1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-28 10:47:28 +00:00

Allow removing bold/italic

This commit is contained in:
M66B 2019-03-08 10:01:34 +00:00
parent db36125d19
commit d887687904

View file

@ -794,17 +794,20 @@ public class FragmentCompose extends FragmentBase {
switch (id) {
case R.id.menu_bold:
if (start == end)
Snackbar.make(view, R.string.title_no_selection, Snackbar.LENGTH_LONG).show();
else
ss.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case R.id.menu_italic:
if (start == end)
Snackbar.make(view, R.string.title_no_selection, Snackbar.LENGTH_LONG).show();
else
ss.setSpan(new StyleSpan(Typeface.ITALIC), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
else {
int style = (id == R.id.menu_bold ? Typeface.BOLD : Typeface.ITALIC);
boolean has = false;
for (StyleSpan span : ss.getSpans(start, end, StyleSpan.class))
if (span.getStyle() == style) {
has = true;
ss.removeSpan(span);
}
if (!has)
ss.setSpan(new StyleSpan(style), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
break;
case R.id.menu_clear: