mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-08 01:53:25 +02:00
Cleanup
This commit is contained in:
@@ -1688,72 +1688,6 @@ public class HtmlHelper {
|
||||
return ssb.toString();
|
||||
}
|
||||
|
||||
static void convertLists(Document document) {
|
||||
if (BuildConfig.DEBUG)
|
||||
return;
|
||||
|
||||
for (Element span : document.select("span")) {
|
||||
// Skip signature and referenced message
|
||||
boolean body = true;
|
||||
Element parent = span.parent();
|
||||
while (parent != null) {
|
||||
if ("div".equals(parent.tagName()) &&
|
||||
!TextUtils.isEmpty(parent.attr("fairemail"))) {
|
||||
body = false;
|
||||
break;
|
||||
}
|
||||
parent = parent.parent();
|
||||
}
|
||||
if (!body)
|
||||
continue;
|
||||
|
||||
Element list = null;
|
||||
for (int i = 0; i < span.childNodeSize(); i++) {
|
||||
boolean item = false;
|
||||
Node node = span.childNode(i);
|
||||
if (node instanceof TextNode) {
|
||||
String text = ((TextNode) node).text().trim();
|
||||
Node next = node.nextSibling();
|
||||
if ((/*text.startsWith("* ") ||*/ text.startsWith("- ")) &&
|
||||
(next == null || "br".equals(next.nodeName()))) {
|
||||
item = true;
|
||||
String type = (text.startsWith("* ") ? "ul" : "ol");
|
||||
|
||||
Element li = document.createElement("li");
|
||||
li.text(text.substring(2));
|
||||
|
||||
if (list == null || !list.tagName().equals(type)) {
|
||||
Node before = node.previousSibling();
|
||||
if (before != null && "br".equals(before.nodeName())) {
|
||||
before.remove();
|
||||
i--;
|
||||
}
|
||||
|
||||
list = document.createElement(type);
|
||||
list.appendChild(li);
|
||||
node.replaceWith(list);
|
||||
|
||||
} else {
|
||||
list.appendChild(li);
|
||||
node.remove();
|
||||
i--;
|
||||
}
|
||||
|
||||
if (next != null)
|
||||
next.remove();
|
||||
}
|
||||
} else {
|
||||
if (list != null && "br".equals(node.nodeName())) {
|
||||
node.remove();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (!item)
|
||||
list = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Spanned highlightHeaders(Context context, String headers) {
|
||||
int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(headers);
|
||||
|
||||
Reference in New Issue
Block a user