aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-29 13:26:39 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-29 13:26:39 +0200
commit74f0efc4fdcf7b96d3a7a6da4fea874485ff85d4 (patch)
tree3c8b09387ea1a4425a040052db09bab9493bd8cb /src/main/java/de/pixart/messenger/persistance
parent77e7591ed203200f602a956ddbd04d9d5caf9852 (diff)
get real file name for files shared from Conversations
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 143505e9a..b4a758b07 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -578,8 +578,7 @@ public class FileBackend {
public static Uri getUriForFile(Context context, File file) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
- String packageId = context.getPackageName();
- return FileProvider.getUriForFile(context, packageId + FILE_PROVIDER, file);
+ return FileProvider.getUriForFile(context, getAuthority(context), file);
} catch (IllegalArgumentException e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
throw new SecurityException(e);
@@ -592,6 +591,10 @@ public class FileBackend {
}
}
+ public static String getAuthority(Context context) {
+ return context.getPackageName() + FILE_PROVIDER;
+ }
+
public static Uri getIndexableTakePhotoUri(Uri original) {
if ("file".equals(original.getScheme())) {
return original;
@@ -776,9 +779,7 @@ public class FileBackend {
input = rotate(input, getRotation(image));
return cropCenterSquare(input, size);
}
- } catch (SecurityException e) {
- return null; // happens for example on Android 6.0 if contacts permissions get revoked
- } catch (FileNotFoundException e) {
+ } catch (FileNotFoundException | SecurityException e) {
return null;
} finally {
close(is);