From bb0c845232ef8fbd549b34921502aa2d898c2ae1 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 14 Dec 2020 18:55:02 +0100 Subject: [PATCH] Added option for sync on launch --- .../main/java/eu/faircode/email/ActivityMain.java | 7 +++++-- .../eu/faircode/email/FragmentOptionsBehavior.java | 12 +++++++++++- .../main/res/layout/fragment_options_behavior.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityMain.java b/app/src/main/java/eu/faircode/email/ActivityMain.java index 4ad66a4ad8..27d6928e31 100644 --- a/app/src/main/java/eu/faircode/email/ActivityMain.java +++ b/app/src/main/java/eu/faircode/email/ActivityMain.java @@ -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) { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index eb71067cfa..a0f34f167d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -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)); diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index 3e5b396205..cc79ec08fb 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -29,6 +29,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + Parse style sheets Show a warning when the receiving server could not authenticate the message + Synchronize on start Double \'back\' to exit Pull down to refresh Scroll to top on receiving new messages