From 1d1f087b7ac371fdac684ce629ea752937c16907 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 8 Nov 2024 11:34:02 +0100 Subject: [PATCH] Keyword improvements --- .../faircode/email/FragmentDialogKeywordManage.java | 4 +++- .../java/eu/faircode/email/FragmentMessages.java | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogKeywordManage.java b/app/src/main/java/eu/faircode/email/FragmentDialogKeywordManage.java index bb71ec1875..ed1fa9d59e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogKeywordManage.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogKeywordManage.java @@ -86,9 +86,11 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase { String global = prefs.getString("global_keywords", null); if (global != null) { List available = new ArrayList<>(); - available.addAll(Arrays.asList(global.split(" "))); if (data.available != null) available.addAll(Arrays.asList(data.available)); + for (String kw : global.split(" ")) + if (!available.contains(kw)) + available.add(kw); data.available = available.toArray(new String[0]); } diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 0517857f46..61620db9af 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -5229,7 +5229,17 @@ public class FragmentMessages extends FragmentBase available.add(kw); } - Collections.sort(available); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + String global = prefs.getString("global_keywords", null); + if (global != null) + for (String kw : global.split(" ")) + if (!available.contains(kw)) + available.add(kw); + + final Collator collator = Collator.getInstance(Locale.getDefault()); + collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc + + Collections.sort(available, collator); return new Pair<>(selected, available); }