Selective clear style

This commit is contained in:
M66B 2019-09-26 15:05:33 +02:00
parent bcbcdf6e54
commit 77496ae970
1 changed files with 19 additions and 2 deletions

View File

@ -1026,18 +1026,35 @@ public class FragmentCompose extends FragmentBase {
}
private void onMenuClear() {
int start = etBody.getSelectionStart();
int end = etBody.getSelectionEnd();
if (start < 0)
start = 0;
if (end < 0)
end = 0;
if (start > end) {
int tmp = start;
start = end;
end = tmp;
}
boolean selected = (start != end);
if (start == end) {
start = 0;
end = etBody.length();
}
SpannableString ss = new SpannableString(etBody.getText());
for (Object span : ss.getSpans(0, ss.length(), Object.class))
for (Object span : ss.getSpans(start, end, Object.class))
if (!(span instanceof ImageSpan))
ss.removeSpan(span);
etBody.setText(ss);
etBody.setSelection(end, end);
if (selected)
etBody.setSelection(start, end);
}
private void onMenuContactGroup() {