Skip confirm exit on external search

pull/157/head
M66B 6 years ago
parent 3b718aad63
commit 7a8a34343f

@ -91,6 +91,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private RecyclerView rvMenuExtra; private RecyclerView rvMenuExtra;
private boolean exit = false; private boolean exit = false;
private boolean searching = false;
static final int REQUEST_UNIFIED = 1; static final int REQUEST_UNIFIED = 1;
static final int REQUEST_WHY = 2; static final int REQUEST_WHY = 2;
@ -110,12 +111,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
static final String ACTION_EDIT_RULE = BuildConfig.APPLICATION_ID + ".EDIT_RULE"; static final String ACTION_EDIT_RULE = BuildConfig.APPLICATION_ID + ".EDIT_RULE";
static final String ACTION_SHOW_PRO = BuildConfig.APPLICATION_ID + ".SHOW_PRO"; static final String ACTION_SHOW_PRO = BuildConfig.APPLICATION_ID + ".SHOW_PRO";
private static final long EXIT_DELAY = 2500L; // milliseconds
static final long UPDATE_INTERVAL = (BuildConfig.BETA_RELEASE ? 4 : 12) * 3600 * 1000L; // milliseconds static final long UPDATE_INTERVAL = (BuildConfig.BETA_RELEASE ? 4 : 12) * 3600 * 1000L; // milliseconds
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null)
searching = savedInstanceState.getBoolean("fair:searching");
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
startup = prefs.getString("startup", "unified"); startup = prefs.getString("startup", "unified");
@ -445,6 +450,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
if (intent.hasExtra(Intent.EXTRA_PROCESS_TEXT)) { if (intent.hasExtra(Intent.EXTRA_PROCESS_TEXT)) {
searching = true;
String search = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT).toString(); String search = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT).toString();
intent.removeExtra(Intent.EXTRA_PROCESS_TEXT); intent.removeExtra(Intent.EXTRA_PROCESS_TEXT);
@ -460,6 +466,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean("fair:toggle", drawerToggle.isDrawerIndicatorEnabled()); outState.putBoolean("fair:toggle", drawerToggle.isDrawerIndicatorEnabled());
outState.putBoolean("fair:searching", searching);
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@ -519,14 +526,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (exit || count > 1) if (exit || count > 1)
super.onBackPressed(); super.onBackPressed();
else if (!backHandled()) { else if (!backHandled()) {
exit = true; if (searching)
Toast.makeText(this, R.string.app_exit, Toast.LENGTH_SHORT).show(); super.onBackPressed();
new Handler().postDelayed(new Runnable() { else {
@Override exit = true;
public void run() { Toast.makeText(this, R.string.app_exit, Toast.LENGTH_SHORT).show();
exit = false; new Handler().postDelayed(new Runnable() {
} @Override
}, 2500); public void run() {
exit = false;
}
}, EXIT_DELAY);
}
} }
} }
} }

Loading…
Cancel
Save