Skip to content

Commit

Permalink
Merge pull request #399 from flash62au/master
Browse files Browse the repository at this point in the history
CHANGE - Remove background notifications during the Intro
  • Loading branch information
mstevetodd authored Jan 30, 2019
2 parents 7a94bba + 5791567 commit cd51049
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class connection_activity extends Activity implements PermissionsHelper.P
private static final int FORCED_RESTART_REASON_THROTTLE_PAGE = 5;
private static final int FORCED_RESTART_REASON_LOCALE = 6;

private boolean runIntro = false;
// private boolean runIntro = false;

static {
try {
Expand Down Expand Up @@ -349,7 +349,8 @@ public void onCreate(Bundle savedInstanceState) {

if (!prefs.getString("prefRunIntro", "0").equals(mainapp.INTRO_VERSION)) {
Intent intent = new Intent(this, intro_activity.class); // Call the AppIntro java class
runIntro = true;
// runIntro = true;
// mainapp.introIsRunning = true;
startActivity(intent);
}

Expand Down Expand Up @@ -470,7 +471,8 @@ public void onResume() {
if (this.isFinishing()) { //if finishing, expedite it
return;
}
if (this.runIntro) { //if going to run the intro, expedite it
// if (this.runIntro) { //if going to run the intro, expedite it
if (mainapp.introIsRunning) { //if going to run the intro, expedite it
return;
}

Expand Down Expand Up @@ -502,10 +504,11 @@ public void onResume() {
@Override
public void onPause() {
super.onPause();
if (!this.isFinishing() && !navigatingAway && !runIntro) { //only invoke setContentIntentNotification when going into background
// if (!this.isFinishing() && !navigatingAway && !runIntro) { //only invoke setContentIntentNotification when going into background
if (!this.isFinishing() && !navigatingAway && !mainapp.introIsRunning) { //only invoke setContentIntentNotification when going into background
mainapp.addNotification(this.getIntent());
}
runIntro = false;
// runIntro = false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

mainapp = (threaded_application) this.getApplication();

mainapp.introIsRunning = true;

prefs = getSharedPreferences("jmri.enginedriver_preferences", 0);
originalPrefTheme = prefs.getString("prefTheme", getApplicationContext().getResources().getString(R.string.prefThemeDefaultValue));
originalPrefThrottleType = prefs.getString("prefThrottleScreenType", getApplicationContext().getResources().getString(R.string.prefThrottleScreenTypeDefault));
Expand Down Expand Up @@ -182,6 +184,7 @@ public void onDonePressed(Fragment currentFragment) {
Runtime.getRuntime().exit(0); // really force the kill

}
mainapp.introIsRunning = false;
this.finish();
}

Expand All @@ -194,7 +197,7 @@ public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment ne
@Override
public void onPause() {
super.onPause();
if (!this.isFinishing()) { //only invoke setContentIntentNotification when going into background
if (!this.isFinishing() && !mainapp.introIsRunning) { //only invoke setContentIntentNotification when going into background
mainapp.addNotification(this.getIntent());
}
}
Expand All @@ -211,6 +214,7 @@ public void onResume() {

@Override
public void onDestroy() {
mainapp.introIsRunning = false;
if (!introComplete) {
Toast.makeText(getApplicationContext(), getApplicationContext().getResources().getString(R.string.introbackButtonPress), Toast.LENGTH_LONG).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public class threaded_application extends Application {
public String languageCountry = "en";

public boolean appIsFinishing = false;
public boolean introIsRunning = false;

class comm_thread extends Thread {
JmDNS jmdns = null;
Expand Down Expand Up @@ -2790,6 +2791,7 @@ public String throttleIntToString(int whichThrottle) {
return Integer.toString(whichThrottle);
}

@SuppressLint("ApplySharedPref")
public String fixThrottleName(String currentValue) {
String defaultName = getApplicationContext().getResources().getString(R.string.prefThrottleNameDefaultValue);

Expand Down

0 comments on commit cd51049

Please sign in to comment.