mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
add an image about the Kitkat new write permission thing
This commit is contained in:
@ -14,6 +14,7 @@ import android.view.MenuItem
|
||||
import com.simplemobiletools.filemanager.Constants
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.Utils
|
||||
import com.simplemobiletools.filemanager.dialogs.WritePermissionDialog
|
||||
import com.simplemobiletools.filemanager.fragments.ItemsFragment
|
||||
import com.simplemobiletools.filepicker.dialogs.StoragePickerDialog
|
||||
import com.simplemobiletools.filepicker.extensions.getInternalStoragePath
|
||||
@ -137,8 +138,12 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
||||
fun checkStupidAndroidFiveSDCardWritePermission(pickedPath: String): Boolean {
|
||||
val file = File(pickedPath)
|
||||
return if (!file.canWrite() && Utils.needsStupidWritePermissions(applicationContext, pickedPath) && mConfig.treeUri.isEmpty()) {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
startActivityForResult(intent, OPEN_DOCUMENT_TREE)
|
||||
WritePermissionDialog(this, object: WritePermissionDialog.OnWritePermissionListener {
|
||||
override fun onConfirmed() {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
startActivityForResult(intent, OPEN_DOCUMENT_TREE)
|
||||
}
|
||||
})
|
||||
false
|
||||
} else
|
||||
true
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.simplemobiletools.filemanager.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import com.simplemobiletools.filemanager.R
|
||||
|
||||
class WritePermissionDialog(val context: Context, val listener: OnWritePermissionListener) {
|
||||
var dialog: AlertDialog? = null
|
||||
|
||||
init {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.write_permission, null)
|
||||
|
||||
dialog = AlertDialog.Builder(context)
|
||||
.setTitle(context.resources.getString(R.string.confirm_storage_access_title))
|
||||
.setView(view)
|
||||
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
|
||||
.create()
|
||||
|
||||
dialog?.show()
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
dialog?.dismiss()
|
||||
listener.onConfirmed()
|
||||
}
|
||||
|
||||
interface OnWritePermissionListener {
|
||||
fun onConfirmed()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user