check android version too ad editing SD card content
This commit is contained in:
parent
e511702fd5
commit
b3e0dceff6
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue