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 } }