Simplified resolving styles and images

This commit is contained in:
M66B 2020-09-23 13:01:20 +02:00
parent 33e0ad5d8c
commit 24bc2e7002
1 changed files with 20 additions and 27 deletions

View File

@ -563,19 +563,15 @@ public class MessageHelper {
// When sending message // When sending message
if (identity != null && send) { if (identity != null && send) {
boolean save = false;
for (Element child : document.body().children()) for (Element child : document.body().children())
if (!TextUtils.isEmpty(child.text()) && if (!TextUtils.isEmpty(child.text()) &&
TextUtils.isEmpty(child.attr("fairemail"))) { TextUtils.isEmpty(child.attr("fairemail"))) {
String old = child.attr("style"); String old = child.attr("style");
String style = HtmlHelper.mergeStyles( String style = HtmlHelper.mergeStyles(
"font-family:" + compose_font, old); "font-family:" + compose_font, old);
if (!old.equals(style)) { if (!old.equals(style))
save = true;
child.attr("style", style); child.attr("style", style);
} }
}
document.select("div[fairemail=signature]").removeAttr("fairemail"); document.select("div[fairemail=signature]").removeAttr("fairemail");
document.select("div[fairemail=reference]").removeAttr("fairemail"); document.select("div[fairemail=reference]").removeAttr("fairemail");
@ -602,30 +598,30 @@ public class MessageHelper {
if (TextUtils.isEmpty(type)) if (TextUtils.isEmpty(type))
type = "image/*"; type = "image/*";
String cid = BuildConfig.APPLICATION_ID + ".content." + Math.abs(source.hashCode());
String acid = "<" + cid + ">";
if (db.attachment().getAttachment(message.id, acid) == null) {
EntityAttachment attachment = new EntityAttachment(); EntityAttachment attachment = new EntityAttachment();
attachment.message = message.id; attachment.message = message.id;
attachment.sequence = db.attachment().getAttachmentSequence(message.id) + 1; attachment.sequence = db.attachment().getAttachmentSequence(message.id) + 1;
attachment.name = name; attachment.name = name;
attachment.type = type; attachment.type = type;
attachment.disposition = Part.INLINE; attachment.disposition = Part.INLINE;
attachment.cid = null; attachment.cid = acid;
attachment.size = null; attachment.size = null;
attachment.progress = 0; attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment); attachment.id = db.attachment().insertAttachment(attachment);
String cid = BuildConfig.APPLICATION_ID + "." + attachment.id;
attachment.cid = "<" + BuildConfig.APPLICATION_ID + "." + attachment.id + ">";
db.attachment().setCid(attachment.id, attachment.cid);
attachment.size = Helper.copy(context, uri, attachment.getFile(context)); attachment.size = Helper.copy(context, uri, attachment.getFile(context));
attachment.progress = null; attachment.progress = null;
attachment.available = true; attachment.available = true;
db.attachment().setDownloaded(attachment.id, attachment.size); db.attachment().setDownloaded(attachment.id, attachment.size);
attachments.add(attachment); attachments.add(attachment);
}
img.attr("src", "cid:" + cid); img.attr("src", "cid:" + cid);
save = true;
} }
db.setTransactionSuccessful(); db.setTransactionSuccessful();
@ -634,9 +630,6 @@ public class MessageHelper {
} finally { } finally {
db.endTransaction(); db.endTransaction();
} }
if (save)
Helper.writeText(message.getFile(context), document.html());
} }
// multipart/mixed // multipart/mixed