Reorganized privacy settings

This commit is contained in:
M66B 2020-03-15 11:04:24 +01:00
parent b59626f628
commit ff6b65e721
2 changed files with 84 additions and 72 deletions

View File

@ -57,17 +57,17 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private SwitchCompat swConfirmImages; private SwitchCompat swConfirmImages;
private SwitchCompat swConfirmHtml; private SwitchCompat swConfirmHtml;
private SwitchCompat swDisableTracking; private SwitchCompat swDisableTracking;
private SwitchCompat swDisplayHidden;
private SwitchCompat swSecure;
private Button btnBiometrics; private Button btnBiometrics;
private Button btnPin; private Button btnPin;
private Spinner spBiometricsTimeout; private Spinner spBiometricsTimeout;
private SwitchCompat swDisplayHidden;
private SwitchCompat swSecure;
private SwitchCompat swSafeBrowsing; private SwitchCompat swSafeBrowsing;
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"confirm_links", "confirm_images", "confirm_html", "confirm_links", "confirm_images", "confirm_html", "disable_tracking",
"disable_tracking", "display_hidden", "secure", "biometrics", "pin", "biometrics_timeout",
"biometrics", "pin", "biometrics_timeout", "safe_browsing" "display_hidden", "secure", "safe_browsing"
}; };
@Override @Override
@ -85,11 +85,11 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swConfirmImages = view.findViewById(R.id.swConfirmImages); swConfirmImages = view.findViewById(R.id.swConfirmImages);
swConfirmHtml = view.findViewById(R.id.swConfirmHtml); swConfirmHtml = view.findViewById(R.id.swConfirmHtml);
swDisableTracking = view.findViewById(R.id.swDisableTracking); swDisableTracking = view.findViewById(R.id.swDisableTracking);
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
swSecure = view.findViewById(R.id.swSecure);
btnBiometrics = view.findViewById(R.id.btnBiometrics); btnBiometrics = view.findViewById(R.id.btnBiometrics);
btnPin = view.findViewById(R.id.btnPin); btnPin = view.findViewById(R.id.btnPin);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swDisplayHidden = view.findViewById(R.id.swDisplayHidden);
swSecure = view.findViewById(R.id.swSecure);
swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing); swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing);
setOptions(); 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() { btnBiometrics.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? View.GONE : View.VISIBLE);
swSafeBrowsing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swSafeBrowsing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -250,8 +250,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swConfirmImages.setChecked(prefs.getBoolean("confirm_images", true)); swConfirmImages.setChecked(prefs.getBoolean("confirm_images", true));
swConfirmHtml.setChecked(prefs.getBoolean("confirm_html", true)); swConfirmHtml.setChecked(prefs.getBoolean("confirm_html", true));
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", 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); boolean biometrics = prefs.getBoolean("biometrics", false);
btnBiometrics.setText(biometrics btnBiometrics.setText(biometrics
@ -267,6 +265,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
break; break;
} }
swDisplayHidden.setChecked(prefs.getBoolean("display_hidden", false));
swSecure.setChecked(prefs.getBoolean("secure", false));
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", true)); swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", true));
} }

View File

@ -115,52 +115,6 @@
app:layout_constraintTop_toBottomOf="@+id/tvConfirmHtmlHint" app:layout_constraintTop_toBottomOf="@+id/tvConfirmHtmlHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDisplayHidden"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_display_hidden"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDisableTracking"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvDisplayHiddenHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_display_hidden_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDisplayHidden" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSecure"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_secure"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDisplayHiddenHint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSecureHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_english_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSecure" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvBiometrics" android:id="@+id/tvBiometrics"
android:layout_width="0dp" android:layout_width="0dp"
@ -172,7 +126,7 @@
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
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/tvSecureHint" /> app:layout_constraintTop_toBottomOf="@id/swDisableTracking" />
<Button <Button
android:id="@+id/btnBiometrics" android:id="@+id/btnBiometrics"
@ -232,6 +186,64 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" /> app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvAdvanced"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:gravity="center"
android:text="@string/title_advanced_advanced"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDisplayHidden"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_display_hidden"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAdvanced"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvDisplayHiddenHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_display_hidden_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDisplayHidden" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSecure"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_secure"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDisplayHiddenHint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSecureHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_english_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSecure" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSafeBrowsing" android:id="@+id/swSafeBrowsing"
android:layout_width="0dp" android:layout_width="0dp"
@ -241,7 +253,7 @@
android:text="@string/title_advanced_safe_browsing" android:text="@string/title_advanced_safe_browsing"
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/tvSecureHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>