diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 65efd76cfb..a3bd4b6584 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -2377,15 +2377,18 @@ public class AdapterMessage extends RecyclerView.Adapter succesive = new ArrayList<>(); - for (Element quote : document.select("blockquote")) { - Element next = quote.nextElementSibling(); - if (next != null && "blockquote".equals(next.tagName())) - succesive.add(quote); - else - quote.html("…"); - } - for (Element quote : succesive) + List successive = new ArrayList<>(); + for (Element quote : document.select("blockquote")) + if (HtmlHelper.hasBorder(quote)) { + Element next = quote.nextElementSibling(); + if (next != null && + "blockquote".equals(next.tagName()) && + HtmlHelper.hasBorder(next)) + successive.add(quote); + else + quote.html("…"); + } + for (Element quote : successive) quote.remove(); } diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 9994e0bcdd..735272be21 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -807,6 +807,17 @@ public class HtmlHelper { sb.append(key).append(':').append(value).append(';'); } break; + + case "border": + case "border-left": + case "border-right": + if (value != null) { + // 1px solid rgb(204,204,204) + Float border = getFontSize(value.trim().split("\\s+")[0], 1.0f); + if (border != null && border > 0) + element.attr("x-border", "true"); + } + break; } } @@ -1989,14 +2000,19 @@ public class HtmlHelper { private static String _getText(Document d) { truncate(d, MAX_FULL_TEXT_SIZE); - for (Element bq : d.select("blockquote")) { - bq.prependChild(new TextNode("[")); - bq.appendChild(new TextNode("]")); - } + for (Element bq : d.select("blockquote")) + if (hasBorder(bq)) { + bq.prependChild(new TextNode("[")); + bq.appendChild(new TextNode("]")); + } return d.text(); } + static boolean hasBorder(Element e) { + return "true".equals(e.attr("x-border")); + } + static String truncate(String text, int at) { if (text.length() < at) return text; @@ -2206,7 +2222,8 @@ public class HtmlHelper { int level = 1; Element parent = bq.parent(); while (parent != null) { - if ("blockquote".equals(parent.tagName())) + if ("blockquote".equals(parent.tagName()) && + hasBorder(parent)) level++; parent = parent.parent(); } @@ -2291,6 +2308,7 @@ public class HtmlHelper { int bulletGap = context.getResources().getDimensionPixelSize(R.dimen.bullet_gap_size); int bulletRadius = context.getResources().getDimensionPixelSize(R.dimen.bullet_radius_size); int bulletIndent = context.getResources().getDimensionPixelSize(R.dimen.bullet_indent_size); + int intentSize = context.getResources().getDimensionPixelSize(R.dimen.indent_size); int quoteGap = context.getResources().getDimensionPixelSize(R.dimen.quote_gap_size); int quoteStripe = context.getResources().getDimensionPixelSize(R.dimen.quote_stripe_width); int line_dash_length = context.getResources().getDimensionPixelSize(R.dimen.line_dash_length); @@ -2573,10 +2591,13 @@ public class HtmlHelper { if (ssb.length() == 0 || ssb.charAt(ssb.length() - 1) != '\n') ssb.append("\n"); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) - setSpan(ssb, new QuoteSpan(colorBlockquote), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); - else - setSpan(ssb, new QuoteSpan(colorBlockquote, quoteStripe, quoteGap), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + if (hasBorder(element)) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) + setSpan(ssb, new QuoteSpan(colorBlockquote), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + else + setSpan(ssb, new QuoteSpan(colorBlockquote, quoteStripe, quoteGap), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + } else + setSpan(ssb, new IndentSpan(intentSize), start, ssb.length()); break; case "br": ssb.append('\n'); @@ -2858,7 +2879,8 @@ public class HtmlHelper { .removeAttr("x-align") .removeAttr("x-column") .removeAttr("x-dashed") - .removeAttr("x-tracking"); + .removeAttr("x-tracking") + .removeAttr("x-border"); } static Spanned fromHtml(@NonNull String html, Context context) { diff --git a/app/src/main/java/eu/faircode/email/IndentSpan.java b/app/src/main/java/eu/faircode/email/IndentSpan.java new file mode 100644 index 0000000000..beac553043 --- /dev/null +++ b/app/src/main/java/eu/faircode/email/IndentSpan.java @@ -0,0 +1,37 @@ +package eu.faircode.email; + +/* + This file is part of FairEmail. + + FairEmail is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FairEmail is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FairEmail. If not, see . + + Copyright 2018-2021 by Marcel Bokhorst (M66B) +*/ + +import android.os.Parcel; +import android.text.style.LeadingMarginSpan; + +public class IndentSpan extends LeadingMarginSpan.Standard { + public IndentSpan(int first, int rest) { + super(first, rest); + } + + public IndentSpan(int every) { + super(every); + } + + public IndentSpan(Parcel src) { + super(src); + } +} diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml index b027df5b48..c7b5a92951 100644 --- a/app/src/main/res/values/dimen.xml +++ b/app/src/main/res/values/dimen.xml @@ -8,6 +8,7 @@ 6dp 3dp 24dp + 24dp 6dp 3dp 3dp