use the local config variable at folders

This commit is contained in:
tibbi 2020-11-08 21:39:39 +01:00
parent 5363cc1569
commit 425d1f77b5

View file

@ -178,7 +178,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
} else { } else {
PropertiesDialog(activity, getSelectedPaths().filter { PropertiesDialog(activity, getSelectedPaths().filter {
it != FAVORITES && it != RECYCLE_BIN && !activity.config.isFolderProtected(it) it != FAVORITES && it != RECYCLE_BIN && !config.isFolderProtected(it)
}.toMutableList(), config.shouldShowHidden) }.toMutableList(), config.shouldShowHidden)
} }
} }
@ -216,7 +216,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
} }
} else { } else {
val paths = getSelectedPaths().filter { !activity.isAStorageRootFolder(it) && !activity.config.isFolderProtected(it) } as ArrayList<String> val paths = getSelectedPaths().filter { !activity.isAStorageRootFolder(it) && !config.isFolderProtected(it) } as ArrayList<String>
RenameItemsDialog(activity, paths) { RenameItemsDialog(activity, paths) {
listener?.refreshItems() listener?.refreshItems()
} }
@ -243,13 +243,13 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
} }
} else { } else {
selectedPaths.filter { it != FAVORITES && it != RECYCLE_BIN && (selectedPaths.size == 1 || !activity.config.isFolderProtected(it)) }.forEach { selectedPaths.filter { it != FAVORITES && it != RECYCLE_BIN && (selectedPaths.size == 1 || !config.isFolderProtected(it)) }.forEach {
val path = it val path = it
activity.handleLockedFolderOpening(path) { success -> activity.handleLockedFolderOpening(path) { success ->
if (success) { if (success) {
if (path.containsNoMedia()) { if (path.containsNoMedia()) {
activity.removeNoMedia(path) { activity.removeNoMedia(path) {
if (activity.config.shouldShowHidden) { if (config.shouldShowHidden) {
updateFolderNames() updateFolderNames()
} else { } else {
activity.runOnUiThread { activity.runOnUiThread {
@ -308,7 +308,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
private fun updateFolderNames() { private fun updateFolderNames() {
val includedFolders = activity.config.includedFolders val includedFolders = config.includedFolders
val hidden = activity.getString(R.string.hidden) val hidden = activity.getString(R.string.hidden)
dirs.forEach { dirs.forEach {
it.name = activity.checkAppendingHidden(it.path, hidden, includedFolders, ArrayList()) it.name = activity.checkAppendingHidden(it.path, hidden, includedFolders, ArrayList())
@ -321,11 +321,11 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
private fun hideFolder(path: String) { private fun hideFolder(path: String) {
activity.addNoMedia(path) { activity.addNoMedia(path) {
if (activity.config.shouldShowHidden) { if (config.shouldShowHidden) {
updateFolderNames() updateFolderNames()
} else { } else {
val affectedPositions = ArrayList<Int>() val affectedPositions = ArrayList<Int>()
val includedFolders = activity.config.includedFolders val includedFolders = config.includedFolders
val newDirs = dirs.filterIndexed { index, directory -> val newDirs = dirs.filterIndexed { index, directory ->
val removeDir = directory.path.doesThisOrParentHaveNoMedia() && !includedFolders.contains(directory.path) val removeDir = directory.path.doesThisOrParentHaveNoMedia() && !includedFolders.contains(directory.path)
if (removeDir) { if (removeDir) {
@ -366,7 +366,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
finishActMode() finishActMode()
} }
} else if (paths.size > 1) { } else if (paths.size > 1) {
activity.config.addExcludedFolders(paths) config.addExcludedFolders(paths)
listener?.refreshItems() listener?.refreshItems()
finishActMode() finishActMode()
} }
@ -434,7 +434,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
private fun copyMoveTo(isCopyOperation: Boolean) { private fun copyMoveTo(isCopyOperation: Boolean) {
val paths = ArrayList<String>() val paths = ArrayList<String>()
val showHidden = activity.config.shouldShowHidden val showHidden = config.shouldShowHidden
getSelectedPaths().forEach { getSelectedPaths().forEach {
val filter = config.filterMedia val filter = config.filterMedia
File(it).listFiles()?.filter { File(it).listFiles()?.filter {
@ -576,7 +576,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
} }
} else { } else {
foldersToDelete = foldersToDelete.filter { !activity.config.isFolderProtected(it.absolutePath) }.toMutableList() as ArrayList<File> foldersToDelete = foldersToDelete.filter { !config.isFolderProtected(it.absolutePath) }.toMutableList() as ArrayList<File>
listener?.deleteFolders(foldersToDelete) listener?.deleteFolders(foldersToDelete)
} }
} }
@ -620,7 +620,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
private fun getAlbumCoversWithout(path: String) = config.parseAlbumCovers().filterNot { it.path == path } as ArrayList private fun getAlbumCoversWithout(path: String) = config.parseAlbumCovers().filterNot { it.path == path } as ArrayList
private fun storeCovers(albumCovers: ArrayList<AlbumCover>) { private fun storeCovers(albumCovers: ArrayList<AlbumCover>) {
activity.config.albumCovers = Gson().toJson(albumCovers) config.albumCovers = Gson().toJson(albumCovers)
finishActMode() finishActMode()
listener?.refreshItems() listener?.refreshItems()
} }