From 02c1dd3a171be3dcf42d0542bf451247efabc6b6 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 14 Aug 2020 20:32:05 +0200 Subject: [PATCH] Workaround Android span bug --- app/src/main/java/eu/faircode/email/StyleHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java index 33d240a652..5635cf093e 100644 --- a/app/src/main/java/eu/faircode/email/StyleHelper.java +++ b/app/src/main/java/eu/faircode/email/StyleHelper.java @@ -243,6 +243,9 @@ public class StyleHelper { end++; } + if (end == t.length()) + t.append("\n"); // workaround Android bug + // Remove existing bullets BulletSpan[] spans = t.getSpans(start, end, BulletSpan.class); for (BulletSpan span : spans) @@ -253,6 +256,7 @@ public class StyleHelper { int index = 1; while (j < end) { if (i > 0 && t.charAt(i - 1) == '\n' && t.charAt(j) == '\n') { + Log.i("Insert " + i + "..." + (j + 1) + " size=" + end); if (item.getItemId() == R.id.menu_style_list_bullets) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) t.setSpan(new BulletSpan(dp6, colorAccent), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH);