This commit is contained in:
Grishka 2023-01-11 13:06:40 +03:00
parent 6a1032cd61
commit d667b8fa98
1 changed files with 10 additions and 3 deletions

View File

@ -413,6 +413,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
mainEditText.setSelectionListener(this); mainEditText.setSelectionListener(this);
mainEditText.addTextChangedListener(new TextWatcher(){ mainEditText.addTextChangedListener(new TextWatcher(){
private int lastChangeStart, lastChangeCount;
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after){ public void beforeTextChanged(CharSequence s, int start, int count, int after){
@ -422,6 +424,14 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
public void onTextChanged(CharSequence s, int start, int before, int count){ public void onTextChanged(CharSequence s, int start, int before, int count){
if(s.length()==0) if(s.length()==0)
return; return;
lastChangeStart=start;
lastChangeCount=count;
}
@Override
public void afterTextChanged(Editable s){
int start=lastChangeStart;
int count=lastChangeCount;
// offset one char back to catch an already typed '@' or '#' or ':' // offset one char back to catch an already typed '@' or '#' or ':'
int realStart=start; int realStart=start;
start=Math.max(0, start-1); start=Math.max(0, start-1);
@ -467,10 +477,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
editable.removeSpan(span); editable.removeSpan(span);
} }
} }
}
@Override
public void afterTextChanged(Editable s){
updateCharCounter(); updateCharCounter();
} }
}); });