From 011b2884e06f710a234f9713b76f027810e6f159 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 7 Aug 2020 14:28:03 +0200 Subject: [PATCH] Update message content on downloading EML files --- .../eu/faircode/email/AdapterMessage.java | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index e92b9c825d..5ec16ab05e 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1464,25 +1464,32 @@ public class AdapterMessage extends RecyclerView.Adapter>() { @Override public void onChanged(@Nullable List attachments) { + int inlineImages = 0; + int embeddedMessages = 0; + if (attachments != null) + for (EntityAttachment attachment : attachments) + if (attachment.available) + if (attachment.isInline() && attachment.isImage()) + inlineImages++; + else if ("message/rfc822".equals(attachment.type)) + embeddedMessages++; + + int lastInlineImages = 0; + int lastEmbeddedMessages = 0; + List lastAttachments = properties.getAttachments(message.id); + if (lastAttachments != null) + for (EntityAttachment attachment : lastAttachments) + if (attachment.available) + if (attachment.isInline() && attachment.isImage()) + lastInlineImages++; + else if ("message/rfc822".equals(attachment.type)) + lastEmbeddedMessages++; + boolean show_images = properties.getValue("images", message.id); boolean inline = prefs.getBoolean("inline_images", false); - if (show_images || inline) { - int inlineImages = 0; - if (attachments != null) - for (EntityAttachment attachment : attachments) - if (attachment.available && attachment.isInline() && attachment.isImage()) - inlineImages++; - - int lastInlineImages = 0; - List lastAttachments = properties.getAttachments(message.id); - if (lastAttachments != null) - for (EntityAttachment attachment : lastAttachments) - if (attachment.available && attachment.isInline() && attachment.isImage()) - lastInlineImages++; - - if (inlineImages > lastInlineImages) - bindBody(message, false); - } + if (embeddedMessages > lastEmbeddedMessages || + (inlineImages > lastInlineImages && (show_images || inline))) + bindBody(message, false); bindAttachments(message, attachments); }