From df447bb94d8098ec15da072514fb8675210d91fe Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 4 Aug 2021 09:37:33 +0200 Subject: [PATCH] Improved omitting bg colors --- .../main/java/eu/faircode/email/HtmlHelper.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 269bb3ffb5..0829673f26 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -619,14 +619,12 @@ public class HtmlHelper { if (color != null && view) color = adjustColor(dark, textColorPrimary, color); - } else { - // Check background/foreground luminance + } else if (bg == Color.TRANSPARENT) { + // Background color was suppressed because "no color" if (color != null) { - double lbg = ColorUtils.calculateLuminance(bg); - double lfg = ColorUtils.calculateLuminance(color); - if (Math.abs(lbg - lfg) < 0.1) { - color = (lbg < 0.5 ? Color.WHITE : Color.BLACK); - } + double lum = ColorUtils.calculateLuminance(color); + if (dark ? lum < MIN_LUMINANCE : lum > 1 - MIN_LUMINANCE) + color = textColorPrimary; } } @@ -634,7 +632,7 @@ public class HtmlHelper { element.attr("x-color", "true"); } else /* background */ { if (color != null && !hasColor(color)) - continue; + color = Color.TRANSPARENT; if (color != null) element.attr("x-background", encodeWebColor(color));