From cf64335cb4ded8718f59eea7093b4b851646b754 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 10 Feb 2020 18:03:25 +0100 Subject: [PATCH] Never more --- .../java/eu/faircode/email/AdapterMessage.java | 12 +++++++----- .../java/eu/faircode/email/HtmlHelper.java | 18 ++++++++++++++++++ app/src/main/res/values/strings.xml | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index a8db572ac3..d14d6c61ac 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -247,8 +247,6 @@ public class AdapterMessage extends RecyclerView.Adapter PARANOID_QUERY = Collections.unmodifiableList(Arrays.asList( // https://en.wikipedia.org/wiki/UTM_parameters @@ -1749,9 +1747,6 @@ public class AdapterMessage extends RecyclerView.Adapter LARGE_MESSAGE_SIZE) - return HtmlHelper.fromHtml("" + context.getString(R.string.title_too_large) + ""); - // Cleanup message document = HtmlHelper.sanitize(context, body, show_images, true); @@ -3495,6 +3490,13 @@ public class AdapterMessage extends RecyclerView.Adapter heads = Collections.unmodifiableList(Arrays.asList( @@ -714,11 +715,28 @@ public class HtmlHelper { if (!TextUtils.isEmpty(span.attr("color"))) span.tagName("font"); + int length = 0; + for (Element elm : document.select("*")) { + for (Node child : elm.childNodes()) + if (child instanceof TextNode) + length += ((TextNode) child).text().length(); + if (length > MAX_TEXT_SIZE) + elm.remove(); + } + if (document.body() == null) { Log.e("Sanitize without body"); document.normalise(); } + if (length > MAX_TEXT_SIZE) + document.body() + .appendElement("p") + .appendElement("big") + .appendElement("a") + .attr("href", "more:") + .text(context.getString(R.string.title_show_more)); + return document; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 62e02484fc..dc0c24e0d0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -694,7 +694,7 @@ The originally received message will be included Image could not be decoded Search on server is not available for this account - Message too large to reformat, try to use the original message view via the full screen icon instead + Show more … Unused inline images will be removed on send Messages moved across accounts will be downloaded again resulting in extra data usage Raw message saved