diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index df32192e84..e89dfb2197 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -778,10 +778,16 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB intent.setAction(null); setIntent(intent); - if ("unified".equals(action)) { + if (action.startsWith("unified")) { if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) getSupportFragmentManager().popBackStack("unified", 0); + if (action.contains(":")) { + Intent clear = new Intent(this, ServiceUI.class) + .setAction(action.replace("unified", "clear")); + startService(clear); + } + } else if ("why".equals(action)) { if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) getSupportFragmentManager().popBackStack("unified", 0); diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index a8a635ef8d..08572b20a2 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2674,6 +2674,7 @@ class Core { boolean notify_flag = (prefs.getBoolean("notify_flag", false) && flags && pro); boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro); boolean notify_snooze = (prefs.getBoolean("notify_snooze", false) || !pro); + boolean notify_remove = prefs.getBoolean("notify_remove", true); boolean light = prefs.getBoolean("light", false); String sound = prefs.getString("sound", null); boolean alert_once = prefs.getBoolean("alert_once", true); @@ -2686,8 +2687,9 @@ class Core { // Summary notification if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N || notify_summary) { // Build pending intents - Intent summary = new Intent(context, ActivityView.class).setAction("unified"); - PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT); + Intent unified = new Intent(context, ActivityView.class) + .setAction("unified" + (notify_remove ? ":" + group : "")); + PendingIntent piUnified = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, unified, PendingIntent.FLAG_UPDATE_CURRENT); Intent clear = new Intent(context, ServiceUI.class).setAction("clear:" + group); PendingIntent piClear = PendingIntent.getService(context, ServiceUI.PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT); @@ -2701,7 +2703,7 @@ class Core { new NotificationCompat.Builder(context, "notification") .setSmallIcon(R.drawable.baseline_email_white_24) .setContentTitle(title) - .setContentIntent(piSummary) + .setContentIntent(piUnified) .setNumber(messages.size()) .setShowWhen(false) .setDeleteIntent(piClear) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index 0b4dc185e5..c851dc3ff4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -57,6 +57,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private SwitchCompat swBadge; private SwitchCompat swUnseenIgnored; private SwitchCompat swNotifySummary; + private SwitchCompat swNotifyRemove; private SwitchCompat swNotifyPreview; private CheckBox cbNotifyActionTrash; private CheckBox cbNotifyActionJunk; @@ -68,7 +69,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private CheckBox cbNotifyActionSnooze; private EditText etNotifyActionSnooze; private TextView tvNotifyActionsPro; - private SwitchCompat swNotifyRemove; private SwitchCompat swBiometricsNotify; private Button btnManage; private TextView tvManageHint; @@ -83,8 +83,9 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private final static String[] RESET_OPTIONS = new String[]{ "badge", "unseen_ignored", - "notify_summary", "notify_preview", "notify_trash", "notify_junk", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag", - "notify_seen", "notify_snooze", "notify_snooze_duration", "notify_remove", + "notify_summary", "notify_remove", "notify_preview", + "notify_trash", "notify_junk", "notify_archive", "notify_reply", "notify_reply_direct", + "notify_flag", "notify_seen", "notify_snooze", "notify_snooze_duration", "biometrics_notify", "light", "sound", "alert_once" }; @@ -102,6 +103,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swBadge = view.findViewById(R.id.swBadge); swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored); swNotifySummary = view.findViewById(R.id.swNotifySummary); + swNotifyRemove = view.findViewById(R.id.swNotifyRemove); swNotifyPreview = view.findViewById(R.id.swNotifyPreview); cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash); cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk); @@ -113,7 +115,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared cbNotifyActionSnooze = view.findViewById(R.id.cbNotifyActionSnooze); etNotifyActionSnooze = view.findViewById(R.id.etNotifyActionSnooze); tvNotifyActionsPro = view.findViewById(R.id.tvNotifyActionsPro); - swNotifyRemove = view.findViewById(R.id.swNotifyRemove); swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify); btnManage = view.findViewById(R.id.btnManage); tvManageHint = view.findViewById(R.id.tvManageHint); @@ -157,6 +158,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared } }); + swNotifyRemove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("notify_remove", checked).apply(); + } + }); + swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -241,13 +249,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared Helper.linkPro(tvNotifyActionsPro); - swNotifyRemove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("notify_remove", checked).apply(); - } - }); - swBiometricsNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -400,7 +401,6 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared cbNotifyActionSeen.setEnabled(pro && !checked); cbNotifyActionSnooze.setEnabled(pro && !checked); etNotifyActionSnooze.setEnabled(pro && !checked); - swNotifyRemove.setEnabled(pro && !checked); swBiometricsNotify.setEnabled(!checked); } diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index 7e01ea80b9..6cf372504b 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -314,11 +314,6 @@ public class ServiceUI extends IntentService { } private void onIgnore(long id) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - boolean notify_remove = prefs.getBoolean("notify_remove", true); - if (!notify_remove) - return; - DB db = DB.getInstance(this); try { db.beginTransaction(); diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml index 8423a26779..4ecfd08217 100644 --- a/app/src/main/res/layout/fragment_options_notifications.xml +++ b/app/src/main/res/layout/fragment_options_notifications.xml @@ -57,6 +57,31 @@ app:layout_constraintTop_toBottomOf="@id/swUnseenIgnored" app:switchPadding="12dp" /> + + + + - - - -