diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index e7d9b0bdd8..7a6ef36e07 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -485,7 +485,8 @@ public class FragmentCompose extends FragmentBase { if (activity != null) activity.onUserInteraction(); - if (before == 0 && count == 1 && start > 0 && text.charAt(start) == '\n') { + if (before == 0 && count == 1 && start > 0 && + text.charAt(start) == '\n' && text.charAt(start - 1) == '\n') { // break block quotes boolean qbroken = false; SpannableStringBuilder ssb = new SpannableStringBuilder(text); @@ -493,7 +494,7 @@ public class FragmentCompose extends FragmentBase { for (QuoteSpan span : spans) { int s = ssb.getSpanStart(span); int e = ssb.getSpanEnd(span); - int f = ssb.getSpanFlags(span); + int f = ssb.getSpanFlags(span) | Spanned.SPAN_PARAGRAPH; Log.i("Span " + s + "..." + e + " start=" + start); if (s > 0 && start - s > 0 && e - (start + 1) > 0 && diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index c96115f524..ff62545d64 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -2043,16 +2043,15 @@ public class HtmlHelper { ssb.setSpan(new RelativeSizeSpan(FONT_LARGE), start, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case "blockquote": - if (start > 0 && ssb.charAt(start - 1) != '\n') + if (start == 0 || ssb.charAt(start - 1) != '\n') ssb.insert(start++, "\n"); + if (ssb.length() == 0 || ssb.charAt(ssb.length() - 1) != '\n') + ssb.append("\n"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) ssb.setSpan(new QuoteSpan(colorPrimary), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); else ssb.setSpan(new QuoteSpan(colorPrimary, dp3, dp6), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); - - if (ssb.length() > 1 && ssb.charAt(ssb.length() - 1) != '\n') - ssb.append("\n"); break; case "br": newline(ssb.length()); @@ -2096,7 +2095,11 @@ public class HtmlHelper { ssb.setSpan(new ImageSpan(d, src), start, start + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case "li": - newline(ssb.length()); + if (start == 0 || ssb.charAt(start - 1) != '\n') + ssb.insert(start++, "\n"); + if (ssb.length() == 0 || ssb.charAt(ssb.length() - 1) != '\n') + ssb.append("\n"); + Element parent = element.parent(); if (parent == null || "ul".equals(parent.tagName())) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)