From b6597e675cf979ab98d64f562e33bbf8229bb4e6 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 10 Feb 2023 18:21:08 +0100 Subject: [PATCH] Added advanced option to disable grouping of notifications --- app/src/main/java/eu/faircode/email/Core.java | 6 ++++-- .../email/FragmentOptionsNotifications.java | 12 +++++++++++- .../res/layout/fragment_options_notifications.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 6bd3bf02cb..c968d7fa59 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -5380,6 +5380,7 @@ class Core { boolean pro = ActivityBilling.isPro(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean notify_grouping = prefs.getBoolean("notify_grouping", true); boolean notify_private = prefs.getBoolean("notify_private", true); boolean notify_newest_first = prefs.getBoolean("notify_newest_first", false); MessageHelper.AddressFormat email_format = MessageHelper.getAddressFormat(context); @@ -5437,7 +5438,8 @@ class Core { } // Summary notification - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N || notify_summary) { + if (notify_summary || + (notify_grouping && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)) { // Build pending intents Intent content; if (group < 0) { @@ -5669,7 +5671,7 @@ class Core { mbuilder.setStyle(messagingStyle); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + if (notify_grouping && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) mbuilder .setGroup(Long.toString(group)) .setGroupSummary(false) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index 5db41215d6..13d1425769 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -97,6 +97,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private SwitchCompat swBadge; private ImageButton ibBadge; private SwitchCompat swUnseenIgnored; + private SwitchCompat swNotifyGrouping; private SwitchCompat swNotifyPrivate; private SwitchCompat swNotifyBackgroundOnly; private SwitchCompat swNotifyKnownOnly; @@ -135,7 +136,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared "notify_flag", "notify_seen", "notify_hide", "notify_snooze", "light", "sound", "notify_screen_on", "badge", "unseen_ignored", - "notify_private", "notify_background_only", "notify_known", "notify_suppress_in_call", "notify_suppress_in_car", + "notify_grouping", "notify_private", "notify_background_only", "notify_known", "notify_suppress_in_call", "notify_suppress_in_car", "notify_remove", "notify_clear", "notify_subtext", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate", "wearable_preview", @@ -184,6 +185,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swBadge = view.findViewById(R.id.swBadge); ibBadge = view.findViewById(R.id.ibBadge); swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored); + swNotifyGrouping = view.findViewById(R.id.swNotifyGrouping); swNotifyPrivate = view.findViewById(R.id.swNotifyPrivate); swNotifyBackgroundOnly = view.findViewById(R.id.swNotifyBackgroundOnly); swNotifyKnownOnly = view.findViewById(R.id.swNotifyKnownOnly); @@ -541,6 +543,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared } }); + swNotifyGrouping.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("notify_grouping", checked).apply(); + } + }); + swNotifyPrivate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -811,6 +820,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swBadge.setChecked(prefs.getBoolean("badge", true)); swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false)); + swNotifyGrouping.setChecked(prefs.getBoolean("notify_grouping", true)); swNotifyPrivate.setChecked(prefs.getBoolean("notify_private", true)); swNotifyBackgroundOnly.setChecked(prefs.getBoolean("notify_background_only", false)); swNotifyKnownOnly.setChecked(prefs.getBoolean("notify_known", false)); diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml index 02e3cbc7b6..bb95ae794c 100644 --- a/app/src/main/res/layout/fragment_options_notifications.xml +++ b/app/src/main/res/layout/fragment_options_notifications.xml @@ -526,6 +526,18 @@ app:layout_constraintTop_toBottomOf="@id/ibBadge" app:switchPadding="12dp" /> + + Show launcher icon with number of new messages Let the number of new messages match the number of notifications + Group notifications Keep notifications private when the device is locked Show notifications when in the background only Show notifications for contacts only