Added option to show notifications when using biometric authentication

This commit is contained in:
M66B 2019-08-20 21:45:47 +02:00
parent 23562395fd
commit 5260162986
4 changed files with 42 additions and 17 deletions

View File

@ -2061,6 +2061,7 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean biometrics = prefs.getBoolean("biometrics", false);
boolean biometric_notify = prefs.getBoolean("biometrics_notify", false);
boolean flags = prefs.getBoolean("flags", true);
boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro);
@ -2113,7 +2114,7 @@ class Core {
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setPublicVersion(pub);
if (!biometrics) {
if (!biometrics || biometric_notify) {
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
StringBuilder sb = new StringBuilder();
for (EntityMessage message : messages) {
@ -2211,7 +2212,7 @@ class Core {
mbuilder.setDefaults(def);
}
if (biometrics)
if (biometrics && !biometric_notify)
mbuilder.setContentTitle(context.getResources().getQuantityString(
R.plurals.title_notification_unseen, 1, 1));
else {
@ -2289,7 +2290,7 @@ class Core {
mbuilder.addAction(actionSeen.build());
}
if (!biometrics) {
if (!biometrics || biometric_notify) {
if (!TextUtils.isEmpty(message.subject))
mbuilder.setContentText(message.subject);

View File

@ -45,8 +45,9 @@ import androidx.constraintlayout.widget.Group;
import androidx.preference.PreferenceManager;
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private Spinner spBiometricsTimeout;
private SwitchCompat swDoubleBack;
private Spinner spBiometricsTimeout;
private SwitchCompat swBiometricsNotify;
private SwitchCompat swEnglish;
private SwitchCompat swWatchdog;
private SwitchCompat swUpdates;
@ -62,7 +63,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Group grpDebug;
private final static String[] RESET_OPTIONS = new String[]{
"biometrics_timeout", "double_back", "english", "watchdog", "updates", "crash_reports", "debug"
"double_back", "biometrics_timeout", "biometrics_notify", "english", "watchdog", "updates", "crash_reports", "debug"
};
private final static String[] RESET_QUESTIONS = new String[]{
@ -79,8 +80,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
// Get controls
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swDoubleBack = view.findViewById(R.id.swDoubleBack);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify);
swEnglish = view.findViewById(R.id.swEnglish);
swWatchdog = view.findViewById(R.id.swWatchdog);
swUpdates = view.findViewById(R.id.swUpdates);
@ -101,6 +103,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swDoubleBack.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("double_back", checked).apply();
}
});
spBiometricsTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -114,10 +123,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swDoubleBack.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
swBiometricsNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("double_back", checked).apply();
prefs.edit().putBoolean("biometrics_notify", checked).apply();
}
});
@ -254,6 +263,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues);
for (int pos = 0; pos < biometricTimeoutValues.length; pos++)
@ -262,7 +273,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
break;
}
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false));
swEnglish.setChecked(prefs.getBoolean("english", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swUpdates.setChecked(prefs.getBoolean("updates", true));

View File

@ -19,17 +19,29 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDoubleBack"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/title_advanced_double_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvBiometricsTimeout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_biometrics_timeout"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/swDoubleBack" />
<Spinner
android:id="@+id/spBiometricsTimeout"
@ -41,12 +53,11 @@
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDoubleBack"
android:id="@+id/swBiometricsNotify"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_double_back"
android:text="@string/title_advanced_biometrics_notify"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout"
@ -60,7 +71,7 @@
android:text="@string/title_advanced_english"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDoubleBack"
app:layout_constraintTop_toBottomOf="@id/swBiometricsNotify"
app:switchPadding="12dp" />
<TextView

View File

@ -280,10 +280,9 @@
<string name="title_advanced_notify_action_hint">At most three actions will be shown</string>
<string name="title_advanced_notify_manage_hint">Tap on the channel name \'Notifications\' to set the default notification sound, etc</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_biometrics_timeout">Biometric authentication timeout</string>
<string name="title_advanced_double_back">Double \'back\' to exit</string>
<string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string>
<string name="title_advanced_biometrics_notify">Show notification content when using biometric authentication</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_updates">Check for updates</string>
@ -302,6 +301,8 @@
<string name="title_advanced_unseen_hint">Some providers don\'t support this properly, which, for example, may result in all messages being synchronized</string>
<string name="title_advanced_sync_kept_hint">This will transfer extra data and consume extra battery power, especially if a lot of messages are stored on the device</string>
<string name="title_advanced_sync_folders_hint">Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too</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_lookup_mx_hint">This will check if DNS MX records exist</string>
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>