From ff6b65e72167a04491db889d9e050de88a7ea174 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 15 Mar 2020 11:04:24 +0100 Subject: [PATCH] Reorganized privacy settings --- .../email/FragmentOptionsPrivacy.java | 48 ++++---- .../res/layout/fragment_options_privacy.xml | 108 ++++++++++-------- 2 files changed, 84 insertions(+), 72 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java index 2c1829e6b1..31198f85de 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java @@ -57,17 +57,17 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer private SwitchCompat swConfirmImages; private SwitchCompat swConfirmHtml; private SwitchCompat swDisableTracking; - private SwitchCompat swDisplayHidden; - private SwitchCompat swSecure; private Button btnBiometrics; private Button btnPin; private Spinner spBiometricsTimeout; + private SwitchCompat swDisplayHidden; + private SwitchCompat swSecure; private SwitchCompat swSafeBrowsing; private final static String[] RESET_OPTIONS = new String[]{ - "confirm_links", "confirm_images", "confirm_html", - "disable_tracking", "display_hidden", "secure", - "biometrics", "pin", "biometrics_timeout", "safe_browsing" + "confirm_links", "confirm_images", "confirm_html", "disable_tracking", + "biometrics", "pin", "biometrics_timeout", + "display_hidden", "secure", "safe_browsing" }; @Override @@ -85,11 +85,11 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer swConfirmImages = view.findViewById(R.id.swConfirmImages); swConfirmHtml = view.findViewById(R.id.swConfirmHtml); swDisableTracking = view.findViewById(R.id.swDisableTracking); - swDisplayHidden = view.findViewById(R.id.swDisplayHidden); - swSecure = view.findViewById(R.id.swSecure); btnBiometrics = view.findViewById(R.id.btnBiometrics); btnPin = view.findViewById(R.id.btnPin); spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); + swDisplayHidden = view.findViewById(R.id.swDisplayHidden); + swSecure = view.findViewById(R.id.swSecure); swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing); setOptions(); @@ -126,21 +126,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer } }); - swDisplayHidden.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("display_hidden", checked).apply(); - } - }); - - swSecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("secure", checked).commit(); // apply won't work here - restart(); - } - }); - btnBiometrics.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -192,6 +177,21 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer } }); + swDisplayHidden.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("display_hidden", checked).apply(); + } + }); + + swSecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("secure", checked).commit(); // apply won't work here + restart(); + } + }); + swSafeBrowsing.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? View.GONE : View.VISIBLE); swSafeBrowsing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -250,8 +250,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer swConfirmImages.setChecked(prefs.getBoolean("confirm_images", true)); swConfirmHtml.setChecked(prefs.getBoolean("confirm_html", true)); swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true)); - swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false)); - swSecure.setChecked(prefs.getBoolean("secure", false)); boolean biometrics = prefs.getBoolean("biometrics", false); btnBiometrics.setText(biometrics @@ -267,6 +265,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer break; } + swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false)); + swSecure.setChecked(prefs.getBoolean("secure", false)); swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", true)); } diff --git a/app/src/main/res/layout/fragment_options_privacy.xml b/app/src/main/res/layout/fragment_options_privacy.xml index 5791088f46..fac7354a05 100644 --- a/app/src/main/res/layout/fragment_options_privacy.xml +++ b/app/src/main/res/layout/fragment_options_privacy.xml @@ -115,52 +115,6 @@ app:layout_constraintTop_toBottomOf="@+id/tvConfirmHtmlHint" app:switchPadding="12dp" /> - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/swDisableTracking" />