mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-19 21:39:18 +00:00
Add ability to multiselect groups
This commit is contained in:
parent
920df1d9be
commit
78ee38ba7d
5 changed files with 24 additions and 15 deletions
|
@ -86,6 +86,10 @@ public class Preferences {
|
||||||
return _prefs.getBoolean("pref_tap_to_reveal", false);
|
return _prefs.getBoolean("pref_tap_to_reveal", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGroupMultiselectEnabled() {
|
||||||
|
return _prefs.getBoolean("pref_groups_multiselect", false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEntryHighlightEnabled() {
|
public boolean isEntryHighlightEnabled() {
|
||||||
return _prefs.getBoolean("pref_highlight_entry", false);
|
return _prefs.getBoolean("pref_highlight_entry", false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,6 +274,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
private void initializeGroups() {
|
private void initializeGroups() {
|
||||||
_groupChip.removeAllViews();
|
_groupChip.removeAllViews();
|
||||||
|
_groupChip.setSingleSelection(!_prefs.isGroupMultiselectEnabled());
|
||||||
|
|
||||||
for (VaultGroup group : _groups) {
|
for (VaultGroup group : _groups) {
|
||||||
addChipTo(_groupChip, new VaultGroupModel(group));
|
addChipTo(_groupChip, new VaultGroupModel(group));
|
||||||
|
@ -313,29 +314,24 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
}
|
}
|
||||||
|
|
||||||
chip.setOnCheckedChangeListener((group1, isChecked) -> {
|
chip.setOnCheckedChangeListener((group1, isChecked) -> {
|
||||||
Set<UUID> groupFilter = new HashSet<>();
|
|
||||||
if (_actionMode != null) {
|
if (_actionMode != null) {
|
||||||
_actionMode.finish();
|
_actionMode.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
setSaveChipVisibility(true);
|
setSaveChipVisibility(true);
|
||||||
|
|
||||||
if (!isChecked) {
|
// Reset group filter if last checked group gets unchecked
|
||||||
group1.setChecked(false);
|
if (!isChecked && _groupFilter.size() == 1) {
|
||||||
|
Set<UUID> groupFilter = new HashSet<>();
|
||||||
|
|
||||||
|
chipGroup.clearCheck();
|
||||||
_groupFilter = groupFilter;
|
_groupFilter = groupFilter;
|
||||||
_entryListView.setGroupFilter(groupFilter);
|
_entryListView.setGroupFilter(groupFilter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object chipTag = group1.getTag();
|
_groupFilter = getGroupFilter(chipGroup);
|
||||||
if (chipTag == GroupPlaceholderType.NO_GROUP) {
|
_entryListView.setGroupFilter(_groupFilter);
|
||||||
groupFilter.add(null);
|
|
||||||
} else {
|
|
||||||
groupFilter = getGroupFilter(chipGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
_groupFilter = groupFilter;
|
|
||||||
_entryListView.setGroupFilter(groupFilter);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
chipGroup.addView(chip);
|
chipGroup.addView(chip);
|
||||||
|
@ -368,8 +364,10 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
private static Set<UUID> getGroupFilter(ChipGroup chipGroup) {
|
private static Set<UUID> getGroupFilter(ChipGroup chipGroup) {
|
||||||
return chipGroup.getCheckedChipIds().stream()
|
return chipGroup.getCheckedChipIds().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.map(i -> {
|
.map(i -> {
|
||||||
Chip chip = chipGroup.findViewById(i);
|
Chip chip = chipGroup.findViewById(i);
|
||||||
|
|
||||||
if (chip.getTag() instanceof VaultGroupModel) {
|
if (chip.getTag() instanceof VaultGroupModel) {
|
||||||
VaultGroupModel group = (VaultGroupModel) chip.getTag();
|
VaultGroupModel group = (VaultGroupModel) chip.getTag();
|
||||||
return group.getUUID();
|
return group.getUUID();
|
||||||
|
@ -377,7 +375,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@
|
||||||
android:id="@+id/groupChipGroup"
|
android:id="@+id/groupChipGroup"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:selectionRequired="true"
|
app:selectionRequired="true"/>
|
||||||
app:singleSelection="true"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</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_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_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_title">Minimize on copy</string>
|
||||||
<string name="pref_minimize_on_copy_summary">Minimize the app after copying a token</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>
|
<string name="pref_copy_behavior_title">Copy tokens to the clipboard</string>
|
||||||
|
|
|
@ -26,6 +26,13 @@
|
||||||
android:title="@string/pref_copy_behavior_title"
|
android:title="@string/pref_copy_behavior_title"
|
||||||
app:iconSpaceReserved="false"/>
|
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
|
<androidx.preference.SwitchPreferenceCompat
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_highlight_entry"
|
android:key="pref_highlight_entry"
|
||||||
|
|
Loading…
Add table
Reference in a new issue