mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
improve the handling of direct subfolder grouping in some cases
This commit is contained in:
parent
92316d8827
commit
72db7e8070
1 changed files with 13 additions and 3 deletions
|
@ -211,16 +211,26 @@ fun Context.getDirectParentSubfolders(folders: HashSet<String>, currentPathPrefi
|
|||
val internalPath = internalStoragePath
|
||||
val sdPath = sdCardPath
|
||||
val currentPaths = LinkedHashSet<String>()
|
||||
|
||||
folders.forEach {
|
||||
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 (File(path).parent.equals(currentPathPrefix, true) || path == currentPathPrefix) {
|
||||
if (path == currentPathPrefix || File(path).parent.equals(currentPathPrefix, true)) {
|
||||
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)) }) {
|
||||
// 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
|
||||
currentPaths.add(parent)
|
||||
if (folders.contains(parent)) {
|
||||
currentPaths.add(parent)
|
||||
} else {
|
||||
currentPaths.add(path)
|
||||
}
|
||||
} else {
|
||||
currentPaths.add(path)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue