mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
properly make the Included folders check recursive
This commit is contained in:
parent
1a163ce56a
commit
d2a6d2cb88
3 changed files with 8 additions and 11 deletions
|
@ -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"
|
"$dirName $hidden"
|
||||||
} else {
|
} else {
|
||||||
dirName
|
dirName
|
||||||
|
|
|
@ -4,3 +4,7 @@ import com.bumptech.glide.signature.ObjectKey
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
fun String.getFileSignature() = ObjectKey(File(this).lastModified().toString())
|
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 android.provider.MediaStore
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.extensions.containsNoMedia
|
|
||||||
import com.simplemobiletools.gallery.extensions.doesThisOrParentHaveNoMedia
|
|
||||||
import com.simplemobiletools.gallery.extensions.isPathInMediaStore
|
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.LinkedHashMap
|
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 {
|
private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean): Boolean {
|
||||||
val file = File(path)
|
val file = File(path)
|
||||||
return if (includedPaths.contains(path)) {
|
return if (path.isThisOrParentIncluded(includedPaths)) {
|
||||||
true
|
true
|
||||||
} else if (isThisOrParentExcluded(path, excludedPaths, includedPaths)) {
|
} else if (path.isThisOrParentExcluded(excludedPaths)) {
|
||||||
false
|
false
|
||||||
} else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
|
} else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
|
||||||
var containsNoMediaOrDot = file.containsNoMedia() || path.contains("/.")
|
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) {
|
private fun getMediaInFolder(folder: String, curMedia: ArrayList<Medium>, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int, allowRecursion: Boolean) {
|
||||||
val files = File(folder).listFiles() ?: return
|
val files = File(folder).listFiles() ?: return
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
|
@ -310,7 +304,6 @@ class MediaFetcher(val context: Context) {
|
||||||
val isAlreadyAdded = curMedia.any { it.path == file.absolutePath }
|
val isAlreadyAdded = curMedia.any { it.path == file.absolutePath }
|
||||||
if (!isAlreadyAdded) {
|
if (!isAlreadyAdded) {
|
||||||
curMedia.add(medium)
|
curMedia.add(medium)
|
||||||
//context.scanPath(file.absolutePath)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue