1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-25 23:43:07 +00:00

Prevent crash

This commit is contained in:
M66B 2020-10-29 08:32:23 +01:00
parent 7aea1370ca
commit 26496c1341
4 changed files with 43 additions and 22 deletions

View file

@ -205,6 +205,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
if (attachment == null || !attachment.available) if (attachment == null || !attachment.available)
return false; return false;
try {
File file = attachment.getFile(context); File file = attachment.getFile(context);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file); Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
@ -216,6 +217,15 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
context.startActivity(Intent.createChooser(send, context.getString(R.string.title_select_app))); context.startActivity(Intent.createChooser(send, context.getString(R.string.title_select_app)));
return true; return true;
} catch (Throwable ex) {
/*
java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(SourceFile:730)
at androidx.core.content.FileProvider.getUriForFile(SourceFile:418)
*/
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
return false;
}
} }
private void onDelete(final EntityAttachment attachment) { private void onDelete(final EntityAttachment attachment) {

View file

@ -4775,7 +4775,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message.raw == null || !message.raw) { if (message.raw == null || !message.raw) {
properties.setValue("raw_send", message.id, true); properties.setValue("raw_send", message.id, true);
rawDownload(message); rawDownload(message);
} else { } else
try {
File file = message.getRawFile(context); File file = message.getRawFile(context);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file); Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
@ -4784,12 +4785,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
send.setType("message/rfc822"); send.setType("message/rfc822");
send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
context.startActivity(send); context.startActivity(send);
} catch (ActivityNotFoundException ex) { } catch (Throwable ex) {
Log.w(ex); // java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
ToastEx.makeText(context, context.getString(R.string.title_no_viewer, send), Toast.LENGTH_LONG).show(); Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
} }
} }

View file

@ -2164,6 +2164,9 @@ public class FragmentCompose extends FragmentBase {
Log.w(ex); Log.w(ex);
Snackbar.make(view, getString(R.string.title_no_viewer, intent), Snackbar.LENGTH_LONG) Snackbar.make(view, getString(R.string.title_no_viewer, intent), Snackbar.LENGTH_LONG)
.setGestureInsetBottomIgnored(true).show(); .setGestureInsetBottomIgnored(true).show();
} catch (Throwable ex) {
// / java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
Log.unexpectedError(getParentFragmentManager(), ex);
} }
} }
} else { } else {

View file

@ -483,6 +483,15 @@ public class Helper {
} }
static void share(Context context, File file, String type, String name) { static void share(Context context, File file, String type, String name) {
try {
_share(context, file, type, name);
} catch (Throwable ex) {
// java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
Log.e(ex);
}
}
static void _share(Context context, File file, String type, String name) {
// https://developer.android.com/reference/android/support/v4/content/FileProvider // https://developer.android.com/reference/android/support/v4/content/FileProvider
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file); Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
Log.i("uri=" + uri); Log.i("uri=" + uri);