From 75b77791b497d67760d6251e270ef3ee39b7d7b5 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 22 Jun 2021 21:09:09 +0200 Subject: [PATCH] Simplified hide/snooze messages --- .../eu/faircode/email/FragmentMessages.java | 44 +++++++++---------- .../eu/faircode/email/ServiceSynchronize.java | 6 +-- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 76e2fd68bd..1f3537ebc2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -3149,7 +3149,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. args.putLong("time", 0); } - onSnooze(args); + onSnoozeOrHide(args); } private void onActionHide(TupleMessageEx message) { @@ -3159,9 +3159,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. args.putLong("id", message.id); args.putLong("duration", message.ui_snoozed == null ? Long.MAX_VALUE : 0); args.putLong("time", message.ui_snoozed == null ? Long.MAX_VALUE : 0); - args.putBoolean("hide", true); - onSnooze(args); + onSnoozeOrHide(args); } private void onActionSnoozeSelection() { @@ -6167,7 +6166,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. break; case REQUEST_MESSAGE_SNOOZE: if (resultCode == RESULT_OK && data != null) - onSnooze(data.getBundleExtra("args")); + onSnoozeOrHide(data.getBundleExtra("args")); break; case REQUEST_MESSAGES_SNOOZE: if (resultCode == RESULT_OK && data != null) @@ -7528,7 +7527,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. }.execute(this, args, "message:color"); } - private void onSnooze(Bundle args) { + private void onSnoozeOrHide(Bundle args) { long duration = args.getLong("duration"); long time = args.getLong("time"); args.putLong("wakeup", duration == 0 ? -1 : time); @@ -7542,7 +7541,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. Long wakeup = args.getLong("wakeup"); if (wakeup < 0) wakeup = null; - boolean hide = args.getBoolean("hide"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean flag_snoozed = prefs.getBoolean("flag_snoozed", false); @@ -7559,14 +7557,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. account, thread, threading ? null : id, null); for (EntityMessage threaded : messages) { db.message().setMessageUnsnoozed(threaded.id, false); - db.message().setMessageSnoozed(threaded.id, wakeup); - if (threaded.id.equals(id)) - EntityOperation.queue(context, threaded, EntityOperation.SEEN, true, wakeup == null); - else - db.message().setMessageUiIgnored(threaded.id, true); - if (!hide && flag_snoozed && threaded.folder.equals(message.folder)) - EntityOperation.queue(context, threaded, EntityOperation.FLAG, wakeup != null); - EntityMessage.snooze(context, threaded.id, wakeup); + if (wakeup == null || wakeup == Long.MAX_VALUE || threaded.id.equals(id)) { + db.message().setMessageSnoozed(threaded.id, wakeup); + EntityMessage.snooze(context, threaded.id, wakeup); + if (wakeup != null && wakeup != Long.MAX_VALUE && threaded.id.equals(id)) { + EntityOperation.queue(context, threaded, EntityOperation.SEEN, true); + if (flag_snoozed) + EntityOperation.queue(context, threaded, EntityOperation.FLAG, true); + } + } } db.setTransactionSuccessful(); @@ -7627,14 +7626,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. message.account, message.thread, threading ? null : id, null); for (EntityMessage threaded : messages) { db.message().setMessageUnsnoozed(threaded.id, false); - db.message().setMessageSnoozed(threaded.id, wakeup); - if (threaded.id.equals(id)) - EntityOperation.queue(context, threaded, EntityOperation.SEEN, true, wakeup == null); - else - db.message().setMessageUiIgnored(threaded.id, true); - if (flag_snoozed && threaded.folder.equals(message.folder)) - EntityOperation.queue(context, threaded, EntityOperation.FLAG, wakeup != null); - EntityMessage.snooze(context, threaded.id, wakeup); + if (wakeup == null || threaded.id.equals(id)) { + db.message().setMessageSnoozed(threaded.id, wakeup); + EntityMessage.snooze(context, threaded.id, wakeup); + if (wakeup != null && threaded.id.equals(id)) { + EntityOperation.queue(context, threaded, EntityOperation.SEEN, true); + if (flag_snoozed) + EntityOperation.queue(context, threaded, EntityOperation.FLAG, true); + } + } } } diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index f6a4702f09..af5c034789 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -969,10 +969,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences } db.message().setMessageSnoozed(message.id, null); - if (!message.ui_ignored) { - db.message().setMessageUnsnoozed(message.id, true); - EntityOperation.queue(ServiceSynchronize.this, message, EntityOperation.SEEN, false, false); - } + db.message().setMessageUnsnoozed(message.id, true); + EntityOperation.queue(ServiceSynchronize.this, message, EntityOperation.SEEN, false, false); } db.setTransactionSuccessful();