Skip to content

Commit

Permalink
use file provider for taking pictures
Browse files Browse the repository at this point in the history
  • Loading branch information
iNPUTmice committed Aug 30, 2016
1 parent d32cbcc commit 3685c8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
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;
Expand Down Expand Up @@ -436,10 +438,9 @@ public Uri getTakePhotoUri() {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ public void onPresenceSelected() {
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();
Expand Down

0 comments on commit 3685c8c

Please sign in to comment.