Add ability to multiselect groups

pull/1559/head
Michael Schättgen 3 months ago
parent 920df1d9be
commit 78ee38ba7d

@ -86,6 +86,10 @@ public class Preferences {
return _prefs.getBoolean("pref_tap_to_reveal", false);
}
public boolean isGroupMultiselectEnabled() {
return _prefs.getBoolean("pref_groups_multiselect", false);
}
public boolean isEntryHighlightEnabled() {
return _prefs.getBoolean("pref_highlight_entry", false);
}

@ -274,6 +274,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private void initializeGroups() {
_groupChip.removeAllViews();
_groupChip.setSingleSelection(!_prefs.isGroupMultiselectEnabled());
for (VaultGroup group : _groups) {
addChipTo(_groupChip, new VaultGroupModel(group));
@ -313,29 +314,24 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
}
chip.setOnCheckedChangeListener((group1, isChecked) -> {
Set<UUID> groupFilter = new HashSet<>();
if (_actionMode != null) {
_actionMode.finish();
}
setSaveChipVisibility(true);
if (!isChecked) {
group1.setChecked(false);
// Reset group filter if last checked group gets unchecked
if (!isChecked && _groupFilter.size() == 1) {
Set<UUID> groupFilter = new HashSet<>();
chipGroup.clearCheck();
_groupFilter = groupFilter;
_entryListView.setGroupFilter(groupFilter);
return;
}
Object chipTag = group1.getTag();
if (chipTag == GroupPlaceholderType.NO_GROUP) {
groupFilter.add(null);
} else {
groupFilter = getGroupFilter(chipGroup);
}
_groupFilter = groupFilter;
_entryListView.setGroupFilter(groupFilter);
_groupFilter = getGroupFilter(chipGroup);
_entryListView.setGroupFilter(_groupFilter);
});
chipGroup.addView(chip);
@ -368,8 +364,10 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private static Set<UUID> getGroupFilter(ChipGroup chipGroup) {
return chipGroup.getCheckedChipIds().stream()
.filter(Objects::nonNull)
.map(i -> {
Chip chip = chipGroup.findViewById(i);
if (chip.getTag() instanceof VaultGroupModel) {
VaultGroupModel group = (VaultGroupModel) chip.getTag();
return group.getUUID();
@ -377,7 +375,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
return null;
})
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}

@ -39,8 +39,7 @@
android:id="@+id/groupChipGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:selectionRequired="true"
app:singleSelection="true"/>
app:selectionRequired="true"/>
</LinearLayout>
</HorizontalScrollView>
</com.google.android.material.appbar.AppBarLayout>

@ -373,6 +373,8 @@
<string name="pref_highlight_entry_title">Highlight tokens when tapped</string>
<string name="pref_highlight_entry_summary">Make tokens easier to distinguish from each other by temporarily highlighting them when tapped</string>
<string name="pref_groups_multiselect_title">Multiselect groups</string>
<string name="pref_groups_multiselect_summary">Allow the selection of multiple groups at the same time</string>
<string name="pref_minimize_on_copy_title">Minimize on copy</string>
<string name="pref_minimize_on_copy_summary">Minimize the app after copying a token</string>
<string name="pref_copy_behavior_title">Copy tokens to the clipboard</string>

@ -26,6 +26,13 @@
android:title="@string/pref_copy_behavior_title"
app:iconSpaceReserved="false"/>
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_groups_multiselect"
android:title="@string/pref_groups_multiselect_title"
android:summary="@string/pref_groups_multiselect_summary"
app:iconSpaceReserved="false"/>
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_highlight_entry"

Loading…
Cancel
Save