From 87ef625c56ce923884082683287864f514a1b214 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 29 Dec 2021 09:31:46 +0100 Subject: [PATCH] Store importance as flag --- .../eu/faircode/email/AdapterMessage.java | 19 ++++++++++++++++++- app/src/main/java/eu/faircode/email/Core.java | 7 +++++++ .../eu/faircode/email/EntityOperation.java | 12 +++++++++--- .../java/eu/faircode/email/EntityRule.java | 5 +++++ .../eu/faircode/email/FragmentMessages.java | 8 +++++++- .../java/eu/faircode/email/MessageHelper.java | 16 +++++++++++----- 6 files changed, 57 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index d4c0c2567c..285d07cadd 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -5263,7 +5263,24 @@ public class AdapterMessage extends RecyclerView.Adapter messages = db.message().getMessagesByThread( message.account, message.thread, threading ? null : id, message.folder); - for (EntityMessage threaded : messages) + for (EntityMessage threaded : messages) { db.message().setMessageImportance(threaded.id, importance); + + EntityOperation.queue(context, threaded, EntityOperation.KEYWORD, + MessageHelper.FLAG_LOW_IMPORTANCE, EntityMessage.PRIORITIY_LOW.equals(importance)); + EntityOperation.queue(context, threaded, EntityOperation.KEYWORD, + MessageHelper.FLAG_HIGH_IMPORTANCE, EntityMessage.PRIORITIY_HIGH.equals(importance)); + } } db.setTransactionSuccessful(); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index ad64606b13..49e19b235b 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -27,6 +27,7 @@ import android.net.Uri; import android.system.ErrnoException; import android.text.TextUtils; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.net.MailTo; import androidx.documentfile.provider.DocumentFile; @@ -167,15 +168,19 @@ public class MessageHelper { static final String FLAG_NOT_DELIVERED = "$NotDelivered"; static final String FLAG_DISPLAYED = "$Displayed"; static final String FLAG_NOT_DISPLAYED = "$NotDisplayed"; + static final String FLAG_LOW_IMPORTANCE = "$LowImportance"; + static final String FLAG_HIGH_IMPORTANCE = "$HighImportance"; // https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml // Not black listed: Gmail $Phishing private static final List FLAG_BLACKLIST = Collections.unmodifiableList(Arrays.asList( - MessageHelper.FLAG_FORWARDED, - MessageHelper.FLAG_JUNK, - MessageHelper.FLAG_NOT_JUNK, - MessageHelper.FLAG_CLASSIFIED, // FairEmail - MessageHelper.FLAG_FILTERED, // FairEmail + FLAG_FORWARDED, + FLAG_JUNK, + FLAG_NOT_JUNK, + FLAG_CLASSIFIED, // FairEmail + FLAG_FILTERED, // FairEmail + FLAG_LOW_IMPORTANCE, // FairEmail + FLAG_HIGH_IMPORTANCE, // FairEmail "$MDNSent", // https://tools.ietf.org/html/rfc3503 "$SubmitPending", "$Submitted", @@ -1133,6 +1138,7 @@ public class MessageHelper { return flags.toString(); } + @NonNull String[] getKeywords() throws MessagingException { List keywords = Arrays.asList(imessage.getFlags().getUserFlags()); Collections.sort(keywords);