diff --git a/app/src/main/java/com/simplemobiletools/filemanager/Utils.kt b/app/src/main/java/com/simplemobiletools/filemanager/Utils.kt index 59e18dc1..aa01c5eb 100644 --- a/app/src/main/java/com/simplemobiletools/filemanager/Utils.kt +++ b/app/src/main/java/com/simplemobiletools/filemanager/Utils.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager import android.Manifest import android.content.Context import android.content.pm.PackageManager +import android.os.Build import android.support.v4.content.ContextCompat import android.widget.Toast import com.simplemobiletools.filepicker.extensions.getSDCardPath @@ -31,7 +32,11 @@ object Utils { return matcher.matches() } + fun needsStupidWritePermissions(context: Context, path: String) = isPathOnSD(context, path) && isKitkat() + fun isPathOnSD(context: Context, path: String): Boolean { return path.startsWith(context.getSDCardPath()) } + + fun isKitkat() = Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt index 5c229fbb..70f5512d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt @@ -136,7 +136,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br fun checkStupidAndroidFiveSDCardWritePermission(pickedPath: String): Boolean { val file = File(pickedPath) - return if (!file.canWrite() && Utils.isPathOnSD(applicationContext, pickedPath) && mConfig.treeUri.isEmpty()) { + return if (!file.canWrite() && Utils.needsStupidWritePermissions(applicationContext, pickedPath) && mConfig.treeUri.isEmpty()) { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) startActivityForResult(intent, OPEN_DOCUMENT_TREE) false