diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-12-13 17:55:24 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2019-12-13 17:55:24 +0100 |
commit | 65bfbafa1761bfd80c82825a285a84a2f9db3ce9 (patch) | |
tree | 5888eafa6c1c7351884a337b48a5c2e9def59c7f /src/main/java | |
parent | 51f52022cb3b36735993cecdee4cdc14201f4428 (diff) |
use setFlags instead of addFlags to grant uri permissions
Diffstat (limited to 'src/main/java')
9 files changed, 9 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/services/ExportBackupService.java b/src/main/java/de/pixart/messenger/services/ExportBackupService.java index 8d105ba88..b5c1293e0 100644 --- a/src/main/java/de/pixart/messenger/services/ExportBackupService.java +++ b/src/main/java/de/pixart/messenger/services/ExportBackupService.java @@ -401,7 +401,7 @@ public class ExportBackupService extends Service { uris.add(FileBackend.getUriForFile(this, file)); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType(MIME_TYPE); final Intent chooser = Intent.createChooser(intent, getString(R.string.share_backup_files)); shareFilesIntent = PendingIntent.getActivity(this, 190, chooser, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/src/main/java/de/pixart/messenger/ui/ChooseAccountForProfilePictureActivity.java b/src/main/java/de/pixart/messenger/ui/ChooseAccountForProfilePictureActivity.java index 23214e228..0c008532c 100644 --- a/src/main/java/de/pixart/messenger/ui/ChooseAccountForProfilePictureActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ChooseAccountForProfilePictureActivity.java @@ -75,7 +75,7 @@ public class ChooseAccountForProfilePictureActivity extends XmppActivity { Intent intent = new Intent(this, PublishProfilePictureActivity.class); intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toString()); intent.setData(uri); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { startActivity(intent); } catch (SecurityException e) { diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 1f02022b3..de03a3838 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -1772,8 +1772,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke final Uri uri = activity.xmppConnectionService.getFileBackend().getTakePhotoUri(); pendingTakePhotoUri.push(uri); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION & Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); break; case ATTACHMENT_CHOICE_CHOOSE_FILE: diff --git a/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java b/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java index 8f65e54eb..f60550975 100644 --- a/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java @@ -174,7 +174,7 @@ public class ImportBackupActivity extends XmppActivity implements ServiceConnect intent.putExtra("file", uri.getPath()); } else { intent.setData(uri); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } setLoadingState(true); ContextCompat.startForegroundService(this, intent); diff --git a/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java b/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java index 1032eb82a..04d44e142 100644 --- a/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java +++ b/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java @@ -166,7 +166,7 @@ public class MediaViewerActivity extends XmppActivity implements AudioManager.On String mime = MimeUtils.guessMimeTypeFromUri(this, uri); Intent openIntent = new Intent(Intent.ACTION_VIEW); openIntent.setDataAndType(uri, mime); - openIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); PackageManager manager = this.getPackageManager(); List<ResolveInfo> info = manager.queryIntentActivities(openIntent, 0); if (info.size() == 0) { diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java index c79895324..7ae001a6f 100644 --- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java @@ -186,7 +186,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer if (share.uris.size() > 0) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, share.uris); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else if (share.text != null) { intent.setAction(ConversationsActivity.ACTION_VIEW_CONVERSATION); intent.putExtra(Intent.EXTRA_TEXT, share.text); diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index cf23b0e7e..4d70c97f1 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -581,7 +581,7 @@ public abstract class XmppActivity extends ActionBarActivity { Intent intent = new Intent(this, XmppConnectionService.class); intent.setAction(Intent.ACTION_SEND); intent.setData(uri); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); try { startService(intent); } catch (Exception e) { diff --git a/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java b/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java index 71cc5614a..6d76cf6eb 100644 --- a/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java +++ b/src/main/java/de/pixart/messenger/ui/util/ShareUtil.java @@ -67,7 +67,7 @@ public class ShareUtil { Toast.makeText(activity, activity.getString(R.string.no_permission_to_access_x, file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); return; } - shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); String mime = message.getMimeType(); if (mime == null) { mime = "*/*"; diff --git a/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java b/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java index db729f0e4..931477425 100644 --- a/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java +++ b/src/main/java/de/pixart/messenger/ui/util/ViewUtil.java @@ -69,7 +69,7 @@ public class ViewUtil { } else { Intent openIntent = new Intent(Intent.ACTION_VIEW); openIntent.setDataAndType(uri, mime); - openIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + openIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); PackageManager manager = context.getPackageManager(); List<ResolveInfo> info = manager.queryIntentActivities(openIntent, 0); if (info.size() == 0) { |