diff --git a/app/src/main/java/eu/faircode/email/HtmlEx.java b/app/src/main/java/eu/faircode/email/HtmlEx.java index 6aa76d67a6..215ec22797 100644 --- a/app/src/main/java/eu/faircode/email/HtmlEx.java +++ b/app/src/main/java/eu/faircode/email/HtmlEx.java @@ -136,16 +136,22 @@ public class HtmlEx { int option) { int next; for (int i = start; i < end; i = next) { - next = text.nextSpanTransition(i, end, QuoteSpan.class); - QuoteSpan[] quotes = text.getSpans(i, next, QuoteSpan.class); - - for (QuoteSpan quote : quotes) { - out.append("
"); + int n1 = text.nextSpanTransition(i, end, QuoteSpan.class); + int n2 = text.nextSpanTransition(i, end, eu.faircode.email.IndentSpan.class); + Class type = (n1 < n2 ? QuoteSpan.class : eu.faircode.email.IndentSpan.class); + next = Math.min(n1, n2); + Object[] quotes = text.getSpans(i, next, type); + + for (Object quote : quotes) { + if (quote instanceof QuoteSpan) + out.append("
"); + else + out.append("
"); } withinBlockquote(out, text, i, next, option); - for (QuoteSpan quote : quotes) { + for (Object quote : quotes) { out.append("
\n"); } } diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 735272be21..d1a5c453c5 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -814,8 +814,13 @@ public class HtmlHelper { if (value != null) { // 1px solid rgb(204,204,204) Float border = getFontSize(value.trim().split("\\s+")[0], 1.0f); - if (border != null && border > 0) + if (border != null && border > 0) { element.attr("x-border", "true"); + if (!view) { + sb.append("border-left").append(':').append("3px solid #ccc").append(';'); + sb.append("padding-left").append(':').append("3px").append(';'); + } + } } break; } @@ -2951,6 +2956,8 @@ public class HtmlHelper { last.remove(); } + Log.i("MMM " + doc.html()); + return doc.html(); } diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java index b714e79921..369c15604e 100644 --- a/app/src/main/java/eu/faircode/email/StyleHelper.java +++ b/app/src/main/java/eu/faircode/email/StyleHelper.java @@ -172,6 +172,9 @@ public class StyleHelper { popupMenu.getMenu().findItem(R.id.menu_style_list_increase).setVisible(level >= 0); popupMenu.getMenu().findItem(R.id.menu_style_list_decrease).setVisible(level > 0); + IndentSpan[] indents = edit.getSpans(start, end, IndentSpan.class); + popupMenu.getMenu().findItem(R.id.menu_style_indentation_decrease).setEnabled(indents.length > 0); + popupMenu.insertIcons(context); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @@ -198,6 +201,8 @@ public class StyleHelper { return setList(item); } else if (groupId == R.id.group_style_blockquote) { return setBlockQuote(item); + } else if (groupId == R.id.group_style_indentation) { + return setIndentation(item); } else if (groupId == R.id.group_style_strikethrough) { return setStrikeThrough(item); } else if (groupId == R.id.group_style_clear) { @@ -503,6 +508,17 @@ public class StyleHelper { if (paragraph == null) return false; + QuoteSpan[] quotes = edit.getSpans(paragraph.first, paragraph.second, QuoteSpan.class); + for (QuoteSpan quote : quotes) + edit.removeSpan(quote); + + if (quotes.length == 1) + return true; + + IndentSpan[] indents = edit.getSpans(start, end, IndentSpan.class); + for (IndentSpan indent : indents) + edit.removeSpan(indent); + QuoteSpan q; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) q = new QuoteSpan(colorBlockquote); @@ -516,6 +532,35 @@ public class StyleHelper { return true; } + private boolean setIndentation(MenuItem item) { + Log.breadcrumb("style", "action", "indent"); + + Pair paragraph = ensureParagraph(edit, start, end); + if (paragraph == null) + return false; + + if (item.getItemId() == R.id.menu_style_indentation_decrease) { + IndentSpan[] indents = edit.getSpans(paragraph.first, paragraph.second, IndentSpan.class); + if (indents.length > 0) + edit.removeSpan(indents[0]); + } else { + Context context = etBody.getContext(); + int intentSize = context.getResources().getDimensionPixelSize(R.dimen.indent_size); + + QuoteSpan[] quotes = edit.getSpans(start, end, QuoteSpan.class); + for (QuoteSpan quote : quotes) + edit.removeSpan(quote); + + IndentSpan is = new IndentSpan(intentSize); + edit.setSpan(is, paragraph.first, paragraph.second, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); + } + + etBody.setText(edit); + etBody.setSelection(paragraph.first, paragraph.second); + + return true; + } + private boolean setStrikeThrough(MenuItem item) { Log.breadcrumb("style", "action", "strike"); diff --git a/app/src/main/res/menu/popup_style.xml b/app/src/main/res/menu/popup_style.xml index 165c99e9f0..7a9592b34e 100644 --- a/app/src/main/res/menu/popup_style.xml +++ b/app/src/main/res/menu/popup_style.xml @@ -113,9 +113,28 @@ android:title="@string/title_style_blockquote" /> + + + + + + + + + + android:orderInCategory="9"> + android:orderInCategory="10"> Font Default Block quote + Indentation Strikethrough Clear formatting Insert link