From e0d244696bb00230c9f40d8c685b9bd02285f990 Mon Sep 17 00:00:00 2001
From: M66B ");
+
+ int next;
+ for (int i = start; i < end; i = next) {
+@@ -302,24 +294,24 @@ public class HtmlEx {
+
+ withinParagraph(out, text, i, next - nl);
+
+- if (nl == 0) {
++ if (nl == 1) {
+ out.append("
\n");
++ out.append("
\n");
+ } else {
+- Boolean isBulletListItem = null;
++ boolean isListItem = false;
+ ParagraphStyle[] paragraphStyles = text.getSpans(i, next, ParagraphStyle.class);
+ for (ParagraphStyle paragraphStyle : paragraphStyles) {
+ final int spanFlags = text.getSpanFlags(paragraphStyle);
+ if ((spanFlags & Spanned.SPAN_PARAGRAPH) == Spanned.SPAN_PARAGRAPH
+ && paragraphStyle instanceof BulletSpan) {
+- isBulletListItem = !(paragraphStyle instanceof eu.faircode.email.NumberSpan);
++ isListItem = true;
+ break;
+ }
+ }
+
+- if (isBulletListItem != null && isInBulletList != null && isBulletListItem != isInBulletList) {
+- out.append(isInBulletList ? "\n" : "\n");
+- isInBulletList = null;
+- }
+-
+- if (isBulletListItem != null && isInBulletList == null) {
++ if (isListItem && !isInList) {
+ // Current paragraph is the first item in a list
+- isInBulletList = isBulletListItem;
+- out.append(isInBulletList ? "\n");
+ }
+
+- if (isInBulletList != null && isBulletListItem == null) {
++ if (isInList && !isListItem) {
+ // Current paragraph is no longer a list item; close the previously opened list
+- out.append(isInBulletList ? "
\n" : "\n");
+- isInBulletList = null;
++ isInList = false;
++ out.append("\n");
+ }
+
+- String tagType = isBulletListItem != null ? "li" : "span";
++ String tagType = isListItem ? "li" : "p";
+ out.append("<").append(tagType)
+ .append(getTextDirection(text, i, next))
+- .append(getTextStyles(text, i, next, isBulletListItem == null, true))
++ .append(getTextStyles(text, i, next, !isListItem, true))
+ .append(">");
+
+ withinParagraph(out, text, i, next);
+@@ -269,12 +263,10 @@ public class HtmlEx {
+ out.append("");
+ out.append(tagType);
+ out.append(">\n");
+- if (isBulletListItem == null)
+- out.append("
\n");
+
+- if (next == end && isInBulletList != null) {
+- out.append(isInBulletList ? "\n" : "\n");
+- isInBulletList = null;
++ if (next == end && isInList) {
++ isInList = false;
++ out.append("\n");
+ }
+ }
+
+@@ -282,9 +274,9 @@ public class HtmlEx {
+ }
+ }
+
+- private /* static */ void withinBlockquoteConsecutive(StringBuilder out, Spanned text, int start,
++ private static void withinBlockquoteConsecutive(StringBuilder out, Spanned text, int start,
+ int end) {
+- out.append("");
++ out.append("
\n");
+ } else {
+- for (int j = 0; j < nl; j++) {
++ for (int j = 2; j < nl; j++) {
+ out.append("
");
+ }
+ if (next != end) {
+ /* Paragraph should be closed and reopened */
+- out.append("
"); + } + } + } + +- out.append("\n"); ++ out.append("
\n"); + } + +- private /* static */ void withinParagraph(StringBuilder out, Spanned text, int start, int end) { ++ private static void withinParagraph(StringBuilder out, Spanned text, int start, int end) { + int next; + for (int i = start; i < end; i = next) { + next = text.nextSpanTransition(i, end, CharacterStyle.class); +@@ -339,11 +331,9 @@ public class HtmlEx { + if (style[j] instanceof TypefaceSpan) { + String s = ((TypefaceSpan) style[j]).getFamily(); + +- //if ("monospace".equals(s)) { +- // out.append(""); +- //} +- +- out.append(""); ++ if ("monospace".equals(s)) { ++ out.append(""); ++ } + } + if (style[j] instanceof SuperscriptSpan) { + out.append(""); +@@ -374,8 +364,8 @@ public class HtmlEx { + AbsoluteSizeSpan s = ((AbsoluteSizeSpan) style[j]); + float sizeDip = s.getSize(); + if (!s.getDip()) { +- //Application application = ActivityThread.currentApplication(); +- sizeDip /= context.getResources().getDisplayMetrics().density; ++ Application application = ActivityThread.currentApplication(); ++ sizeDip /= application.getResources().getDisplayMetrics().density; + } + + // px in CSS is the equivalance of dip in Android +@@ -427,13 +417,11 @@ public class HtmlEx { + out.append(""); + } + if (style[j] instanceof TypefaceSpan) { +- //String s = ((TypefaceSpan) style[j]).getFamily(); +- +- //if (s.equals("monospace")) { +- // out.append(""); +- //} ++ String s = ((TypefaceSpan) style[j]).getFamily(); + +- out.append(""); ++ if (s.equals("monospace")) { ++ out.append(""); ++ } + } + if (style[j] instanceof StyleSpan) { + int s = ((StyleSpan) style[j]).getStyle(); +@@ -449,8 +437,8 @@ public class HtmlEx { + } + } + +- //@UnsupportedAppUsage +- private /* static */ void withinStyle(StringBuilder out, CharSequence text, ++ @UnsupportedAppUsage ++ private static void withinStyle(StringBuilder out, CharSequence text, + int start, int end) { + for (int i = start; i < end; i++) { + char c = text.charAt(i); diff --git a/patches/HtmlEx.patch b/patches/HtmlEx.patch deleted file mode 100644 index 6ca1687bd2..0000000000 --- a/patches/HtmlEx.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/app/src/main/java/eu/faircode/email/HtmlEx.java b/app/src/main/java/eu/faircode/email/HtmlEx.java -index c8b8e1b8f..5cfceaccd 100644 ---- a/app/src/main/java/eu/faircode/email/HtmlEx.java -+++ b/app/src/main/java/eu/faircode/email/HtmlEx.java -@@ -276,7 +276,7 @@ public class HtmlEx { - - private /* static */ void withinBlockquoteConsecutive(StringBuilder out, Spanned text, int start, - int end) { -- out.append("");
-+ out.append("");
-
- int next;
- for (int i = start; i < end; i = next) {
-@@ -294,21 +294,21 @@ public class HtmlEx {
-
- withinParagraph(out, text, i, next - nl);
-
-- if (nl == 1) {
-+ if (nl == 0) {
- out.append("
\n");
- } else {
-- for (int j = 2; j < nl; j++) {
-+ for (int j = 0; j < nl; j++) {
- out.append("
");
- }
- if (next != end) {
- /* Paragraph should be closed and reopened */
-- out.append("
"); -+ out.append("\n"); -+ out.append(""); - } - } - } - -- out.append("
\n"); -+ out.append("\n"); - } - - private /* static */ void withinParagraph(StringBuilder out, Spanned text, int start, int end) { diff --git a/patches/HtmlExNumber.patch b/patches/HtmlExNumber.patch deleted file mode 100644 index db7c66386c..0000000000 --- a/patches/HtmlExNumber.patch +++ /dev/null @@ -1,87 +0,0 @@ -diff --git a/app/src/main/java/eu/faircode/email/HtmlEx.java b/app/src/main/java/eu/faircode/email/HtmlEx.java -index 5cfceaccd..f6db9f051 100644 ---- a/app/src/main/java/eu/faircode/email/HtmlEx.java -+++ b/app/src/main/java/eu/faircode/email/HtmlEx.java -@@ -211,7 +211,7 @@ public class HtmlEx { - - private /* static */ void withinBlockquoteIndividual(StringBuilder out, Spanned text, int start, - int end) { -- boolean isInList = false; -+ Boolean isInBulletList = null; - int next; - for (int i = start; i <= end; i = next) { - next = TextUtils.indexOf(text, '\n', i, end); -@@ -220,42 +220,47 @@ public class HtmlEx { - } - - if (next == i) { -- if (isInList) { -+ if (isInBulletList != null) { - // Current paragraph is no longer a list item; close the previously opened list -- isInList = false; -- out.append("\n"); -+ out.append(isInBulletList ? "\n" : "\n"); -+ isInBulletList = null; - } - out.append("