diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 784245ec3..103887658 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -72,6 +72,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, R.id.cab_properties -> showProperties() R.id.cab_rename -> renameFile() R.id.cab_edit -> editFile() + R.id.cab_hide -> toggleFileVisibility(true) + R.id.cab_unhide -> toggleFileVisibility(false) R.id.cab_share -> shareMedia() R.id.cab_copy_to -> copyMoveTo(true) R.id.cab_move_to -> copyMoveTo(false) @@ -90,9 +92,12 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean { - val selections = multiSelector.selectedPositions - menu.findItem(R.id.cab_rename).isVisible = selections.size <= 1 - menu.findItem(R.id.cab_edit).isVisible = selections.size == 1 && media[selections[0]].isImage() + val positions = multiSelector.selectedPositions + menu.findItem(R.id.cab_rename).isVisible = positions.size <= 1 + menu.findItem(R.id.cab_edit).isVisible = positions.size == 1 && media[positions[0]].isImage() + + checkHideBtnVisibility(menu, positions) + return true } @@ -102,6 +107,20 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, markedItems.clear() actMode = null } + + fun checkHideBtnVisibility(menu: Menu, positions: List) { + var hiddenCnt = 0 + var unhiddenCnt = 0 + positions.map { media[it] }.forEach { + if (it.name.startsWith('.')) + hiddenCnt++ + else + unhiddenCnt++ + } + + menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0 + menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0 + } } private fun showProperties() { @@ -129,6 +148,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, actMode?.finish() } + private fun toggleFileVisibility(hide: Boolean) { + + } + 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 0364126d2..4b47e6025 100644 --- a/app/src/main/res/menu/cab_media.xml +++ b/app/src/main/res/menu/cab_media.xml @@ -21,6 +21,16 @@ android:icon="@drawable/ic_rename" android:title="@string/rename" app:showAsAction="ifRoom"/> + +