mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 12:42:16 -05:00
made provider authorities relativ to deal with different package ids
This commit is contained in:
parent
96a992353b
commit
f0f2aab92d
@ -197,7 +197,7 @@
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="eu.siacs.conversations.files"
|
||||
android:authorities="${applicationId}.files"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
@ -205,7 +205,7 @@
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
<provider
|
||||
android:authorities="eu.siacs.conversations.barcodes"
|
||||
android:authorities="${applicationId}.barcodes"
|
||||
android:name=".services.BarcodeProvider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true"/>
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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)));
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user