Restore on launch by default

This commit is contained in:
M66B
2025-05-19 22:02:46 +02:00
parent 71362110c2
commit 1c9b4df261
4 changed files with 9 additions and 12 deletions

View File

@@ -43,8 +43,6 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
public class ActivityMain extends ActivityBase implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
static final int RESTORE_STATE_INTERVAL = 3; // minutes
private static final long SPLASH_DELAY = 1500L; // milliseconds
private static final long SERVICE_START_DELAY = 5 * 1000L; // milliseconds
private static final long IGNORE_STORAGE_SPACE = 24 * 60 * 60 * 1000L; // milliseconds
@@ -271,10 +269,8 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
// VX-N3
// https://developer.android.com/docs/quality-guidelines/core-app-quality
long now = new Date().getTime();
long last = prefs.getLong("last_launched", 0L);
boolean restore_on_launch = prefs.getBoolean("restore_on_launch", false);
if (!restore_on_launch || now - last > RESTORE_STATE_INTERVAL * 60 * 1000L)
boolean restore_on_launch = prefs.getBoolean("restore_on_launch", true);
if (!restore_on_launch)
view.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
else {
String last_activity = prefs.getString("last_activity", null);
@@ -288,7 +284,6 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
Intent saved = args.getParcelable("intent");
if (saved == null) {
prefs.edit().putLong("last_launched", now).apply();
startActivity(view, options);
if (sync_on_launch)
ServiceUI.sync(ActivityMain.this, null);

View File

@@ -1102,6 +1102,11 @@ public class ApplicationEx extends Application
editor.remove("color_stripe_wide");
}
if (version < 2277) {
if (!prefs.contains("restore_on_launch"))
editor.putBoolean("restore_on_launch", false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
editor.remove("background_service");

View File

@@ -59,7 +59,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private View view;
private ImageButton ibHelp;
private SwitchCompat swRestoreOnLaunch;
private TextView tvRestoreOnLaunchHint;
private SwitchCompat swSyncOnlaunch;
private SwitchCompat swDoubleBack;
private SwitchCompat swConversationActions;
@@ -147,7 +146,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
ibHelp = view.findViewById(R.id.ibHelp);
swRestoreOnLaunch = view.findViewById(R.id.swRestoreOnLaunch);
tvRestoreOnLaunchHint = view.findViewById(R.id.tvRestoreOnLaunchHint);
swSyncOnlaunch = view.findViewById(R.id.swSyncOnlaunch);
swDoubleBack = view.findViewById(R.id.swDoubleBack);
swConversationActions = view.findViewById(R.id.swConversationActions);
@@ -224,7 +222,6 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
tvRestoreOnLaunchHint.setText(getString(R.string.title_advanced_restore_on_launch_hint, ActivityMain.RESTORE_STATE_INTERVAL));
swRestoreOnLaunch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -729,7 +726,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swRestoreOnLaunch.setChecked(prefs.getBoolean("restore_on_launch", false));
swRestoreOnLaunch.setChecked(prefs.getBoolean("restore_on_launch", true));
swSyncOnlaunch.setChecked(prefs.getBoolean("sync_on_launch", false));
swDoubleBack.setChecked(prefs.getBoolean("double_back", false));
swConversationActions.setChecked(prefs.getBoolean("conversation_actions", Helper.isGoogle()));