diff --git a/app/src/main/java/com/beemdevelopment/aegis/Preferences.java b/app/src/main/java/com/beemdevelopment/aegis/Preferences.java index 95f3ed4c47..6e86f4f75d 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/Preferences.java +++ b/app/src/main/java/com/beemdevelopment/aegis/Preferences.java @@ -86,6 +86,10 @@ public boolean isTapToRevealEnabled() { 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); } diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java b/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java index 1dc5cbd531..a66e62a1ff 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java @@ -282,6 +282,8 @@ private void initializeGroups() { GroupPlaceholderType placeholderType = GroupPlaceholderType.NO_GROUP; addChipTo(_groupChip, new VaultGroupModel(this, placeholderType)); addSaveChip(_groupChip); + + _groupChip.setSingleSelection(!_prefs.isGroupMultiselectEnabled()); } private Set cleanGroupFilter(Set groupFilter) { @@ -313,29 +315,24 @@ private void addChipTo(ChipGroup chipGroup, VaultGroupModel group) { } chip.setOnCheckedChangeListener((group1, isChecked) -> { - Set 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 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); @@ -352,6 +349,7 @@ private void addSaveChip(ChipGroup chipGroup) { chip.setTextColor(MaterialColors.getColor(chip.getRootView(), com.google.android.material.R.attr.colorSecondary)); chip.setClickable(true); chip.setCheckedIconVisible(false); + chip.setTag("save"); chip.setOnClickListener(v -> { onSaveGroupFilter(_groupFilter); setSaveChipVisibility(false); @@ -368,8 +366,13 @@ private void setSaveChipVisibility(boolean visible) { private static Set getGroupFilter(ChipGroup chipGroup) { return chipGroup.getCheckedChipIds().stream() + .filter(Objects::nonNull) .map(i -> { Chip chip = chipGroup.findViewById(i); + if (chip.getTag() == "save") { + return null; + } + if (chip.getTag() instanceof VaultGroupModel) { VaultGroupModel group = (VaultGroupModel) chip.getTag(); return group.getUUID(); @@ -377,7 +380,6 @@ private static Set getGroupFilter(ChipGroup chipGroup) { return null; }) - .filter(Objects::nonNull) .collect(Collectors.toSet()); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 7a288e1e04..b2ca2d0061 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -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"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2725c77f2a..b2ec52ff61 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -373,6 +373,8 @@ Highlight tokens when tapped Make tokens easier to distinguish from each other by temporarily highlighting them when tapped + Multiselect groups + Allow the selection of multiple groups at the same time Minimize on copy Minimize the app after copying a token Copy tokens to the clipboard diff --git a/app/src/main/res/xml/preferences_behavior.xml b/app/src/main/res/xml/preferences_behavior.xml index ac2fa0d230..46f636f4c1 100644 --- a/app/src/main/res/xml/preferences_behavior.xml +++ b/app/src/main/res/xml/preferences_behavior.xml @@ -26,6 +26,13 @@ android:title="@string/pref_copy_behavior_title" app:iconSpaceReserved="false"/> + +