tweak the way folders at grouping direct subfolders are checked

This commit is contained in:
tibbi 2018-12-12 23:31:12 +01:00
parent 7dcfa167a7
commit e3fcd3c84b

View file

@ -926,11 +926,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun getDirectParentSubfolders(folders: HashSet<String>): HashSet<String> { private fun getDirectParentSubfolders(folders: HashSet<String>): HashSet<String> {
val internalPath = internalStoragePath val internalPath = internalStoragePath
val sdPath = sdCardPath val sdPath = sdCardPath
val currentPaths = HashSet<String>() val currentPaths = LinkedHashSet<String>()
folders.forEach { folders.forEach {
val path = it
if (it != internalPath && it != sdPath) { if (it != internalPath && it != sdPath) {
val parent = File(it).parent if (folders.any { it != path && (File(path).parent == it || File(it).parent == File(path).parent) }) {
currentPaths.add(parent) val parent = File(it).parent
currentPaths.add(parent)
} else {
currentPaths.add(it)
}
} }
} }
@ -938,7 +943,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
currentPaths.forEach { currentPaths.forEach {
val path = it val path = it
currentPaths.forEach { currentPaths.forEach {
if (it != path && it.startsWith(path)) { if (it != path && File(it).parent == path) {
areDirectSubfoldersAvailable = true areDirectSubfoldersAvailable = true
} }
} }