From 1c0535ec329cf1c43361dca9e9bc2f37cf9bc238 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 8 Jul 2021 08:16:30 +0200 Subject: [PATCH] Skip drawing invisible bullets --- .../java/eu/faircode/email/BulletSpanEx.java | 16 +++++++++++++++- .../main/java/eu/faircode/email/HtmlHelper.java | 12 +++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/BulletSpanEx.java b/app/src/main/java/eu/faircode/email/BulletSpanEx.java index 18b410f733..26ab30b7e2 100644 --- a/app/src/main/java/eu/faircode/email/BulletSpanEx.java +++ b/app/src/main/java/eu/faircode/email/BulletSpanEx.java @@ -32,18 +32,30 @@ import androidx.annotation.RequiresApi; public class BulletSpanEx extends BulletSpan { private int indentWidth; private int level; + private String ltype; public BulletSpanEx(int indentWidth, int gapWidth, int color, int level) { + this(indentWidth, gapWidth, color, level, null); + } + + @RequiresApi(api = Build.VERSION_CODES.P) + public BulletSpanEx(int indentWidth, int gapWidth, int color, int bulletRadius, int level) { + this(indentWidth, gapWidth, color, bulletRadius, level, null); + } + + public BulletSpanEx(int indentWidth, int gapWidth, int color, int level, String ltype) { super(gapWidth, color); this.indentWidth = indentWidth; this.level = level; + this.ltype = ltype; } @RequiresApi(api = Build.VERSION_CODES.P) - public BulletSpanEx(int indentWidth, int gapWidth, int color, int bulletRadius, int level) { + public BulletSpanEx(int indentWidth, int gapWidth, int color, int bulletRadius, int level, String ltype) { super(gapWidth, color, bulletRadius); this.indentWidth = indentWidth; this.level = level; + this.ltype = ltype; } int getLevel() { @@ -63,6 +75,8 @@ public class BulletSpanEx extends BulletSpan { @Override public void drawLeadingMargin(@NonNull Canvas canvas, @NonNull Paint paint, int x, int dir, int top, int baseline, int bottom, @NonNull CharSequence text, int start, int end, boolean first, @Nullable Layout layout) { + if ("none".equals(ltype)) + return; super.drawLeadingMargin(canvas, paint, x + indentWidth * (level + 1) * dir, dir, top, baseline, bottom, text, start, end, first, layout); } } diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 1b9ad76b3c..8fcbfb7a76 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -824,6 +824,10 @@ public class HtmlHelper { } } break; + + case "list-style-type": + element.attr("x-list-style", value); + break; } } @@ -2741,10 +2745,11 @@ public class HtmlHelper { level--; if (type == null || "ul".equals(type.tagName())) { + String ltype = element.attr("x-list-style"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) - setSpan(ssb, new BulletSpanEx(bulletIndent, bulletGap, colorAccent, level), start, ssb.length()); + setSpan(ssb, new BulletSpanEx(bulletIndent, bulletGap, colorAccent, level, ltype), start, ssb.length()); else - setSpan(ssb, new BulletSpanEx(bulletIndent, bulletGap, colorAccent, bulletRadius, level), start, ssb.length()); + setSpan(ssb, new BulletSpanEx(bulletIndent, bulletGap, colorAccent, bulletRadius, level, ltype), start, ssb.length()); } else { // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol int index = 0; @@ -2934,7 +2939,8 @@ public class HtmlHelper { .removeAttr("x-column") .removeAttr("x-dashed") .removeAttr("x-tracking") - .removeAttr("x-border"); + .removeAttr("x-border") + .removeAttr("x-list-style"); } static Spanned fromHtml(@NonNull String html, Context context) {