From 4f20c49abb500c6b74558119675314a6210c4221 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 13 Apr 2020 00:31:25 +0530 Subject: Request WRITE_EXTERNAL_STORAGE for external password repository (#698) * PasswordStore: request WRITE_EXTERNAL_STORAGE permission instead We wish to be able to write to our password store directory as well. Fixes #697 Fixes #365 Signed-off-by: Harsh Shandilya * Reword changelog entry Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt index 9844d5a2..f1283538 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt @@ -107,7 +107,7 @@ class PasswordStore : AppCompatActivity() { var savedInstance = savedInstanceState if (savedInstanceState != null && (!settings.getBoolean("git_external", false) || ContextCompat.checkSelfPermission( - activity, Manifest.permission.READ_EXTERNAL_STORAGE) + activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) { savedInstance = null } @@ -129,9 +129,9 @@ class PasswordStore : AppCompatActivity() { super.onResume() // do not attempt to checkLocalRepository() if no storage permission: immediate crash if (settings.getBoolean("git_external", false)) { - if (ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE) + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.READ_EXTERNAL_STORAGE)) { + if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { val snack = Snackbar.make( findViewById(R.id.main_layout), getString(R.string.access_sdcard_text), @@ -139,7 +139,7 @@ class PasswordStore : AppCompatActivity() { .setAction(R.string.dialog_ok) { ActivityCompat.requestPermissions( activity, - arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), + arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_EXTERNAL_STORAGE) } snack.show() @@ -151,7 +151,7 @@ class PasswordStore : AppCompatActivity() { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions( activity, - arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), + arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_EXTERNAL_STORAGE) } } else { -- cgit v1.2.3