add a Select all button to the directories screen too

This commit is contained in:
tibbi 2016-12-25 16:32:19 +01:00
parent 08879ee1e1
commit 674c82c15d
2 changed files with 17 additions and 0 deletions

View file

@ -67,6 +67,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
R.id.cab_hide -> toggleFoldersVisibility(true) R.id.cab_hide -> toggleFoldersVisibility(true)
R.id.cab_unhide -> toggleFoldersVisibility(false) R.id.cab_unhide -> toggleFoldersVisibility(false)
R.id.cab_copy_move -> displayCopyDialog() R.id.cab_copy_move -> displayCopyDialog()
R.id.cab_select_all -> selectAll()
R.id.cab_delete -> askConfirmDelete() R.id.cab_delete -> askConfirmDelete()
else -> return false else -> return false
} }
@ -203,6 +204,17 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
}) })
} }
fun selectAll() {
val cnt = dirs.size
for (i in 0..cnt - 1) {
markedItems.add(i)
multiSelector.setSelected(i, 0, true)
notifyItemChanged(i)
}
actMode?.title = cnt.toString()
actMode?.invalidate()
}
private fun askConfirmDelete() { private fun askConfirmDelete() {
ConfirmationDialog(activity) { ConfirmationDialog(activity) {
actMode?.finish() actMode?.finish()

View file

@ -36,6 +36,11 @@
android:icon="@mipmap/copy" android:icon="@mipmap/copy"
android:title="@string/copy_move" android:title="@string/copy_move"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_select_all"
android:icon="@mipmap/select_all"
android:title="@string/select_all"
app:showAsAction="ifRoom"/>
<item <item
android:id="@+id/cab_delete" android:id="@+id/cab_delete"
android:icon="@mipmap/delete" android:icon="@mipmap/delete"