Added option to disable double back

pull/159/head
M66B 5 years ago
parent 075d3dc6e9
commit 9c17a9758d

@ -528,7 +528,9 @@ 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()) {
if (searching) SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getOriginalContext());
boolean double_back = prefs.getBoolean("double_back", true);
if (searching || !double_back)
super.onBackPressed(); super.onBackPressed();
else { else {
exit = true; exit = true;

@ -52,6 +52,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvSubscriptionPro; private TextView tvSubscriptionPro;
private SwitchCompat swSubscribedOnly; private SwitchCompat swSubscribedOnly;
private Spinner spBiometricsTimeout; private Spinner spBiometricsTimeout;
private SwitchCompat swDoubleBack;
private SwitchCompat swEnglish; private SwitchCompat swEnglish;
private SwitchCompat swWatchdog; private SwitchCompat swWatchdog;
private SwitchCompat swUpdates; private SwitchCompat swUpdates;
@ -67,7 +68,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Group grpDebug; private Group grpDebug;
private final static String[] RESET_OPTIONS = new String[]{ 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[]{ 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); tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro);
swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly); swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swDoubleBack = view.findViewById(R.id.swDoubleBack);
swEnglish = view.findViewById(R.id.swEnglish); swEnglish = view.findViewById(R.id.swEnglish);
swWatchdog = view.findViewById(R.id.swWatchdog); swWatchdog = view.findViewById(R.id.swWatchdog);
swUpdates = view.findViewById(R.id.swUpdates); 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() { swEnglish.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -298,6 +307,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
break; break;
} }
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
swEnglish.setChecked(prefs.getBoolean("english", false)); swEnglish.setChecked(prefs.getBoolean("english", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true)); swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setChecked(prefs.getBoolean("updates", true));

@ -110,6 +110,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" /> app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDoubleBack"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_double_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swEnglish" android:id="@+id/swEnglish"
android:layout_width="0dp" android:layout_width="0dp"
@ -118,7 +130,7 @@
android:text="@string/title_advanced_english" android:text="@string/title_advanced_english"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout" app:layout_constraintTop_toBottomOf="@id/swDoubleBack"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView

@ -254,6 +254,7 @@
<string name="title_advanced_subscriptions">Manage folder subscriptions</string> <string name="title_advanced_subscriptions">Manage folder subscriptions</string>
<string name="title_advanced_sync_subscribed">Synchronize subscribed folders only</string> <string name="title_advanced_sync_subscribed">Synchronize subscribed folders only</string>
<string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string> <string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string>
<string name="title_advanced_double_back">Double \'back\' to exit</string>
<string name="title_advanced_english">Force English language</string> <string name="title_advanced_english">Force English language</string>
<string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string> <string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string>
<string name="title_advanced_updates">Check for updates</string> <string name="title_advanced_updates">Check for updates</string>

Loading…
Cancel
Save