Improved PIN/biometric handling

This commit is contained in:
M66B 2020-10-30 18:07:32 +01:00
parent 23a99bd761
commit 8cb4c89c76
3 changed files with 24 additions and 5 deletions

View File

@ -187,10 +187,11 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
try {
boolean pro = ActivityBilling.isPro(getContext());
if (pro) {
prefs.edit().putBoolean("biometrics", !biometrics).apply();
btnBiometrics.setText(!biometrics
? R.string.title_setup_biometrics_disable
: R.string.title_setup_biometrics_enable);
SharedPreferences.Editor editor = prefs.edit();
if (!biometrics)
editor.remove("pin");
editor.putBoolean("biometrics", !biometrics);
editor.apply();
} else
startActivity(new Intent(getContext(), ActivityBilling.class));
} catch (Throwable ex) {
@ -357,6 +358,10 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
swHideTimeZone.setChecked(prefs.getBoolean("hide_timezone", true));
String pin = prefs.getString("pin", null);
btnPin.setCompoundDrawablesRelativeWithIntrinsicBounds(
0, 0, TextUtils.isEmpty(pin) ? 0 : R.drawable.twotone_check_12, 0);
boolean biometrics = prefs.getBoolean("biometrics", false);
btnBiometrics.setText(biometrics
? R.string.title_setup_biometrics_disable
@ -405,7 +410,10 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
boolean pro = ActivityBilling.isPro(getContext());
if (pro) {
Helper.setAuthenticated(getContext());
prefs.edit().putString("pin", pin).apply();
prefs.edit()
.remove("biometrics")
.putString("pin", pin)
.apply();
} else
startActivity(new Intent(getContext(), ActivityBilling.class));
}

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="12dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41L9,16.17z"/>
</vector>

View File

@ -168,6 +168,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:drawablePadding="6dp"
android:text="@string/title_advanced_pin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometrics" />