1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Added workaround for unsupported nested colors

This commit is contained in:
M66B 2020-02-08 15:19:05 +01:00
parent e200c62731
commit 9ed07f1c92

View file

@ -371,6 +371,7 @@ public class HtmlHelper {
sb.append("color:").append(c).append(";");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
element.attr("color", c);
element.attr("x-color", c);
}
break;
@ -656,6 +657,21 @@ public class HtmlHelper {
for (Element div : document.select("div"))
div.tagName("span");
// Workaround: fromHtml does not support nested colors
for (Element span : document.select("span")) {
String c = span.attr("x-color");
if (!TextUtils.isEmpty(c)) {
span.removeAttr("x-color");
for (Element cspan : span.children().select("span")) {
String style = cspan.attr("style");
if (TextUtils.isEmpty(style))
cspan.attr("style", "color:" + c + ";");
else if (!style.contains("color:"))
cspan.attr(style + "color:" + c + ";");
}
}
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
for (Element span : document.select("span"))
if (!TextUtils.isEmpty(span.attr("color")))