mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 18:27:43 +00:00
Allow removing bold/italic
This commit is contained in:
parent
db36125d19
commit
d887687904
1 changed files with 11 additions and 8 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue