diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-12-01 12:09:49 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-12-01 12:09:49 +0100 |
commit | f0f2aab92d9a66a30ab76d263df38f6c227d752d (patch) | |
tree | 592de7b96f1d894f5224438d6009f93925c7be3f /src/main/java/eu | |
parent | 96a992353b29d77f54af51f4e3b6c0c581d25fd3 (diff) |
made provider authorities relativ to deal with different package ids
Diffstat (limited to 'src/main/java/eu')
4 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 1886d3c0..13e27f89 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -60,7 +60,7 @@ import eu.siacs.conversations.xmpp.pep.Avatar; public class FileBackend { private static final SimpleDateFormat IMAGE_DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US); - public static final String CONVERSATIONS_FILE_PROVIDER = "eu.siacs.conversations.files"; + private static final String FILE_PROVIDER = ".files"; private XmppConnectionService mXmppConnectionService; @@ -454,12 +454,17 @@ public class FileBackend { File file = new File(getTakePhotoPath()+"IMG_" + this.IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); file.getParentFile().mkdirs(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return FileProvider.getUriForFile(mXmppConnectionService, CONVERSATIONS_FILE_PROVIDER, file); + return getUriForFile(mXmppConnectionService,file); } else { return Uri.fromFile(file); } } + public static Uri getUriForFile(Context context, File file) { + String packageId = context.getPackageName(); + return FileProvider.getUriForFile(context, packageId + FILE_PROVIDER, file); + } + public static Uri getIndexableTakePhotoUri(Uri original) { if ("file".equals(original.getScheme())) { return original; diff --git a/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java b/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java index 8d00b33e..9c50b081 100644 --- a/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java +++ b/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java @@ -34,7 +34,7 @@ import eu.siacs.conversations.xmpp.jid.Jid; public class BarcodeProvider extends ContentProvider implements ServiceConnection { - private static final String AUTHORITY = "eu.siacs.conversations.barcodes"; + private static final String AUTHORITY = ".barcodes"; private final Object lock = new Object(); @@ -176,8 +176,9 @@ public class BarcodeProvider extends ContentProvider implements ServiceConnectio } } - public static Uri getUriForAccount(Account account) { - return Uri.parse("content://" + AUTHORITY + "/" + account.getJid().toBareJid() + ".png"); + public static Uri getUriForAccount(Context context, Account account) { + final String packageId = context.getPackageName(); + return Uri.parse("content://" + packageId + AUTHORITY + "/" + account.getJid().toBareJid() + ".png"); } public static Bitmap createAztecBitmap(String input, int size) { diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 008c563b..e14f559e 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -763,7 +763,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private void shareBarcode() { Intent intent = new Intent(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_STREAM,BarcodeProvider.getUriForAccount(mAccount)); + intent.putExtra(Intent.EXTRA_STREAM,BarcodeProvider.getUriForAccount(this,mAccount)); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType("image/png"); startActivity(Intent.createChooser(intent, getText(R.string.share_with))); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 5418b344..2de80895 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -711,7 +711,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie Uri uri; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { try { - uri = FileProvider.getUriForFile(activity, FileBackend.CONVERSATIONS_FILE_PROVIDER, file); + uri = FileBackend.getUriForFile(activity, file); } catch (IllegalArgumentException e) { Toast.makeText(activity,activity.getString(R.string.no_permission_to_access_x,file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); return; |