1
0
Fork 0

fixed incorrect behavior of the virtual Clear Filter key when using the suggestion to be filtered was selected with a hardware key

This commit is contained in:
sspanak 2024-08-30 12:57:10 +03:00 committed by Dimo Karaivanov
parent 11a6c97afa
commit d9c899f787
3 changed files with 12 additions and 3 deletions

View file

@ -17,6 +17,7 @@ abstract public class AbstractHandler extends InputMethodService {
abstract public boolean onOK(); abstract public boolean onOK();
abstract public boolean onText(String text, boolean validateOnly); // used for "#", "*" and whatnot abstract public boolean onText(String text, boolean validateOnly); // used for "#", "*" and whatnot
// lifecycle
abstract protected void onInit(); abstract protected void onInit();
abstract protected boolean onStart(InputConnection inputConnection, EditorInfo inputField); abstract protected boolean onStart(InputConnection inputConnection, EditorInfo inputField);
abstract protected void onFinishTyping(); abstract protected void onFinishTyping();
@ -27,7 +28,7 @@ abstract public class AbstractHandler extends InputMethodService {
abstract protected void createSuggestionBar(); abstract protected void createSuggestionBar();
abstract protected void resetStatus(); abstract protected void resetStatus();
// informational
abstract protected InputMode getInputMode(); abstract protected InputMode getInputMode();
abstract protected int getInputModeId(); abstract protected int getInputModeId();
abstract protected SuggestionOps getSuggestionOps(); abstract protected SuggestionOps getSuggestionOps();

View file

@ -21,6 +21,7 @@ public class SoftFilterKey extends SoftKey {
preventRepeat(); preventRepeat();
if (validateTT9Handler() && tt9.onKeyFilterClear(false)) { if (validateTT9Handler() && tt9.onKeyFilterClear(false)) {
vibrate(Vibration.getHoldVibration()); vibrate(Vibration.getHoldVibration());
ignoreLastPressedKey();
} }
} }

View file

@ -36,7 +36,9 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
private boolean repeat = false; private boolean repeat = false;
private long lastLongClickTime = 0; private long lastLongClickTime = 0;
private final Handler repeatHandler = new Handler(Looper.getMainLooper()); private final Handler repeatHandler = new Handler(Looper.getMainLooper());
private static int lastPressedKey = -1; private static int lastPressedKey = -1;
private boolean ignoreLastPressedKey = false;
public SoftKey(Context context) { public SoftKey(Context context) {
@ -88,7 +90,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
if (!repeat || hold) { if (!repeat || hold) {
hold = false; hold = false;
boolean result = handleRelease(); boolean result = handleRelease();
lastPressedKey = getId(); lastPressedKey = ignoreLastPressedKey ? -1 : getId();
return result; return result;
} }
repeat = false; repeat = false;
@ -120,7 +122,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
if (hold) { if (hold) {
repeat = true; repeat = true;
handleHold(); handleHold();
lastPressedKey = getId(); lastPressedKey = ignoreLastPressedKey ? -1 : getId();
repeatHandler.removeCallbacks(this::repeatOnLongPress); repeatHandler.removeCallbacks(this::repeatOnLongPress);
repeatHandler.postDelayed(this::repeatOnLongPress, getLongPressRepeatDelay()); repeatHandler.postDelayed(this::repeatOnLongPress, getLongPressRepeatDelay());
} }
@ -151,6 +153,11 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
} }
protected void ignoreLastPressedKey() {
ignoreLastPressedKey = true;
}
protected boolean handlePress() { protected boolean handlePress() {
if (validateTT9Handler()) { if (validateTT9Handler()) {
vibrate(Vibration.getPressVibration(this)); vibrate(Vibration.getPressVibration(this));