From 9c17a9758dc23957d4e556610200b6386ae0f2be Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 15 Jul 2019 22:13:13 +0200 Subject: [PATCH] Added option to disable double back --- .../main/java/eu/faircode/email/ActivityView.java | 4 +++- .../eu/faircode/email/FragmentOptionsMisc.java | 12 +++++++++++- app/src/main/res/layout/fragment_options_misc.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 711425abfa..6b4787cc6e 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -528,7 +528,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB if (exit || count > 1) super.onBackPressed(); else if (!backHandled()) { - if (searching) + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getOriginalContext()); + boolean double_back = prefs.getBoolean("double_back", true); + if (searching || !double_back) super.onBackPressed(); else { exit = true; diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 39fc7aef91..449378747f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -52,6 +52,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private TextView tvSubscriptionPro; private SwitchCompat swSubscribedOnly; private Spinner spBiometricsTimeout; + private SwitchCompat swDoubleBack; private SwitchCompat swEnglish; private SwitchCompat swWatchdog; private SwitchCompat swUpdates; @@ -67,7 +68,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private Group grpDebug; private final static String[] RESET_OPTIONS = new String[]{ - "badge", "subscriptions", "subscribed_only", "biometrics_timeout", "english", "watchdog", "updates", "crash_reports", "debug" + "badge", "subscriptions", "subscribed_only", "biometrics_timeout", "double_back", "english", "watchdog", "updates", "crash_reports", "debug" }; private final static String[] RESET_QUESTIONS = new String[]{ @@ -89,6 +90,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro); swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly); spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); + swDoubleBack = view.findViewById(R.id.swDoubleBack); swEnglish = view.findViewById(R.id.swEnglish); swWatchdog = view.findViewById(R.id.swWatchdog); swUpdates = view.findViewById(R.id.swUpdates); @@ -147,6 +149,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swDoubleBack.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("double_back", checked).apply(); + } + }); + swEnglish.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -298,6 +307,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc break; } + swDoubleBack.setChecked(prefs.getBoolean("double_back", true)); swEnglish.setChecked(prefs.getBoolean("english", false)); swWatchdog.setChecked(prefs.getBoolean("watchdog", true)); swUpdates.setChecked(prefs.getBoolean("updates", true)); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 343f308bca..7d3839c208 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -110,6 +110,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" /> + + Manage folder subscriptions Synchronize subscribed folders only Biometric authentication timeout + Double \'back\' to exit Force English language Periodically check if FairEmail is still active Check for updates