use file provider for taking pictures

This commit is contained in:
Daniel Gultsch 2016-08-30 13:14:38 +02:00
parent d32cbcc70d
commit 3685c8cd2a
2 changed files with 5 additions and 3 deletions

View file

@ -14,9 +14,11 @@ import android.media.MediaMetadataRetriever;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.os.FileObserver;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.provider.OpenableColumns; import android.provider.OpenableColumns;
import android.support.v4.content.FileProvider;
import android.system.Os; import android.system.Os;
import android.system.StructStat; import android.system.StructStat;
import android.util.Base64; import android.util.Base64;
@ -436,10 +438,9 @@ public class FileBackend {
pathBuilder.append("Camera"); pathBuilder.append("Camera");
pathBuilder.append('/'); pathBuilder.append('/');
pathBuilder.append("IMG_" + this.imageDateFormat.format(new Date()) + ".jpg"); pathBuilder.append("IMG_" + this.imageDateFormat.format(new Date()) + ".jpg");
Uri uri = Uri.parse("file://" + pathBuilder.toString()); File file = new File(pathBuilder.toString());
File file = new File(uri.toString());
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
return uri; return FileProvider.getUriForFile(mXmppConnectionService,"eu.siacs.conversations.files",file);
} }
public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) { public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) {

View file

@ -445,6 +445,7 @@ public class ConversationActivity extends XmppActivity
break; break;
case ATTACHMENT_CHOICE_TAKE_PHOTO: case ATTACHMENT_CHOICE_TAKE_PHOTO:
Uri uri = xmppConnectionService.getFileBackend().getTakePhotoUri(); Uri uri = xmppConnectionService.getFileBackend().getTakePhotoUri();
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
mPendingImageUris.clear(); mPendingImageUris.clear();