mirror of https://github.com/M66B/FairEmail.git
Added option to show notifications when using biometric authentication
This commit is contained in:
parent
23562395fd
commit
5260162986
|
@ -2061,6 +2061,7 @@ class Core {
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||||
|
boolean biometric_notify = prefs.getBoolean("biometrics_notify", false);
|
||||||
boolean flags = prefs.getBoolean("flags", true);
|
boolean flags = prefs.getBoolean("flags", true);
|
||||||
boolean notify_preview = prefs.getBoolean("notify_preview", true);
|
boolean notify_preview = prefs.getBoolean("notify_preview", true);
|
||||||
boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro);
|
boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro);
|
||||||
|
@ -2113,7 +2114,7 @@ class Core {
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||||
.setPublicVersion(pub);
|
.setPublicVersion(pub);
|
||||||
|
|
||||||
if (!biometrics) {
|
if (!biometrics || biometric_notify) {
|
||||||
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
|
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (EntityMessage message : messages) {
|
for (EntityMessage message : messages) {
|
||||||
|
@ -2211,7 +2212,7 @@ class Core {
|
||||||
mbuilder.setDefaults(def);
|
mbuilder.setDefaults(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biometrics)
|
if (biometrics && !biometric_notify)
|
||||||
mbuilder.setContentTitle(context.getResources().getQuantityString(
|
mbuilder.setContentTitle(context.getResources().getQuantityString(
|
||||||
R.plurals.title_notification_unseen, 1, 1));
|
R.plurals.title_notification_unseen, 1, 1));
|
||||||
else {
|
else {
|
||||||
|
@ -2289,7 +2290,7 @@ class Core {
|
||||||
mbuilder.addAction(actionSeen.build());
|
mbuilder.addAction(actionSeen.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!biometrics) {
|
if (!biometrics || biometric_notify) {
|
||||||
if (!TextUtils.isEmpty(message.subject))
|
if (!TextUtils.isEmpty(message.subject))
|
||||||
mbuilder.setContentText(message.subject);
|
mbuilder.setContentText(message.subject);
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,9 @@ import androidx.constraintlayout.widget.Group;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class FragmentOptionsMisc extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
private Spinner spBiometricsTimeout;
|
|
||||||
private SwitchCompat swDoubleBack;
|
private SwitchCompat swDoubleBack;
|
||||||
|
private Spinner spBiometricsTimeout;
|
||||||
|
private SwitchCompat swBiometricsNotify;
|
||||||
private SwitchCompat swEnglish;
|
private SwitchCompat swEnglish;
|
||||||
private SwitchCompat swWatchdog;
|
private SwitchCompat swWatchdog;
|
||||||
private SwitchCompat swUpdates;
|
private SwitchCompat swUpdates;
|
||||||
|
@ -62,7 +63,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[]{
|
||||||
"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[]{
|
private final static String[] RESET_QUESTIONS = new String[]{
|
||||||
|
@ -79,8 +80,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
|
|
||||||
// Get controls
|
// Get controls
|
||||||
|
|
||||||
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
|
|
||||||
swDoubleBack = view.findViewById(R.id.swDoubleBack);
|
swDoubleBack = view.findViewById(R.id.swDoubleBack);
|
||||||
|
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
|
||||||
|
swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify);
|
||||||
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);
|
||||||
|
@ -101,6 +103,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
|
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
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() {
|
spBiometricsTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
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
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
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() {
|
private void setOptions() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
|
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
|
||||||
|
|
||||||
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
|
int biometrics_timeout = prefs.getInt("biometrics_timeout", 2);
|
||||||
int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues);
|
int[] biometricTimeoutValues = getResources().getIntArray(R.array.biometricsTimeoutValues);
|
||||||
for (int pos = 0; pos < biometricTimeoutValues.length; pos++)
|
for (int pos = 0; pos < biometricTimeoutValues.length; pos++)
|
||||||
|
@ -262,7 +273,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
|
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false));
|
||||||
|
|
||||||
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));
|
||||||
|
|
|
@ -19,17 +19,29 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
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
|
<TextView
|
||||||
android:id="@+id/tvBiometricsTimeout"
|
android:id="@+id/tvBiometricsTimeout"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
android:layout_marginEnd="48dp"
|
android:layout_marginEnd="48dp"
|
||||||
android:text="@string/title_advanced_biometrics_timeout"
|
android:text="@string/title_advanced_biometrics_timeout"
|
||||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
|
||||||
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_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@id/swDoubleBack" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spBiometricsTimeout"
|
android:id="@+id/spBiometricsTimeout"
|
||||||
|
@ -41,12 +53,11 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
|
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swDoubleBack"
|
android:id="@+id/swBiometricsNotify"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:checked="true"
|
android:text="@string/title_advanced_biometrics_notify"
|
||||||
android:text="@string/title_advanced_double_back"
|
|
||||||
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/spBiometricsTimeout"
|
||||||
|
@ -60,7 +71,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/swDoubleBack"
|
app:layout_constraintTop_toBottomOf="@id/swBiometricsNotify"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -280,10 +280,9 @@
|
||||||
<string name="title_advanced_notify_action_hint">At most three actions will be shown</string>
|
<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_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_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_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>
|
||||||
|
@ -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_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_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_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_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>
|
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>
|
||||||
|
|
Loading…
Reference in New Issue