Skip to content

Commit

Permalink
Feat[touch_char_input]: directly modify the Editable instead of relyi…
Browse files Browse the repository at this point in the history
…ng on the internal TextView methods.
  • Loading branch information
artdeell committed Jan 17, 2025
1 parent 2a44e8d commit 5d8cf0d
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import static android.content.Context.INPUT_METHOD_SERVICE;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.Editable;
import android.text.Selection;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -78,13 +78,15 @@ public void switchKeyboardState(){
* Clear the EditText from any leftover inputs
* It does not affect the in-game input
*/
@SuppressLint("SetTextI18n")
public void clear(){
mIsDoingInternalChanges = true;
// Edit the Editable directly as it doesn't affect the state
// of the TextView.
Editable editable = getEditableText();
editable.clear();
//Braille space, doesn't trigger keyboard auto-complete
//replacing directly the text without though setText avoids notifying changes
setText(TEXT_FILLER);
setSelection(TEXT_FILLER.length());
editable.append(TEXT_FILLER);
Selection.setSelection(editable, TEXT_FILLER.length());
mIsDoingInternalChanges = false;
}

Expand Down

0 comments on commit 5d8cf0d

Please sign in to comment.