diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 8ed0e383fd..0423b3f113 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -479,8 +479,10 @@ public interface DaoMessage { @Query("UPDATE message SET ui_ignored = 1" + " WHERE (:account IS NULL OR account = :account)" + " AND NOT ui_ignored" + - " AND folder IN (SELECT id FROM folder WHERE folder.unified)") - int ignoreAll(Long account); + " AND folder IN (" + + " SELECT id FROM folder" + + " WHERE (:folder IS NULL AND folder.unified) OR id = :folder)") + int ignoreAll(Long account, Long folder); @Query("UPDATE message SET ui_found = 1" + " WHERE account = :account" + diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 5b58800180..cef8b1fd32 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -2444,6 +2444,32 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. prefs.registerOnSharedPreferenceChangeListener(this); onSharedPreferenceChanged(prefs, "pro"); + + if (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER) { + boolean notify_clear = prefs.getBoolean("notify_clear", false); + if (notify_clear) { + Bundle args = new Bundle(); + args.putLong("folder", folder); + + new SimpleTask() { + @Override + protected Void onExecute(Context context, Bundle args) { + Long folder = args.getLong("folder"); + if (folder < 0) + folder = null; + + DB db = DB.getInstance(context); + db.message().ignoreAll(null, folder); + return null; + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(getParentFragmentManager(), ex); + } + }.execute(this, args, "messages:ignore"); + } + } } @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index 67736da4f6..f0ec22ff93 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -55,6 +55,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private SwitchCompat swUnseenIgnored; private SwitchCompat swNotifySummary; private SwitchCompat swNotifyRemove; + private SwitchCompat swNotifyClear; private SwitchCompat swNotifyPreview; private SwitchCompat swWearablePreview; private CheckBox cbNotifyActionTrash; @@ -81,7 +82,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private final static String[] RESET_OPTIONS = new String[]{ "badge", "unseen_ignored", - "notify_summary", "notify_remove", "notify_preview", "wearable_preview", + "notify_summary", "notify_remove", "notify_clear", "notify_preview", "wearable_preview", "notify_trash", "notify_junk", "notify_archive", "notify_move", "notify_reply", "notify_reply_direct", "notify_flag", "notify_seen", "notify_snooze", @@ -103,6 +104,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored); swNotifySummary = view.findViewById(R.id.swNotifySummary); swNotifyRemove = view.findViewById(R.id.swNotifyRemove); + swNotifyClear = view.findViewById(R.id.swNotifyClear); swNotifyPreview = view.findViewById(R.id.swNotifyPreview); swWearablePreview = view.findViewById(R.id.swWearablePreview); cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash); @@ -165,6 +167,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared } }); + swNotifyClear.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("notify_clear", checked).apply(); + } + }); + swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -363,6 +372,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false)); swNotifySummary.setChecked(prefs.getBoolean("notify_summary", false)); swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true)); + swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false)); swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", true)); diff --git a/app/src/main/java/eu/faircode/email/ServiceUI.java b/app/src/main/java/eu/faircode/email/ServiceUI.java index d6b1200ea6..f77aca49d6 100644 --- a/app/src/main/java/eu/faircode/email/ServiceUI.java +++ b/app/src/main/java/eu/faircode/email/ServiceUI.java @@ -161,7 +161,7 @@ public class ServiceUI extends IntentService { private void onClear(long group) { DB db = DB.getInstance(this); - int cleared = db.message().ignoreAll(group == 0 ? null : group); + int cleared = db.message().ignoreAll(group == 0 ? null : group, null); Log.i("Cleared=" + cleared); } diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml index cceb76585c..fefdf503da 100644 --- a/app/src/main/res/layout/fragment_options_notifications.xml +++ b/app/src/main/res/layout/fragment_options_notifications.xml @@ -82,6 +82,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swNotifyRemove" /> + + Read Snooze Remove new message notification on tapping on notification + Remove new message notifications on viewing message list Only send notifications with a message preview to wearables Show notification content when using biometric authentication Use notification light