From ecad9cbe3cedd2029faa58053ddbdf6a231d91fa Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 1 Nov 2019 10:40:17 +0100 Subject: [PATCH] =?UTF-8?q?catch=20security=20exception=20when=20passing?= =?UTF-8?q?=20on=20share=20intent=20that=20didn=E2=80=99t=20give=20us=20pe?= =?UTF-8?q?rmission?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/ChooseAccountForProfilePictureActivity.java | 8 +++++++- .../java/eu/siacs/conversations/ui/ShareWithActivity.java | 7 ++++++- src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java index cfb4f05fb..fca082c42 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseAccountForProfilePictureActivity.java @@ -5,6 +5,7 @@ import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.widget.ListView; +import android.widget.Toast; import java.util.ArrayList; import java.util.List; @@ -78,7 +79,12 @@ public class ChooseAccountForProfilePictureActivity extends XmppActivity { intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toString()); intent.setData(uri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - startActivity(intent); + try { + startActivity(intent); + } catch (SecurityException e) { + Toast.makeText(this, R.string.sharing_application_not_grant_permission, Toast.LENGTH_SHORT).show(); + return; + } } finish(); } diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 0ec7abd9a..dd4ea40a2 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -200,7 +200,12 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer intent.putExtra(Intent.EXTRA_TEXT, share.text); intent.putExtra(ConversationsActivity.EXTRA_AS_QUOTE, share.asQuote); } - startActivity(intent); + try { + startActivity(intent); + } catch (SecurityException e) { + Toast.makeText(this, R.string.sharing_application_not_grant_permission, Toast.LENGTH_SHORT).show(); + return; + } finish(); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 799ee5071..3674aab53 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -878,4 +878,5 @@ Please enter the password for this account Unable to perform this action Join public channel… + The sharing application did not grant permission to access this file.