From cb17b3a8ca1dd7f1f9fe3c8e5c7563b6e7d45ecc Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 9 Jul 2020 19:31:41 +0200 Subject: [PATCH] Show delivery report inline --- .../java/eu/faircode/email/MessageHelper.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 789b8802d2..53e0892605 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1560,11 +1560,12 @@ public class MessageHelper { class MessageParts { private List plain = new ArrayList<>(); private List html = new ArrayList<>(); + private List extra = new ArrayList<>(); private List attachments = new ArrayList<>(); private ArrayList warnings = new ArrayList<>(); Boolean isPlainOnly() { - if (plain.size() + html.size() == 0) + if (plain.size() + html.size() + extra.size() == 0) return null; return (html.size() == 0); } @@ -1573,6 +1574,7 @@ public class MessageHelper { List all = new ArrayList<>(); all.addAll(plain); all.addAll(html); + all.addAll(extra); for (Part p : all) if (p.getSize() > 0) @@ -1587,6 +1589,7 @@ public class MessageHelper { List all = new ArrayList<>(); all.addAll(plain); all.addAll(html); + all.addAll(extra); for (Part p : all) { int s = p.getSize(); if (s >= 0) @@ -1617,7 +1620,13 @@ public class MessageHelper { StringBuilder sb = new StringBuilder(); - for (Part part : html.size() > 0 ? html : plain) { + List parts = new ArrayList<>(); + if (html.size() > 0) + parts.addAll(html); + else + parts.addAll(plain); + parts.addAll(extra); + for (Part part : parts) { if (part.getSize() > MAX_MESSAGE_SIZE) { warnings.add(context.getString(R.string.title_insufficient_memory)); return null; @@ -1697,7 +1706,8 @@ public class MessageHelper { } } } - } + } else if (part.isMimeType("message/delivery-status")) + result = "
" + HtmlHelper.formatPre(result) + "
"; sb.append(result); } @@ -2047,6 +2057,9 @@ public class MessageHelper { else if (html) parts.html.add(part); } else { + if ("message/delivery-status".equalsIgnoreCase(contentType.getBaseType())) + parts.extra.add(part); + AttachmentPart apart = new AttachmentPart(); apart.disposition = disposition; apart.filename = filename;