From 9942f94fc395008cf62068a52851d01be65ab307 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 21 May 2017 19:16:29 +0200 Subject: [PATCH] hide folders that should be hidden --- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 3b4ed44d1..67cde8e04 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -28,7 +28,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val media = context.getFilesFrom("", isPickImage, isPickVideo) val excludedPaths = config.excludedFolders val directories = groupDirectories(media) - val dirs = ArrayList(directories.values.filter { File(it.path).exists() }).filter { !shouldFolderBeVisible(it.path, excludedPaths) } as ArrayList + val dirs = ArrayList(directories.values.filter { File(it.path).exists() }).filter { shouldFolderBeVisible(it.path, excludedPaths) } as ArrayList Directory.sorting = config.directorySorting dirs.sort() return movePinnedToFront(dirs) @@ -71,8 +71,13 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet): Boolean { val file = File(path) - return isThisOrParentExcluded(path, excludedPaths) || (!config.shouldShowHidden && file.isDirectory && - file.canonicalFile == file.absoluteFile && file.containsNoMedia()) + return if (isThisOrParentExcluded(path, excludedPaths)) + false + else if (!config.shouldShowHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { + !(file.containsNoMedia() || path.contains("/.")) + } else { + true + } } private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet) = excludedPaths.any { path.startsWith(it) }