Added color workarounds

pull/174/head
M66B 5 years ago
parent ecd7172723
commit 7890a36d45

@ -662,24 +662,28 @@ public class HtmlHelper {
private static Integer parseColor(@NonNull String value, boolean dark) { private static Integer parseColor(@NonNull String value, boolean dark) {
// https://developer.mozilla.org/en-US/docs/Web/CSS/color_value // https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
String c = value String c = value
.replace("null", "")
.replace("none", "") .replace("none", "")
.replace("unset", "") .replace("unset", "")
.replace("inherit", "") .replace("inherit", "")
.replace("initial", "") .replace("initial", "")
.replace("windowtext", "") .replace("windowtext", "")
.replace("transparent", "") .replace("transparent", "")
.replaceAll("[^a-z0-9(),.%#]", ""); .replaceAll("[^a-z0-9(),.%#]", "")
.replaceAll("#+", "#");
Integer color = null; Integer color = null;
try { try {
if (TextUtils.isEmpty(c)) if (TextUtils.isEmpty(c))
return null; return null;
else if (c.startsWith("#")) { else if (c.startsWith("#")) {
String code = c.substring(1); if (c.length() > 1) {
if (x11ColorMap.containsKey(code)) // workaround String code = c.substring(1);
color = x11ColorMap.get(code) | 0xFF000000; if (x11ColorMap.containsKey(code)) // workaround
else color = x11ColorMap.get(code) | 0xFF000000;
color = Integer.decode(c) | 0xFF000000; else
color = Integer.decode(c) | 0xFF000000;
}
} else if (c.startsWith("rgb") || c.startsWith("hsl")) { } else if (c.startsWith("rgb") || c.startsWith("hsl")) {
int s = c.indexOf("("); int s = c.indexOf("(");
int e = c.indexOf(")"); int e = c.indexOf(")");

Loading…
Cancel
Save