1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-21 23:32:51 +00:00

Added partial selected keywords

This commit is contained in:
M66B 2024-11-08 14:05:55 +01:00
parent 49b8b90aac
commit 6a81d43557
3 changed files with 18 additions and 6 deletions

View file

@ -98,6 +98,7 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
private void bindTo(TupleKeyword keyword) {
cbKeyword.setText(getTitle(keyword.name));
cbKeyword.setChecked(keyword.selected);
cbKeyword.setAlpha(keyword.partial ? Helper.LOW_LIGHT : 1.0f);
btnColor.setColor(keyword.color, true);
grpNotEdit.setVisibility(View.VISIBLE);
grpEdit.setVisibility(View.GONE);
@ -111,6 +112,7 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
TupleKeyword keyword = all.get(pos);
keyword.selected = isChecked;
buttonView.setAlpha(1.0f);
Bundle args = new Bundle();
args.putLongArray("ids", ids);

View file

@ -121,6 +121,7 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
protected TupleKeyword.Persisted onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
List<String> all = new ArrayList<>();
List<String> selected = new ArrayList<>();
List<String> 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

View file

@ -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<String> selected, List<String> available) {
public Persisted(List<String> selected, List<String> all, List<String> 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<TupleKeyword> result = new ArrayList<>();
List<String> all = new ArrayList<>();
List<String> selected = Arrays.asList(data.selected);
List<String> some = Arrays.asList(data.selected);
List<String> 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