Added option for sync on launch

This commit is contained in:
M66B
2020-12-14 18:55:02 +01:00
parent 8e8c002b8e
commit bb0c845232
4 changed files with 29 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean eula = prefs.getBoolean("eula", false);
boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false);
prefs.registerOnSharedPreferenceChangeListener(this);
@@ -91,9 +92,11 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent saved = args.getParcelable("intent");
if (saved == null)
if (saved == null) {
startActivity(view);
else
if (sync_on_launch)
ServiceUI.sync(ActivityMain.this, null);
} else
try {
startActivity(saved);
} catch (SecurityException ex) {

View File

@@ -54,6 +54,7 @@ import java.util.ArrayList;
import java.util.List;
public class FragmentOptionsBehavior extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swSyncOnlaunch;
private SwitchCompat swDoubleBack;
private SwitchCompat swConversationActions;
private SwitchCompat swConversationActionsReplies;
@@ -85,7 +86,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private Group grpConversationActions;
private final static String[] RESET_OPTIONS = new String[]{
"double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
"sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
"default_snooze",
"pull", "autoscroll", "quick_filter", "quick_scroll",
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
@@ -104,6 +105,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
// Get controls
swSyncOnlaunch = view.findViewById(R.id.swSyncOnlaunch);
swDoubleBack = view.findViewById(R.id.swDoubleBack);
swConversationActions = view.findViewById(R.id.swConversationActions);
swConversationActionsReplies = view.findViewById(R.id.swConversationActionsReplies);
@@ -147,6 +149,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swSyncOnlaunch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("sync_on_launch", checked).apply();
}
});
swConversationActions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -425,6 +434,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swSyncOnlaunch.setChecked(prefs.getBoolean("sync_on_launch", false));
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
swConversationActions.setChecked(prefs.getBoolean("conversation_actions", true));
swConversationActionsReplies.setChecked(prefs.getBoolean("conversation_actions_replies", true));