diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 043036bb32..024cf95b59 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -888,6 +888,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac if ("biometrics".equals(key) && !Helper.canAuthenticate(context)) continue; + if ("alert_once".equals(key)) + continue; + Object value = jsetting.get("value"); if (value instanceof Boolean) editor.putBoolean(key, (Boolean) value); diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 8c890b3926..d714c8c1eb 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2114,6 +2114,7 @@ class Core { boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro); boolean light = prefs.getBoolean("light", false); String sound = prefs.getString("sound", null); + boolean alert_once = prefs.getBoolean("alert_once", true); // Get contact info Map messageContact = new HashMap<>(); @@ -2235,7 +2236,7 @@ class Core { .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setCategory(NotificationCompat.CATEGORY_EMAIL) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) - .setOnlyAlertOnce(true); + .setOnlyAlertOnce(alert_once); // TODO: setAllowSystemGeneratedContextualActions diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index aab14c55c5..c0eee34c1f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -67,13 +67,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private ImageButton ibManage; private SwitchCompat swLight; private Button btnSound; + private SwitchCompat swAlertOnce; private Group grpNotification; private final static String[] RESET_OPTIONS = new String[]{ "badge", "unseen_ignored", "notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag", "notify_seen", "biometrics_notify", - "light", "sound" + "light", "sound", "alert_once" }; @Override @@ -102,6 +103,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared ibManage = view.findViewById(R.id.ibManage); swLight = view.findViewById(R.id.swLight); btnSound = view.findViewById(R.id.btnSound); + swAlertOnce = view.findViewById(R.id.swAlertOnce); grpNotification = view.findViewById(R.id.grpNotification); @@ -230,6 +232,16 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared } }); + swAlertOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("alert_once", !checked).apply(); + } + }); + + swAlertOnce.setVisibility(Log.isXiaomi() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); + grpNotification.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); + PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); return view; @@ -297,8 +309,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false)); swLight.setChecked(prefs.getBoolean("light", false)); - - grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE); + swAlertOnce.setChecked(!prefs.getBoolean("alert_once", true)); } @Override diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index e5a26ad800..bd2ce4f359 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -837,4 +837,8 @@ public class Log { return true; } + + static boolean isXiaomi() { + return "Xiaomi".equalsIgnoreCase(Build.MANUFACTURER); + } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml index 0f7eca67dd..190b861ea7 100644 --- a/app/src/main/res/layout/fragment_options_notifications.xml +++ b/app/src/main/res/layout/fragment_options_notifications.xml @@ -235,6 +235,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swLight" /> + + Show notification content when using biometric authentication Use notification light Select notification sound + MIUI notification sound workaround Only available on supported launchers At most three actions will be shown