diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index a188b8daf..965960e0a 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -1190,7 +1190,14 @@ public class FileBackend { } public Uri getTakePhotoUri() { - File file = new File(getTakeFromCameraPath() + "IMG_" + fileDateFormat.format(new Date()) + ".jpg"); + final String filename = String.format("IMG_%s.%s", fileDateFormat.format(new Date()),"jpg"); + File file; + if (STORAGE_INDEX.get() == 1) { + final File dcimCache = new File(mXmppConnectionService.getCacheDir(), "Camera"); + file = new File(dcimCache, filename); + } else { + file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), filename); + } file.getParentFile().mkdirs(); return getUriForFile(mXmppConnectionService, file); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index fd47fc3ab..2d054e626 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -21,6 +21,7 @@ import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -2100,7 +2101,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (context == null) { return; } - if (intent.resolveActivity(context.getPackageManager()) != null) { + try { Log.d(Config.LOGTAG, "Attachment: " + attachmentChoice); if (chooser) { startActivityForResult( @@ -2111,7 +2112,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke startActivityForResult(intent, attachmentChoice); activity.overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } - } else { + } catch (final ActivityNotFoundException e) { //ignore ToastCompat.makeText(context, R.string.no_application_found, ToastCompat.LENGTH_LONG).show(); } }