aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-30 13:14:38 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-08-30 13:14:38 +0200
commit3685c8cd2a705d38d84f72fe363677e7a40d1043 (patch)
tree88d3113acfa2ca3a820d9888934dff904b008f95 /src/main/java
parentd32cbcc70d4336c89997c5f473656a05e19fc940 (diff)
use file provider for taking pictures
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/FileBackend.java7
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java1
2 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
index 843cb155..7bb2e943 100644
--- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java
@@ -14,9 +14,11 @@ import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
+import android.os.FileObserver;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
+import android.support.v4.content.FileProvider;
import android.system.Os;
import android.system.StructStat;
import android.util.Base64;
@@ -436,10 +438,9 @@ public class FileBackend {
pathBuilder.append("Camera");
pathBuilder.append('/');
pathBuilder.append("IMG_" + this.imageDateFormat.format(new Date()) + ".jpg");
- Uri uri = Uri.parse("file://" + pathBuilder.toString());
- File file = new File(uri.toString());
+ File file = new File(pathBuilder.toString());
file.getParentFile().mkdirs();
- return uri;
+ return FileProvider.getUriForFile(mXmppConnectionService,"eu.siacs.conversations.files",file);
}
public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 6ee7f737..8bb1a7f7 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -445,6 +445,7 @@ public class ConversationActivity extends XmppActivity
break;
case ATTACHMENT_CHOICE_TAKE_PHOTO:
Uri uri = xmppConnectionService.getFileBackend().getTakePhotoUri();
+ intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
mPendingImageUris.clear();