Skip to content

Commit

Permalink
Add formatting removal on paste for search
Browse files Browse the repository at this point in the history
  • Loading branch information
imericxu committed May 23, 2021
1 parent f0bb2e8 commit 30e49ac
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.CharacterStyle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -588,6 +589,12 @@ public void onTextChanged(final CharSequence s, final int start,

@Override
public void afterTextChanged(final Editable s) {
final CharacterStyle[] toBeRemovedSpans = s.getSpans(
0, s.length(), CharacterStyle.class
);
for (final CharacterStyle toBeRemovedSpan : toBeRemovedSpans) {
s.removeSpan(toBeRemovedSpan);
}
final String newText = searchEditText.getText().toString();
suggestionPublisher.onNext(newText);
}
Expand Down

0 comments on commit 30e49ac

Please sign in to comment.