Added partial selected keywords

master
M66B 1 week ago
parent 49b8b90aac
commit 6a81d43557

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

@ -121,6 +121,7 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
protected TupleKeyword.Persisted onExecute(Context context, Bundle args) { protected TupleKeyword.Persisted onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids"); long[] ids = args.getLongArray("ids");
List<String> all = new ArrayList<>();
List<String> selected = new ArrayList<>(); List<String> selected = new ArrayList<>();
List<String> available = new ArrayList<>(); List<String> available = new ArrayList<>();
@ -137,13 +138,17 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
if (!list.contains(kw)) if (!list.contains(kw))
selected.remove(kw); selected.remove(kw);
for (String kw : list)
if (!all.contains(kw))
all.add(kw);
if (kws != null && kws.available != null) if (kws != null && kws.available != null)
for (String kw : kws.available) for (String kw : kws.available)
if (!available.contains(kw)) if (!available.contains(kw))
available.add(kw); available.add(kw);
} }
return new TupleKeyword.Persisted(selected, available); return new TupleKeyword.Persisted(selected, all, available);
} }
@Override @Override

@ -26,6 +26,7 @@ import android.text.TextUtils;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.room.Ignore;
import java.text.Collator; import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;
@ -39,6 +40,7 @@ import java.util.Objects;
public class TupleKeyword { public class TupleKeyword {
public String name; public String name;
public boolean selected; public boolean selected;
public boolean partial;
public Integer color; public Integer color;
@Override @Override
@ -54,15 +56,16 @@ public class TupleKeyword {
public static class Persisted { public static class Persisted {
public String[] selected; public String[] selected;
@Ignore
public String[] all_selected;
public String[] available; public String[] available;
public Persisted() { 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.selected = selected.toArray(new String[0]);
this.all_selected = all.toArray(new String[0]);
this.available = available.toArray(new String[0]); this.available = available.toArray(new String[0]);
} }
} }
@ -76,9 +79,10 @@ public class TupleKeyword {
List<TupleKeyword> result = new ArrayList<>(); List<TupleKeyword> result = new ArrayList<>();
List<String> all = 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)) if (!all.contains(keyword))
all.add(keyword); all.add(keyword);
@ -110,6 +114,7 @@ public class TupleKeyword {
TupleKeyword k = new TupleKeyword(); TupleKeyword k = new TupleKeyword();
k.name = keyword; k.name = keyword;
k.selected = selected.contains(keyword); k.selected = selected.contains(keyword);
k.partial = (k.selected && !some.contains(keyword));
String c1 = "kwcolor." + keyword; String c1 = "kwcolor." + keyword;
String c2 = "keyword." + keyword; // legacy String c2 = "keyword." + keyword; // legacy

Loading…
Cancel
Save