From bfc04d2ae201709088e316ad7f885c50e4cc1229 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 10 Oct 2019 17:09:56 +0200 Subject: [PATCH] Make sure move marks seen / remove flags --- app/src/main/java/eu/faircode/email/Core.java | 37 ++++++++----------- .../eu/faircode/email/EntityOperation.java | 7 +++- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 6126ba465f..f2634ed072 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -763,6 +763,9 @@ class Core { // Get arguments long id = jargs.getLong(0); + boolean seen = jargs.optBoolean(1); + boolean unflag = jargs.optBoolean(3); + Flags flags = ifolder.getPermanentFlags(); // Get target folder @@ -813,19 +816,15 @@ class Core { itarget.appendMessages(icopies.toArray(new Message[0])); } else { for (Message imessage : map.keySet()) { - EntityMessage message = map.get(imessage); + Log.i("Move seen=" + seen + " unflag=" + unflag); - // Auto read - if (flags.contains(Flags.Flag.SEEN)) - imessage.setFlag(Flags.Flag.SEEN, message.ui_seen); + // Mark read + if (seen && flags.contains(Flags.Flag.SEEN)) + imessage.setFlag(Flags.Flag.SEEN, true); - // Auto unflag - if (flags.contains(Flags.Flag.FLAGGED)) - imessage.setFlag(Flags.Flag.FLAGGED, message.ui_flagged); - - // Answered fix - if (flags.contains(Flags.Flag.ANSWERED)) - imessage.setFlag(Flags.Flag.ANSWERED, message.ui_answered); + // Remove star + if (unflag && flags.contains(Flags.Flag.FLAGGED)) + imessage.setFlag(Flags.Flag.FLAGGED, false); } ifolder.copyMessages(map.keySet().toArray(new Message[0]), itarget); @@ -854,17 +853,13 @@ class Core { if (draft) { Message icopy = itarget.getMessageByUID(uid); - // Auto read - if (flags.contains(Flags.Flag.SEEN)) - icopy.setFlag(Flags.Flag.SEEN, message.ui_seen); + // Mark read + if (seen && flags.contains(Flags.Flag.SEEN)) + icopy.setFlag(Flags.Flag.SEEN, true); - // Auto unflag - if (flags.contains(Flags.Flag.FLAGGED)) - icopy.setFlag(Flags.Flag.FLAGGED, message.ui_flagged); - - // Answered fix - if (flags.contains(Flags.Flag.ANSWERED)) - icopy.setFlag(Flags.Flag.ANSWERED, message.ui_answered); + // Remove star + if (unflag && flags.contains(Flags.Flag.FLAGGED)) + icopy.setFlag(Flags.Flag.FLAGGED, false); // Set drafts flag icopy.setFlag(Flags.Flag.DRAFT, EntityFolder.DRAFTS.equals(target.type)); diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index 2bef26a03f..cd4ced6a69 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -140,15 +140,18 @@ public class EntityOperation { else if (MOVE.equals(name)) { // Parameters: // 0: target folder - // 1: mark read (rule) + // 1: mark seen // 2: temporary message + // 3: remove flag SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean autoread = prefs.getBoolean("autoread", false); boolean autounflag = prefs.getBoolean("autounflag", false); - if (jargs.optBoolean(1)) + if (jargs.optBoolean(1)) // rule autoread = true; + jargs.put(1, autoread); + jargs.put(3, autounflag); EntityFolder source = db.folder().getFolder(message.folder); EntityFolder target = db.folder().getFolder(jargs.getLong(0));