add an image about the Kitkat new write permission thing

This commit is contained in:
tibbi
2016-11-05 22:07:04 +01:00
parent 479c3c6c4e
commit 44e268b441
14 changed files with 74 additions and 2 deletions

View File

@ -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

View File

@ -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()
}
}