From 095e5e5dd6f44a122b4b7689f49d32dd3bf63dec Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Tue, 12 Nov 2019 10:43:32 +0100 Subject: [PATCH] Add FLAG_GRANT_PREFIX_URI_PERMISSION flag --- .../keepass/activities/helpers/OpenFileHelper.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/helpers/OpenFileHelper.kt b/app/src/main/java/com/kunzisoft/keepass/activities/helpers/OpenFileHelper.kt index deac3ee02..c9f09f0a4 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/helpers/OpenFileHelper.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/helpers/OpenFileHelper.kt @@ -75,9 +75,10 @@ class OpenFileHelper { val intentOpenDocument = Intent(APP_ACTION_OPEN_DOCUMENT).apply { addCategory(Intent.CATEGORY_OPENABLE) type = "*/*" - flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or - Intent.FLAG_GRANT_WRITE_URI_PERMISSION or - Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION + flags = Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or + Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or + Intent.FLAG_GRANT_READ_URI_PERMISSION or + Intent.FLAG_GRANT_WRITE_URI_PERMISSION } if (fragment != null) fragment?.startActivityForResult(intentOpenDocument, OPEN_DOC) @@ -85,10 +86,15 @@ class OpenFileHelper { activity?.startActivityForResult(intentOpenDocument, OPEN_DOC) } + @SuppressLint("InlinedApi") private fun openActivityWithActionGetContent() { val intentGetContent = Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) type = "*/*" + flags = Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or + Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or + Intent.FLAG_GRANT_READ_URI_PERMISSION or + Intent.FLAG_GRANT_WRITE_URI_PERMISSION } if (fragment != null) fragment?.startActivityForResult(intentGetContent, GET_CONTENT)