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 70f5512d..3cc90102 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/WritePermissionDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/WritePermissionDialog.kt new file mode 100644 index 00000000..1faa2aef --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/WritePermissionDialog.kt @@ -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() + } +} diff --git a/app/src/main/res/layout/write_permission.xml b/app/src/main/res/layout/write_permission.xml new file mode 100644 index 00000000..51eadd95 --- /dev/null +++ b/app/src/main/res/layout/write_permission.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/app/src/main/res/mipmap-hdpi/write_storage.png b/app/src/main/res/mipmap-hdpi/write_storage.png new file mode 100644 index 00000000..01110d81 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/write_storage.png differ diff --git a/app/src/main/res/mipmap-mdpi/write_storage.png b/app/src/main/res/mipmap-mdpi/write_storage.png new file mode 100644 index 00000000..dbdfe8f1 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/write_storage.png differ diff --git a/app/src/main/res/mipmap-xhdpi/write_storage.png b/app/src/main/res/mipmap-xhdpi/write_storage.png new file mode 100644 index 00000000..758e02a0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/write_storage.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/write_storage.png b/app/src/main/res/mipmap-xxhdpi/write_storage.png new file mode 100644 index 00000000..9a7c465c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/write_storage.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/write_storage.png b/app/src/main/res/mipmap-xxxhdpi/write_storage.png new file mode 100644 index 00000000..e6191549 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/write_storage.png differ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 3c42444e..552a4959 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -37,6 +37,8 @@ OK Abbrechen Drücke erneut zum Schließen + Confirm external storage access + Please choose the root folder of the SD card to grant write access on the next screen Name diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b8914983..95540b57 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -37,6 +37,8 @@ OK Annulla Premi di nuovo indietro per uscire + Confirm external storage access + Please choose the root folder of the SD card to grant write access on the next screen Nome diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 97d25cf4..2edd0b6f 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -37,6 +37,8 @@ OK Cancel Press back again to exit + Confirm external storage access + Please choose the root folder of the SD card to grant write access on the next screen Name diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 6ca134ca..0261c661 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -37,6 +37,8 @@ OK Cancelar Press back again to exit + Confirm external storage access + Please choose the root folder of the SD card to grant write access on the next screen Nome diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 74e57b99..712665ca 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -37,6 +37,8 @@ OK Cancel Press back again to exit + Confirm external storage access + Please choose the root folder of the SD card to grant write access on the next screen Name diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c73ad79c..19b0fd46 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,6 +37,8 @@ OK Cancel Press back again to exit + Confirm external storage access + Please choose the root folder of the SD card to grant write access on the next screen Name