diff --git a/build.gradle b/build.gradle index 75dfa1409..a59fa123b 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ ext { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 - propVersionName = '2.23.4' + propVersionName = '2.23.6' kotlin_version = '1.1.3-2' support_libs = '25.3.1' } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index 9ce3123fb..70f00c608 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -351,25 +351,14 @@ fun BaseSimpleActivity.getFileDocument(path: String): DocumentFile? { var document = DocumentFile.fromTreeUri(this, Uri.parse(baseConfig.treeUri)) val parts = relativePath.split("/") - for (i in 0..parts.size - 1) { - var currDocument = document.findFile(parts[i]) - if (currDocument != null) { + for (part in parts) { + val currDocument = document.findFile(part) + if (currDocument != null) document = currDocument - } else { - // We need to assure that we transverse to the right directory! - if (i == parts.size - 1) { - // The last document should be the file we're looking for, not a directory - currDocument = document.createFile("", parts[i]) - } else { - currDocument = document.createDirectory(parts[i]) - } - - if (currDocument == null) { - toast(R.string.unknown_error_occurred) - return null - } - document = currDocument - } } - return document + + return if (document.name == path.getFilenameFromPath()) + document + else + null }