mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-26 10:53:43 +02:00
Added support for Outlook categories (read only)
This commit is contained in:
@@ -96,6 +96,7 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
|
||||
}
|
||||
|
||||
private void bindTo(TupleKeyword keyword) {
|
||||
cbKeyword.setEnabled(!keyword.name.startsWith(MessageHelper.CATEGORY_PREFIX));
|
||||
cbKeyword.setText(getTitle(keyword.name));
|
||||
cbKeyword.setChecked(keyword.selected);
|
||||
if (keyword.partial)
|
||||
@@ -168,7 +169,7 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
|
||||
if (itemId == R.id.ibEdit) {
|
||||
String key = "kwtitle." + keyword.name;
|
||||
etKeyword.setText(prefs.getString(key, null));
|
||||
etKeyword.setHint(keyword.name);
|
||||
etKeyword.setHint(keyword.name.replace(MessageHelper.CATEGORY_PREFIX, ""));
|
||||
grpNotEdit.setVisibility(View.GONE);
|
||||
grpEdit.setVisibility(View.VISIBLE);
|
||||
etKeyword.post(new Runnable() {
|
||||
|
||||
@@ -4619,7 +4619,7 @@ class Core {
|
||||
boolean flagged = helper.getFlagged();
|
||||
boolean deleted = helper.getDeleted();
|
||||
String flags = helper.getFlags();
|
||||
String[] keywords = helper.getKeywords();
|
||||
String[] keywords = helper.getKeywords(account.isOutlook());
|
||||
String[] labels = helper.getLabels();
|
||||
boolean update = false;
|
||||
boolean process = false;
|
||||
|
||||
@@ -253,6 +253,7 @@ public class MessageHelper {
|
||||
static final String FLAG_LOW_IMPORTANCE = "$LowImportance";
|
||||
static final String FLAG_HIGH_IMPORTANCE = "$HighImportance";
|
||||
static final String FLAG_PHISHING = "$Phishing"; // Gmail
|
||||
static final String CATEGORY_PREFIX = "$category:";
|
||||
|
||||
// https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml
|
||||
// Not black listed: Gmail $Phishing
|
||||
@@ -1544,10 +1545,19 @@ public class MessageHelper {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
String[] getKeywords() throws MessagingException {
|
||||
String[] getKeywords(boolean outlook) throws MessagingException {
|
||||
List<String> keywords = new ArrayList<>(Arrays.asList(imessage.getFlags().getUserFlags()));
|
||||
|
||||
if (outlook) {
|
||||
String categories = imessage.getHeader("Keywords", null);
|
||||
if (!TextUtils.isEmpty(categories))
|
||||
for (String category : categories.split(","))
|
||||
keywords.add(CATEGORY_PREFIX + category);
|
||||
}
|
||||
|
||||
while (keywords.size() > MAX_KEYWORDS)
|
||||
keywords.remove(keywords.size() - 1);
|
||||
|
||||
Collections.sort(keywords);
|
||||
return keywords.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@@ -168,6 +168,9 @@ public class TupleKeyword {
|
||||
}
|
||||
|
||||
static String getDefaultKeywordAlias(Context context, String keyword) {
|
||||
if (keyword.startsWith(MessageHelper.CATEGORY_PREFIX))
|
||||
return keyword.substring(MessageHelper.CATEGORY_PREFIX.length());
|
||||
|
||||
switch (keyword) {
|
||||
case "$label1": // Important
|
||||
return context.getString(R.string.title_keyword_label1);
|
||||
|
||||
Reference in New Issue
Block a user