From e3fcd3c84b3c0407b5c5dcfe951101be1aa7c470 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 12 Dec 2018 23:31:12 +0100 Subject: [PATCH] tweak the way folders at grouping direct subfolders are checked --- .../gallery/pro/activities/MainActivity.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 25bac3170..3ad0ce15d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -926,11 +926,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun getDirectParentSubfolders(folders: HashSet): HashSet { val internalPath = internalStoragePath val sdPath = sdCardPath - val currentPaths = HashSet() + val currentPaths = LinkedHashSet() folders.forEach { + val path = it if (it != internalPath && it != sdPath) { - val parent = File(it).parent - currentPaths.add(parent) + if (folders.any { it != path && (File(path).parent == it || File(it).parent == File(path).parent) }) { + val parent = File(it).parent + currentPaths.add(parent) + } else { + currentPaths.add(it) + } } } @@ -938,7 +943,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { currentPaths.forEach { val path = it currentPaths.forEach { - if (it != path && it.startsWith(path)) { + if (it != path && File(it).parent == path) { areDirectSubfoldersAvailable = true } }