Require minimum luminance of 50% for texts

This commit is contained in:
M66B
2019-09-25 09:41:10 +02:00
parent 4e1e9db314
commit cb791f30d3
3 changed files with 10 additions and 10 deletions

View File

@@ -85,6 +85,7 @@ import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE;
public class HtmlHelper {
static final int PREVIEW_SIZE = 250; // characters
private static final float MIN_LUMINANCE = 0.5f;
private static final int MAX_AUTO_LINK = 250;
private static final int TRACKING_PIXEL_SURFACE = 25; // pixels
@@ -193,13 +194,12 @@ public class HtmlHelper {
}
if (color != null) {
double lum = ColorUtils.calculateLuminance(color);
if (dark
? lum < Helper.MIN_LUMINANCE
: lum > 1 - Helper.MIN_LUMINANCE)
float lum = (float) ColorUtils.calculateLuminance(color);
if (dark ? lum < MIN_LUMINANCE : lum > 1 - MIN_LUMINANCE)
color = ColorUtils.blendARGB(color,
dark ? Color.WHITE : Color.BLACK, Helper.MIN_LUMINANCE);
c = String.format("#%06x", 0xFFFFFF & color);
dark ? Color.WHITE : Color.BLACK,
dark ? MIN_LUMINANCE - lum : lum - (1 - MIN_LUMINANCE));
c = String.format("#%06x", color & 0xFFFFFF);
sb.append("color:").append(c).append(";");
}
break;