mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Merge branch '2214-catch-activity-not-found-exception-when-saving-image' into 'master'
Catch ActivityNotFoundException when saving image Closes #2214 See merge request briar/briar!1627
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.briar.android.conversation;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -263,7 +264,11 @@ public class ImageActivity extends BriarActivity
|
||||
if (SDK_INT >= 19) {
|
||||
String name = viewModel.getFileName() + "." +
|
||||
getVisibleAttachment().getExtension();
|
||||
launcher.launch(name);
|
||||
try {
|
||||
launcher.launch(name);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
viewModel.onSaveImageError();
|
||||
}
|
||||
} else {
|
||||
viewModel.saveImage(getVisibleAttachment());
|
||||
}
|
||||
|
||||
@@ -180,12 +180,17 @@ public class ImageViewModel extends DbViewModel implements EventListener {
|
||||
@UiThread
|
||||
void saveImage(AttachmentItem attachment, @Nullable Uri uri) {
|
||||
if (uri == null) {
|
||||
saveState.setEvent(true);
|
||||
onSaveImageError();
|
||||
} else {
|
||||
saveImage(attachment, () -> getOutputStream(uri), null);
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
void onSaveImageError() {
|
||||
saveState.setEvent(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the attachment on external storage,
|
||||
* assuming the permission was granted during install time.
|
||||
|
||||
Reference in New Issue
Block a user