hide folders whose parent contains .nomedia when appropriate

This commit is contained in:
tibbi 2017-05-21 20:16:45 +02:00
parent b83341c299
commit f5eb3c931e
1 changed files with 18 additions and 1 deletions

View File

@ -74,12 +74,29 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
return if (isThisOrParentExcluded(path, excludedPaths)) return if (isThisOrParentExcluded(path, excludedPaths))
false false
else if (!config.shouldShowHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) { else if (!config.shouldShowHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
!(file.containsNoMedia() || path.contains("/.")) var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.")
if (!containsNoMediaOrDot) {
containsNoMediaOrDot = checkParentHasNoMedia(file.parentFile)
}
!containsNoMediaOrDot
} else { } else {
true true
} }
} }
private fun checkParentHasNoMedia(file: File): Boolean {
var curFile = file
while (true) {
if (curFile.containsNoMedia()) {
return true
}
curFile = curFile.parentFile
if (curFile.absolutePath == "/")
break
}
return false
}
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) }
private fun movePinnedToFront(dirs: ArrayList<Directory>): ArrayList<Directory> { private fun movePinnedToFront(dirs: ArrayList<Directory>): ArrayList<Directory> {