diff --git a/app/src/main/java/eu/faircode/email/AdapterKeyword.java b/app/src/main/java/eu/faircode/email/AdapterKeyword.java index cdbf21907d..6e66ce3a6a 100644 --- a/app/src/main/java/eu/faircode/email/AdapterKeyword.java +++ b/app/src/main/java/eu/faircode/email/AdapterKeyword.java @@ -98,6 +98,7 @@ public class AdapterKeyword extends RecyclerView.Adapter all = new ArrayList<>(); List selected = new ArrayList<>(); List available = new ArrayList<>(); @@ -137,13 +138,17 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase { if (!list.contains(kw)) selected.remove(kw); + for (String kw : list) + if (!all.contains(kw)) + all.add(kw); + if (kws != null && kws.available != null) for (String kw : kws.available) if (!available.contains(kw)) available.add(kw); } - return new TupleKeyword.Persisted(selected, available); + return new TupleKeyword.Persisted(selected, all, available); } @Override diff --git a/app/src/main/java/eu/faircode/email/TupleKeyword.java b/app/src/main/java/eu/faircode/email/TupleKeyword.java index 2e2233025f..07d8793374 100644 --- a/app/src/main/java/eu/faircode/email/TupleKeyword.java +++ b/app/src/main/java/eu/faircode/email/TupleKeyword.java @@ -26,6 +26,7 @@ import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.preference.PreferenceManager; +import androidx.room.Ignore; import java.text.Collator; import java.util.ArrayList; @@ -39,6 +40,7 @@ import java.util.Objects; public class TupleKeyword { public String name; public boolean selected; + public boolean partial; public Integer color; @Override @@ -54,15 +56,16 @@ public class TupleKeyword { public static class Persisted { public String[] selected; + @Ignore + public String[] all_selected; public String[] available; public Persisted() { - selected = new String[0]; - available = new String[0]; } - public Persisted(List selected, List available) { + public Persisted(List selected, List all, List available) { this.selected = selected.toArray(new String[0]); + this.all_selected = all.toArray(new String[0]); this.available = available.toArray(new String[0]); } } @@ -76,9 +79,10 @@ public class TupleKeyword { List result = new ArrayList<>(); List all = new ArrayList<>(); - List selected = Arrays.asList(data.selected); + List some = Arrays.asList(data.selected); + List selected = Arrays.asList(data.all_selected == null ? data.selected : data.all_selected); - for (String keyword : data.selected) + for (String keyword : selected) if (!all.contains(keyword)) all.add(keyword); @@ -110,6 +114,7 @@ public class TupleKeyword { TupleKeyword k = new TupleKeyword(); k.name = keyword; k.selected = selected.contains(keyword); + k.partial = (k.selected && !some.contains(keyword)); String c1 = "kwcolor." + keyword; String c2 = "keyword." + keyword; // legacy