mirror of https://github.com/M66B/FairEmail.git
Added composing indentation
This commit is contained in:
parent
aacdcae4de
commit
2048374ad0
|
@ -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);
|
||||
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 (QuoteSpan quote : quotes) {
|
||||
out.append("<blockquote>");
|
||||
for (Object quote : quotes) {
|
||||
if (quote instanceof QuoteSpan)
|
||||
out.append("<blockquote style=\"border:3px solid #ccc; padding-left: 3px;\">");
|
||||
else
|
||||
out.append("<blockquote>");
|
||||
}
|
||||
|
||||
withinBlockquote(out, text, i, next, option);
|
||||
|
||||
for (QuoteSpan quote : quotes) {
|
||||
for (Object quote : quotes) {
|
||||
out.append("</blockquote>\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Integer, Integer> 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");
|
||||
|
||||
|
|
|
@ -113,9 +113,28 @@
|
|||
android:title="@string/title_style_blockquote" />
|
||||
</group>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_style_indentation"
|
||||
android:icon="@drawable/twotone_format_indent_increase_24"
|
||||
android:orderInCategory="8"
|
||||
android:title="@string/title_style_indentation">
|
||||
<menu>
|
||||
<group android:id="@+id/group_style_indentation">
|
||||
<item
|
||||
android:id="@+id/menu_style_indentation_increase"
|
||||
android:icon="@drawable/twotone_format_indent_increase_24"
|
||||
android:title="@string/title_style_list_level_increase" />
|
||||
<item
|
||||
android:id="@+id/menu_style_indentation_decrease"
|
||||
android:icon="@drawable/twotone_format_indent_decrease_24"
|
||||
android:title="@string/title_style_list_level_decrease" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<group
|
||||
android:id="@+id/group_style_strikethrough"
|
||||
android:orderInCategory="8">
|
||||
android:orderInCategory="9">
|
||||
<item
|
||||
android:id="@+id/menu_style_strikethrough"
|
||||
android:icon="@drawable/twotone_format_strikethrough_24"
|
||||
|
@ -124,7 +143,7 @@
|
|||
|
||||
<group
|
||||
android:id="@+id/group_style_clear"
|
||||
android:orderInCategory="9">
|
||||
android:orderInCategory="10">
|
||||
<item
|
||||
android:id="@+id/menu_style_clear"
|
||||
android:icon="@drawable/twotone_format_clear_24"
|
||||
|
|
|
@ -1103,6 +1103,7 @@
|
|||
<string name="title_style_font">Font</string>
|
||||
<string name="title_style_font_default">Default</string>
|
||||
<string name="title_style_blockquote">Block quote</string>
|
||||
<string name="title_style_indentation">Indentation</string>
|
||||
<string name="title_style_strikethrough">Strikethrough</string>
|
||||
<string name="title_style_clear">Clear formatting</string>
|
||||
<string name="title_style_link">Insert link</string>
|
||||
|
|
Loading…
Reference in New Issue