handle Properties and Un/hiding of locked folders

This commit is contained in:
tibbi 2019-07-02 21:15:17 +02:00
parent 6e01ea3386
commit 6625a3dbb7

View file

@ -159,10 +159,14 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
if (selectedKeys.size <= 1) { if (selectedKeys.size <= 1) {
val path = getFirstSelectedItemPath() ?: return val path = getFirstSelectedItemPath() ?: return
if (path != FAVORITES && path != RECYCLE_BIN) { if (path != FAVORITES && path != RECYCLE_BIN) {
PropertiesDialog(activity, path, config.shouldShowHidden) activity.handleLockedFolderOpening(path) {
PropertiesDialog(activity, path, config.shouldShowHidden)
}
} }
} else { } else {
PropertiesDialog(activity, getSelectedPaths().filter { it != FAVORITES && it != RECYCLE_BIN }.toMutableList(), config.shouldShowHidden) PropertiesDialog(activity, getSelectedPaths().filter {
it != FAVORITES && it != RECYCLE_BIN && !activity.config.isFolderProtected(it)
}.toMutableList(), config.shouldShowHidden)
} }
} }
@ -176,22 +180,24 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
return return
} }
RenameItemDialog(activity, dir.absolutePath) { activity.handleLockedFolderOpening(sourcePath) {
activity.runOnUiThread { RenameItemDialog(activity, dir.absolutePath) {
firstDir.apply { activity.runOnUiThread {
path = it firstDir.apply {
name = it.getFilenameFromPath() path = it
tmb = File(it, tmb.getFilenameFromPath()).absolutePath name = it.getFilenameFromPath()
} tmb = File(it, tmb.getFilenameFromPath()).absolutePath
updateDirs(dirs) }
ensureBackgroundThread { updateDirs(dirs)
activity.galleryDB.DirectoryDao().updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath) ensureBackgroundThread {
listener?.refreshItems() activity.galleryDB.DirectoryDao().updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath)
listener?.refreshItems()
}
} }
} }
} }
} else { } else {
val paths = getSelectedPaths().filter { !activity.isAStorageRootFolder(it) } as ArrayList<String> val paths = getSelectedPaths().filter { !activity.isAStorageRootFolder(it) && !activity.config.isFolderProtected(it) } as ArrayList<String>
RenameItemsDialog(activity, paths) { RenameItemsDialog(activity, paths) {
listener?.refreshItems() listener?.refreshItems()
} }
@ -208,25 +214,31 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
} }
selectedPaths.filter { it != FAVORITES && it != RECYCLE_BIN }.forEach { selectedPaths.filter { it != FAVORITES && it != RECYCLE_BIN && (selectedPaths.size == 1 || !activity.config.isFolderProtected(it)) }.forEach {
val path = it val path = it
if (hide) { if (hide) {
if (config.wasHideFolderTooltipShown) { if (config.wasHideFolderTooltipShown) {
hideFolder(path) activity.handleLockedFolderOpening(path) {
hideFolder(path)
}
} else { } else {
config.wasHideFolderTooltipShown = true config.wasHideFolderTooltipShown = true
ConfirmationDialog(activity, activity.getString(R.string.hide_folder_description)) { ConfirmationDialog(activity, activity.getString(R.string.hide_folder_description)) {
hideFolder(path) activity.handleLockedFolderOpening(path) {
hideFolder(path)
}
} }
} }
} else { } else {
activity.removeNoMedia(path) { activity.handleLockedFolderOpening(path) {
if (activity.config.shouldShowHidden) { activity.removeNoMedia(path) {
updateFolderNames() if (activity.config.shouldShowHidden) {
} else { updateFolderNames()
activity.runOnUiThread { } else {
listener?.refreshItems() activity.runOnUiThread {
finishActMode() listener?.refreshItems()
finishActMode()
}
} }
} }
} }