mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 22:37:59 +01:00
display hide/unhide menu buttons when appropriate
This commit is contained in:
parent
53ed959e63
commit
4394e6074e
1 changed files with 20 additions and 3 deletions
|
@ -13,6 +13,7 @@ import com.bumptech.glide.signature.StringSignature
|
||||||
import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder
|
import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder
|
||||||
import com.simplemobiletools.filepicker.extensions.scanPaths
|
import com.simplemobiletools.filepicker.extensions.scanPaths
|
||||||
import com.simplemobiletools.filepicker.extensions.toast
|
import com.simplemobiletools.filepicker.extensions.toast
|
||||||
|
import com.simplemobiletools.gallery.Config
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog
|
||||||
|
@ -27,6 +28,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
|
|
||||||
val multiSelector = MultiSelector()
|
val multiSelector = MultiSelector()
|
||||||
val views = ArrayList<View>()
|
val views = ArrayList<View>()
|
||||||
|
val config = Config.newInstance(activity)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var actMode: ActionMode? = null
|
var actMode: ActionMode? = null
|
||||||
|
@ -57,9 +59,23 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu?): Boolean {
|
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean {
|
||||||
val menuItem = menu?.findItem(R.id.cab_edit)
|
val menuItem = menu.findItem(R.id.cab_edit)
|
||||||
menuItem?.isVisible = multiSelector.selectedPositions.size <= 1
|
menuItem.isVisible = multiSelector.selectedPositions.size <= 1
|
||||||
|
|
||||||
|
var hiddenCnt = 0
|
||||||
|
var unhiddenCnt = 0
|
||||||
|
val positions = multiSelector.selectedPositions
|
||||||
|
for (i in positions) {
|
||||||
|
val path = dirs[i].path
|
||||||
|
if (config.getIsFolderHidden(path))
|
||||||
|
hiddenCnt++
|
||||||
|
else
|
||||||
|
unhiddenCnt++
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
||||||
|
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +139,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
multiSelector.setSelected(this, true)
|
multiSelector.setSelected(this, true)
|
||||||
actMode?.title = multiSelector.selectedPositions.size.toString()
|
actMode?.title = multiSelector.selectedPositions.size.toString()
|
||||||
toggleItemSelection(itemView, true)
|
toggleItemSelection(itemView, true)
|
||||||
|
actMode?.invalidate()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue