hide folders that should be hidden

This commit is contained in:
tibbi 2017-05-21 19:16:29 +02:00
parent c03e6ec64f
commit 9942f94fc3

View file

@ -28,7 +28,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
val media = context.getFilesFrom("", isPickImage, isPickVideo) val media = context.getFilesFrom("", isPickImage, isPickVideo)
val excludedPaths = config.excludedFolders val excludedPaths = config.excludedFolders
val directories = groupDirectories(media) val directories = groupDirectories(media)
val dirs = ArrayList(directories.values.filter { File(it.path).exists() }).filter { !shouldFolderBeVisible(it.path, excludedPaths) } as ArrayList<Directory> val dirs = ArrayList(directories.values.filter { File(it.path).exists() }).filter { shouldFolderBeVisible(it.path, excludedPaths) } as ArrayList<Directory>
Directory.sorting = config.directorySorting Directory.sorting = config.directorySorting
dirs.sort() dirs.sort()
return movePinnedToFront(dirs) return movePinnedToFront(dirs)
@ -71,8 +71,13 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet<String>): Boolean { private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet<String>): Boolean {
val file = File(path) val file = File(path)
return isThisOrParentExcluded(path, excludedPaths) || (!config.shouldShowHidden && file.isDirectory && return if (isThisOrParentExcluded(path, excludedPaths))
file.canonicalFile == file.absoluteFile && file.containsNoMedia()) false
else if (!config.shouldShowHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
!(file.containsNoMedia() || path.contains("/."))
} else {
true
}
} }
private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet<String>) = excludedPaths.any { path.startsWith(it) } private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet<String>) = excludedPaths.any { path.startsWith(it) }