1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Prefix cid with package name

Fixes #122
This commit is contained in:
M66B 2018-09-16 11:06:15 +00:00
parent 5a61f0d53a
commit f525b88b84

View file

@ -575,7 +575,7 @@ public class FragmentCompose extends FragmentEx {
int start = etBody.getSelectionStart();
etBody.getText().insert(start, " ");
SpannableString s = new SpannableString(etBody.getText());
ImageSpan is = new ImageSpan(getContext(), Uri.parse("cid:" + attachment.id), ImageSpan.ALIGN_BASELINE);
ImageSpan is = new ImageSpan(getContext(), Uri.parse("cid:" + BuildConfig.APPLICATION_ID + "." + attachment.id), ImageSpan.ALIGN_BASELINE);
s.setSpan(is, start, start + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
String html = Html.toHtml(s);
Log.i(Helper.TAG, "html=" + html);
@ -681,7 +681,7 @@ public class FragmentCompose extends FragmentEx {
}
if (image)
attachment.cid = "<" + attachment.id + ">";
attachment.cid = "<" + BuildConfig.APPLICATION_ID + "." + attachment.id + ">";
attachment.size = size;
attachment.progress = null;
@ -1219,8 +1219,9 @@ public class FragmentCompose extends FragmentEx {
public Drawable getDrawable(String source) {
if (source != null && source.startsWith("cid")) {
String[] cid = source.split(":");
if (cid.length > 1) {
File file = EntityAttachment.getFile(getContext(), Long.parseLong(cid[1]));
if (cid.length == 2 && cid[1].startsWith(BuildConfig.APPLICATION_ID)) {
long id = Long.parseLong(cid[1].replace(BuildConfig.APPLICATION_ID + ".", ""));
File file = EntityAttachment.getFile(getContext(), id);
Drawable d = Drawable.createFromPath(file.getAbsolutePath());
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;