From 96f0a50cd615f618162ab522bce8417610b797b2 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 7 Jul 2021 19:39:09 +0200 Subject: [PATCH] Generic quote style --- app/src/main/java/eu/faircode/email/EntityRule.java | 9 ++++++++- .../java/eu/faircode/email/FragmentCompose.java | 7 ++++++- app/src/main/java/eu/faircode/email/HtmlEx.java | 2 +- app/src/main/java/eu/faircode/email/HtmlHelper.java | 13 +++++++++---- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 332001ac3b..262b4c8946 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -646,7 +646,14 @@ public class EntityRule { div.appendChild(p); Document answering = JsoupEx.parse(message.getFile(context)); - div.appendChild(answering.body().tagName(quote ? "blockquote" : "p")); + Element e = answering.body(); + if (quote) { + String style = e.attr("style"); + style = HtmlHelper.mergeStyles(style, HtmlHelper.QUOTE_STYLE); + e.tagName("blockquote").attr("style", style); + } else + e.tagName("p"); + div.appendChild(e); msg.body().appendChild(div); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index ef457c4e1f..ed5f9a66ee 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -4360,7 +4360,12 @@ public class FragmentCompose extends FragmentBase { boolean quote = (quote_reply && ("reply".equals(action) || "reply_all".equals(action) || "list".equals(action))); - e.tagName(quote ? "blockquote" : "p"); + if (quote) { + String style = e.attr("style"); + style = HtmlHelper.mergeStyles(style, HtmlHelper.QUOTE_STYLE); + e.tagName("blockquote").attr("style", style); + } else + e.tagName("p"); reply.appendChild(e); if (write_below) diff --git a/app/src/main/java/eu/faircode/email/HtmlEx.java b/app/src/main/java/eu/faircode/email/HtmlEx.java index 215ec22797..37d26b332b 100644 --- a/app/src/main/java/eu/faircode/email/HtmlEx.java +++ b/app/src/main/java/eu/faircode/email/HtmlEx.java @@ -144,7 +144,7 @@ public class HtmlEx { for (Object quote : quotes) { if (quote instanceof QuoteSpan) - out.append("
"); + out.append("
"); else out.append("
"); } diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 1926e04f14..239c2cb77a 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -126,6 +126,8 @@ public class HtmlHelper { static final float FONT_SMALL = 0.8f; static final float FONT_LARGE = 1.25f; + static final String QUOTE_STYLE = "border-left:3px solid #ccc; padding-left:3px;"; + private static final int DEFAULT_FONT_SIZE = 16; // pixels private static final int DEFAULT_FONT_SIZE_PT = 12; // points private static final int GRAY_THRESHOLD = Math.round(255 * 0.2f); @@ -140,6 +142,7 @@ public class HtmlHelper { private static final int TRACKING_PIXEL_SURFACE = 25; // pixels private static final float[] HEADING_SIZES = {1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1f}; private static final String LINE = "----------------------------------------"; + private static final HashMap x11ColorMap = new HashMap<>(); static { @@ -808,7 +811,6 @@ public class HtmlHelper { } break; - case "border": case "border-left": case "border-right": if (value != null) { @@ -2031,9 +2033,13 @@ public class HtmlHelper { if (prev != null && "blockquote".equals(prev.tagName()) && hasBorder(prev)) return FilterResult.REMOVE; - level++; + else { + level++; + element.html("…"); + } } } + return FilterResult.CONTINUE; } @@ -2041,11 +2047,10 @@ public class HtmlHelper { public FilterResult tail(Node node, int depth) { if ("blockquote".equals(node.nodeName())) level--; + return FilterResult.CONTINUE; } }); - - document.select("blockquote").html("…"); } static String truncate(String text, int at) {