properly make the Included folders check recursive
This commit is contained in:
parent
1a163ce56a
commit
d2a6d2cb88
|
@ -178,7 +178,7 @@ fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders:
|
|||
}
|
||||
}
|
||||
|
||||
return if (File(path).doesThisOrParentHaveNoMedia() && !includedFolders.contains(path)) {
|
||||
return if (File(path).doesThisOrParentHaveNoMedia() && !path.isThisOrParentIncluded(includedFolders)) {
|
||||
"$dirName $hidden"
|
||||
} else {
|
||||
dirName
|
||||
|
|
|
@ -4,3 +4,7 @@ import com.bumptech.glide.signature.ObjectKey
|
|||
import java.io.File
|
||||
|
||||
fun String.getFileSignature() = ObjectKey(File(this).lastModified().toString())
|
||||
|
||||
fun String.isThisOrParentIncluded(includedPaths: MutableSet<String>) = includedPaths.any { startsWith(it, true) }
|
||||
|
||||
fun String.isThisOrParentExcluded(excludedPaths: MutableSet<String>) = excludedPaths.any { startsWith(it, true) }
|
||||
|
|
|
@ -7,10 +7,7 @@ import android.os.Environment
|
|||
import android.provider.MediaStore
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.containsNoMedia
|
||||
import com.simplemobiletools.gallery.extensions.doesThisOrParentHaveNoMedia
|
||||
import com.simplemobiletools.gallery.extensions.isPathInMediaStore
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import java.io.File
|
||||
import java.util.LinkedHashMap
|
||||
|
@ -246,9 +243,9 @@ class MediaFetcher(val context: Context) {
|
|||
|
||||
private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean): Boolean {
|
||||
val file = File(path)
|
||||
return if (includedPaths.contains(path)) {
|
||||
return if (path.isThisOrParentIncluded(includedPaths)) {
|
||||
true
|
||||
} else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) {
|
||||
} else if (path.isThisOrParentExcluded(excludedPaths)) {
|
||||
false
|
||||
} else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
|
||||
var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.")
|
||||
|
@ -261,9 +258,6 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>) =
|
||||
includedPaths.none { path.startsWith(it, true) } && excludedPaths.any { path.startsWith(it, true) }
|
||||
|
||||
private fun getMediaInFolder(folder: String, curMedia: ArrayList<Medium>, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, allowRecursion: Boolean) {
|
||||
val files = File(folder).listFiles() ?: return
|
||||
for (file in files) {
|
||||
|
@ -310,7 +304,6 @@ class MediaFetcher(val context: Context) {
|
|||
val isAlreadyAdded = curMedia.any { it.path == file.absolutePath }
|
||||
if (!isAlreadyAdded) {
|
||||
curMedia.add(medium)
|
||||
//context.scanPath(file.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue