improve the handling of direct subfolder grouping in some cases
This commit is contained in:
parent
92316d8827
commit
72db7e8070
|
@ -211,19 +211,29 @@ fun Context.getDirectParentSubfolders(folders: HashSet<String>, currentPathPrefi
|
||||||
val internalPath = internalStoragePath
|
val internalPath = internalStoragePath
|
||||||
val sdPath = sdCardPath
|
val sdPath = sdCardPath
|
||||||
val currentPaths = LinkedHashSet<String>()
|
val currentPaths = LinkedHashSet<String>()
|
||||||
|
|
||||||
folders.forEach {
|
folders.forEach {
|
||||||
val path = it
|
val path = it
|
||||||
if (!path.equals(internalPath, true) && !path.equals(sdPath, true) && path != RECYCLE_BIN && path != FAVORITES) {
|
if (path != RECYCLE_BIN && path != FAVORITES && !path.equals(internalPath, true) && !path.equals(sdPath, true)) {
|
||||||
if (currentPathPrefix.isNotEmpty()) {
|
if (currentPathPrefix.isNotEmpty()) {
|
||||||
if (File(path).parent.equals(currentPathPrefix, true) || path == currentPathPrefix) {
|
if (path == currentPathPrefix || File(path).parent.equals(currentPathPrefix, true)) {
|
||||||
currentPaths.add(path)
|
currentPaths.add(path)
|
||||||
}
|
}
|
||||||
} else if (folders.any { !it.equals(path, true) && (File(path).parent.equals(it, true) || File(it).parent.equals(File(path).parent, true)) }) {
|
} else if (folders.any { !it.equals(path, true) && (File(path).parent.equals(it, true) || File(it).parent.equals(File(path).parent, true)) }) {
|
||||||
|
// if we have folders like
|
||||||
|
// /storage/emulated/0/Pictures/Images and
|
||||||
|
// /storage/emulated/0/Pictures/Screenshots,
|
||||||
|
// but /storage/emulated/0/Pictures is empty, show Images and Screenshots as separate folders, do not group them at /Pictures
|
||||||
|
|
||||||
val parent = File(path).parent
|
val parent = File(path).parent
|
||||||
|
if (folders.contains(parent)) {
|
||||||
currentPaths.add(parent)
|
currentPaths.add(parent)
|
||||||
} else {
|
} else {
|
||||||
currentPaths.add(path)
|
currentPaths.add(path)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
currentPaths.add(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue