From 5d8cf0d2dc7203f9f2f2bc193aa0282d35b193eb Mon Sep 17 00:00:00 2001 From: artdeell Date: Wed, 15 Jan 2025 20:22:01 +0300 Subject: [PATCH] Feat[touch_char_input]: directly modify the Editable instead of relying on the internal TextView methods. --- .../customcontrols/keyboard/TouchCharInput.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/keyboard/TouchCharInput.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/keyboard/TouchCharInput.java index ef0fe4e825..3ae75f1693 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/keyboard/TouchCharInput.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/keyboard/TouchCharInput.java @@ -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; @@ -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; }