Fixed adding attachments

pull/162/head
M66B 5 years ago
parent 9776fe9661
commit eedcff1913

@ -1395,15 +1395,20 @@ public class FragmentCompose extends FragmentBase {
long id = args.getLong("id"); long id = args.getLong("id");
Uri uri = args.getParcelable("uri"); Uri uri = args.getParcelable("uri");
boolean image = args.getBoolean("image"); boolean image = args.getBoolean("image");
CharSequence body = args.getCharSequence("body");
int start = args.getInt("start");
EntityAttachment attachment = addAttachment(context, id, uri, image); EntityAttachment attachment = addAttachment(context, id, uri, image);
if (!image)
return null;
File file = attachment.getFile(context); File file = attachment.getFile(context);
Drawable d = Drawable.createFromPath(file.getAbsolutePath()); Drawable d = Drawable.createFromPath(file.getAbsolutePath());
if (d == null)
throw new IllegalArgumentException(context.getString(R.string.title_no_image));
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
CharSequence body = args.getCharSequence("body");
int start = args.getInt("start");
Uri cid = Uri.parse("cid:" + BuildConfig.APPLICATION_ID + "." + attachment.id); Uri cid = Uri.parse("cid:" + BuildConfig.APPLICATION_ID + "." + attachment.id);
SpannableStringBuilder s = new SpannableStringBuilder(body); SpannableStringBuilder s = new SpannableStringBuilder(body);
@ -1421,6 +1426,9 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
protected void onExecuted(Bundle args, final Spanned body) { protected void onExecuted(Bundle args, final Spanned body) {
if (body == null)
return;
etBody.setText(body); etBody.setText(body);
etBody.setSelection(args.getInt("start")); etBody.setSelection(args.getInt("start"));
@ -1433,6 +1441,8 @@ public class FragmentCompose extends FragmentBase {
// External app sending absolute file // External app sending absolute file
if (ex instanceof SecurityException) if (ex instanceof SecurityException)
handleFileShare(); handleFileShare();
else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.toString(), Snackbar.LENGTH_LONG).show();
else else
Helper.unexpectedError(getFragmentManager(), ex); Helper.unexpectedError(getFragmentManager(), ex);
} }

@ -558,6 +558,7 @@
<string name="title_no_connection">Synchronization will be performed on next account connection</string> <string name="title_no_connection">Synchronization will be performed on next account connection</string>
<string name="title_no_folder">Folder does not exist</string> <string name="title_no_folder">Folder does not exist</string>
<string name="title_no_format">The originally received message will be included</string> <string name="title_no_format">The originally received message will be included</string>
<string name="title_no_image">Image could not be decoded</string>
<string name="title_accross_remark">Messages moved across accounts will be downloaded again resulting in extra data usage</string> <string name="title_accross_remark">Messages moved across accounts will be downloaded again resulting in extra data usage</string>
<string name="title_raw_saved">Raw message saved</string> <string name="title_raw_saved">Raw message saved</string>
<string name="title_attachment_saved">Attachment saved</string> <string name="title_attachment_saved">Attachment saved</string>

Loading…
Cancel
Save