made provider authorities relativ to deal with different package ids
This commit is contained in:
		
							parent
							
								
									96a992353b
								
							
						
					
					
						commit
						f0f2aab92d
					
				| @ -197,7 +197,7 @@ | |||||||
| 
 | 
 | ||||||
|         <provider |         <provider | ||||||
|             android:name="android.support.v4.content.FileProvider" |             android:name="android.support.v4.content.FileProvider" | ||||||
|             android:authorities="eu.siacs.conversations.files" |             android:authorities="${applicationId}.files" | ||||||
|             android:exported="false" |             android:exported="false" | ||||||
|             android:grantUriPermissions="true"> |             android:grantUriPermissions="true"> | ||||||
|             <meta-data |             <meta-data | ||||||
| @ -205,7 +205,7 @@ | |||||||
|                 android:resource="@xml/file_paths" /> |                 android:resource="@xml/file_paths" /> | ||||||
|         </provider> |         </provider> | ||||||
|         <provider |         <provider | ||||||
|             android:authorities="eu.siacs.conversations.barcodes" |             android:authorities="${applicationId}.barcodes" | ||||||
|             android:name=".services.BarcodeProvider" |             android:name=".services.BarcodeProvider" | ||||||
|             android:exported="false" |             android:exported="false" | ||||||
|             android:grantUriPermissions="true"/> |             android:grantUriPermissions="true"/> | ||||||
|  | |||||||
| @ -60,7 +60,7 @@ import eu.siacs.conversations.xmpp.pep.Avatar; | |||||||
| public class FileBackend { | public class FileBackend { | ||||||
| 	private static final SimpleDateFormat IMAGE_DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US); | 	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; | 	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 file = new File(getTakePhotoPath()+"IMG_" + this.IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); | ||||||
| 		file.getParentFile().mkdirs(); | 		file.getParentFile().mkdirs(); | ||||||
| 		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||||||
| 			return FileProvider.getUriForFile(mXmppConnectionService, CONVERSATIONS_FILE_PROVIDER, file); | 			return getUriForFile(mXmppConnectionService,file); | ||||||
| 		} else { | 		} else { | ||||||
| 			return Uri.fromFile(file); | 			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) { | 	public static Uri getIndexableTakePhotoUri(Uri original) { | ||||||
| 		if ("file".equals(original.getScheme())) { | 		if ("file".equals(original.getScheme())) { | ||||||
| 			return original; | 			return original; | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ import eu.siacs.conversations.xmpp.jid.Jid; | |||||||
| 
 | 
 | ||||||
| public class BarcodeProvider extends ContentProvider implements ServiceConnection { | 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(); |     private final Object lock = new Object(); | ||||||
| 
 | 
 | ||||||
| @ -176,8 +176,9 @@ public class BarcodeProvider extends ContentProvider implements ServiceConnectio | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public static Uri getUriForAccount(Account account) { |     public static Uri getUriForAccount(Context context, Account account) { | ||||||
|         return Uri.parse("content://" + AUTHORITY + "/" + account.getJid().toBareJid() + ".png"); |         final String packageId = context.getPackageName(); | ||||||
|  |         return Uri.parse("content://" + packageId + AUTHORITY + "/" + account.getJid().toBareJid() + ".png"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public static Bitmap createAztecBitmap(String input, int size) { |     public static Bitmap createAztecBitmap(String input, int size) { | ||||||
|  | |||||||
| @ -763,7 +763,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat | |||||||
| 
 | 
 | ||||||
| 	private void shareBarcode() { | 	private void shareBarcode() { | ||||||
| 		Intent intent = new Intent(Intent.ACTION_SEND); | 		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.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); | ||||||
| 		intent.setType("image/png"); | 		intent.setType("image/png"); | ||||||
| 		startActivity(Intent.createChooser(intent, getText(R.string.share_with))); | 		startActivity(Intent.createChooser(intent, getText(R.string.share_with))); | ||||||
|  | |||||||
| @ -711,7 +711,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie | |||||||
| 		Uri uri; | 		Uri uri; | ||||||
| 		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||||||
| 			try { | 			try { | ||||||
| 				uri = FileProvider.getUriForFile(activity, FileBackend.CONVERSATIONS_FILE_PROVIDER, file); | 				uri = FileBackend.getUriForFile(activity, file); | ||||||
| 			} catch (IllegalArgumentException e) { | 			} catch (IllegalArgumentException e) { | ||||||
| 				Toast.makeText(activity,activity.getString(R.string.no_permission_to_access_x,file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); | 				Toast.makeText(activity,activity.getString(R.string.no_permission_to_access_x,file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); | ||||||
| 				return; | 				return; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch