aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-10-05 21:10:32 +0200
committerChristian Schneppe <christian@pix-art.de>2016-10-05 21:10:32 +0200
commitf4b2ede7cc5f2bbb7e17ba5d527131b1895251f4 (patch)
tree5400236fe91966560d1edd56f7f0b1ad91ab7bd6 /src/main/java/de/pixart/messenger
parent41d836902227c619017c0acfa65c59a9594ec3ba (diff)
properly index take photo uris from file provider
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java23
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java2
2 files changed, 16 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 77b730853..1c69eb88d 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -457,14 +457,12 @@ public class FileBackend {
return frame;
}
- public Uri getTakePhotoUri() {
- StringBuilder pathBuilder = new StringBuilder();
- pathBuilder.append(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
- pathBuilder.append('/');
- pathBuilder.append("Camera");
- pathBuilder.append('/');
- pathBuilder.append("IMG_" + this.fileDateFormat.format(new Date()) + ".jpg");
- File file = new File(pathBuilder.toString());
+ private static String getTakePhotoPath() {
+ return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)+"/Camera/";
+ }
+
+ public Uri getTakePhotoUri() {
+ File file = new File(getTakePhotoPath()+"IMG_" + this.fileDateFormat.format(new Date()) + ".jpg");
file.getParentFile().mkdirs();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return FileProvider.getUriForFile(mXmppConnectionService,"de.pixart.messenger.files",file);
@@ -473,6 +471,15 @@ public class FileBackend {
}
}
+ public static Uri getIndexableTakePhotoUri(Uri original) {
+ if ("file".equals(original.getScheme())) {
+ return original;
+ } else {
+ List<String> segments = original.getPathSegments();
+ return Uri.parse("file://"+getTakePhotoPath()+segments.get(segments.size() - 1));
+ }
+ }
+
public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) {
try {
Avatar avatar = new Avatar();
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index c2088e559..845d174d5 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -1695,7 +1695,7 @@ public class ConversationActivity extends XmppActivity
mPendingPhotoUris.clear();
}
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
- intent.setData(uri);
+ intent.setData(FileBackend.getIndexableTakePhotoUri(uri));
sendBroadcast(intent);
} else {
mPendingPhotoUris.clear();