add the menu buttons for changing album cover

This commit is contained in:
tibbi 2017-06-06 20:00:45 +02:00
parent 9676a78c1d
commit e05ef4a9f2
2 changed files with 20 additions and 0 deletions

View file

@ -111,6 +111,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
R.id.cab_move_to -> copyMoveTo(false)
R.id.cab_select_all -> selectAll()
R.id.cab_delete -> askConfirmDelete()
R.id.cab_select_photo -> changeAlbumCover(false)
R.id.cab_use_default -> changeAlbumCover(true)
else -> return false
}
return true
@ -125,6 +127,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean {
menu.findItem(R.id.cab_rename).isVisible = selectedPositions.size <= 1
menu.findItem(R.id.cab_change_cover_image).isVisible = selectedPositions.size <= 1
checkHideBtnVisibility(menu)
checkPinBtnVisibility(menu)
@ -320,6 +323,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
}
}
private fun changeAlbumCover(useDefault: Boolean) {
listener?.refreshItems()
}
private fun getSelectedPaths(): HashSet<String> {
val paths = HashSet<String>(selectedPositions.size)
selectedPositions.forEach { paths.add(dirs[it].path) }

View file

@ -48,6 +48,19 @@
android:icon="@drawable/ic_select_all"
android:title="@string/select_all"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_change_cover_image"
android:title="@string/change_cover_image"
app:showAsAction="never">
<menu>
<item
android:id="@+id/cab_select_photo"
android:title="@string/select_photo"/>
<item
android:id="@+id/cab_use_default"
android:title="@string/use_default"/>
</menu>
</item>
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete"