diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 749951ef7..416bf3460 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -65,7 +65,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { - editDir() + renameDir() true } R.id.cab_pin -> { @@ -109,8 +109,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList, showProperties() true } + R.id.cab_rename -> { + renameFile() + true + } R.id.cab_share -> { shareMedia() return true @@ -85,7 +90,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, return true } - override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu) = true + override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean { + menu.findItem(R.id.cab_rename).isVisible = multiSelector.selectedPositions.size <= 1 + + return true + } override fun onDestroyActionMode(actionMode: ActionMode?) { super.onDestroyActionMode(actionMode) @@ -105,6 +114,15 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } } + private fun renameFile() { + RenameFileDialog(activity, File(media[multiSelector.selectedPositions[0]].path)) { + listener?.refreshItems() + activity.runOnUiThread { + actMode?.finish() + } + } + } + private fun shareMedia() { val selections = multiSelector.selectedPositions if (selections.size <= 1) { diff --git a/app/src/main/res/menu/cab_media.xml b/app/src/main/res/menu/cab_media.xml index fe37abbb3..8d51dbad8 100644 --- a/app/src/main/res/menu/cab_media.xml +++ b/app/src/main/res/menu/cab_media.xml @@ -16,6 +16,11 @@ android:icon="@mipmap/copy" android:title="@string/copy_move" app:showAsAction="ifRoom"/> +