Skip to content

Commit

Permalink
Merge pull request #6353 from Imericxu/fix-pasting-rich-text-in-search
Browse files Browse the repository at this point in the history
Fix unwanted rich text formatting when pasting
  • Loading branch information
TobiGr authored May 29, 2021
2 parents 67b8338 + ea1b910 commit 0eb69b6
Showing 1 changed file with 6 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,11 @@ public void onTextChanged(final CharSequence s, final int start,

@Override
public void afterTextChanged(final Editable s) {
// Remove rich text formatting
for (final CharacterStyle span : s.getSpans(0, s.length(), CharacterStyle.class)) {
s.removeSpan(span);
}

final String newText = searchEditText.getText().toString();
suggestionPublisher.onNext(newText);
}
Expand Down

0 comments on commit 0eb69b6

Please sign in to comment.