Skip to content

Commit

Permalink
Merge pull request #1200 from michaelschattgen/feature/select-all
Browse files Browse the repository at this point in the history
Add ability to select all tokens
  • Loading branch information
alexbakker authored Sep 24, 2023
2 parents 92e9e04 + 1c86c5f commit e1f4696
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,10 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
_entryListView.setGroups(_vaultManager.getVault().getUsedGroups());
mode.finish();
});
} else if (itemId == R.id.action_select_all) {
_selectedEntries = _entryListView.selectAllEntries();
setFavoriteMenuItemVisiblity();
setIsMultipleSelected(_selectedEntries.size() > 1);
} else if (itemId == R.id.action_assign_icons) {
startAssignIconsActivity(CODE_ASSIGN_ICONS, _selectedEntries);
mode.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,23 @@ public void addSelectedEntry(VaultEntry entry) {
updateDraggableStatus();
}

public List<VaultEntry> selectAllEntries() {
_selectedEntries.clear();

for (VaultEntry entry: _shownEntries) {
for (EntryHolder holder: _holders) {
if (holder.getEntry() == entry) {
holder.setFocused(true);
}
}

_selectedEntries.add(entry);
updateDraggableStatus();
}

return new ArrayList<>(_selectedEntries);
}

public void deselectAllEntries() {
for (VaultEntry entry: _selectedEntries) {
for (EntryHolder holder : _holders) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ public void setCopyBehavior(CopyBehavior copyBehavior) {
_adapter.setCopyBehavior(copyBehavior);
}

public List<VaultEntry> selectAllEntries() {
return _adapter.selectAllEntries();
}

public void setActionModeState(boolean enabled, VaultEntry entry) {
_touchCallback.setSelectedEntry(entry);
_touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed());
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/menu/menu_action_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
android:title="@string/edit"
app:showAsAction="always" />

<item
android:id="@+id/action_select_all"
android:title="@string/select_all"
android:orderInCategory="95"
android:tint="?attr/iconColorPrimary"
app:showAsAction="never"/>

<item
android:id="@+id/action_assign_icons"
android:title="@string/assign_icons"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<string name="set_up_biometric">Set up biometric unlock</string>
<string name="copy">Copy</string>
<string name="edit">Edit</string>
<string name="select_all">Select all</string>
<string name="assign_icons">Assign icons</string>
<string name="favorite" comment="Verb">Favorite</string>
<string name="unfavorite" comment="Verb">Unfavorite</string>
Expand Down

0 comments on commit e1f4696

Please sign in to comment.