mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-04 06:20:26 +00:00
Delete chip on backspace
This commit is contained in:
parent
3bf3e16954
commit
88dcacc823
1 changed files with 12 additions and 1 deletions
|
@ -190,9 +190,11 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie
|
|||
};
|
||||
|
||||
addTextChangedListener(new TextWatcher() {
|
||||
Integer backspace = null;
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// Do nothing
|
||||
backspace = (count - after == 1 ? start : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,6 +204,15 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable edit) {
|
||||
if (backspace != null) {
|
||||
ClipImageSpan[] spans = edit.getSpans(backspace, backspace, ClipImageSpan.class);
|
||||
if (spans.length == 1) {
|
||||
int start = edit.getSpanStart(spans[0]);
|
||||
int end = edit.getSpanEnd(spans[0]);
|
||||
edit.delete(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
if (getWidth() == 0)
|
||||
post(update);
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue