1
0
Fork 0

fixed auto-accepting causig MainView to hide unexpectedly when changing the input mode (#324)

This commit is contained in:
Dimo Karaivanov 2023-07-28 21:23:24 +03:00 committed by sspanak
parent 49eda37b99
commit 005683bb7e

View file

@ -300,12 +300,7 @@ public class TraditionalT9 extends KeyPadHandler {
return performOKAction(); return performOKAction();
} }
String word = suggestionBar.getCurrentSuggestion(); acceptCurrentSuggestion(KeyEvent.KEYCODE_ENTER);
mInputMode.onAcceptSuggestion(word);
commitCurrentSuggestion();
autoCorrectSpace(word, true, KeyEvent.KEYCODE_ENTER);
resetKeyRepeat();
return true; return true;
} }
@ -504,11 +499,15 @@ public class TraditionalT9 extends KeyPadHandler {
private boolean scheduleAutoAccept(int delay) { private boolean scheduleAutoAccept(int delay) {
cancelAutoAccept(); cancelAutoAccept();
if (!suggestionBar.hasElements()) {
return false;
}
if (delay == 0) { if (delay == 0) {
this.onOK(); this.acceptCurrentSuggestion();
return true; return true;
} else if (delay > 0) { } else if (delay > 0) {
autoAcceptHandler.postDelayed(this::autoAccept, delay); autoAcceptHandler.postDelayed(this::acceptCurrentSuggestion, delay);
} }
return false; return false;
@ -520,10 +519,20 @@ public class TraditionalT9 extends KeyPadHandler {
} }
private void autoAccept() { private void acceptCurrentSuggestion(int fromKey) {
if (suggestionBar.hasElements()) { String word = suggestionBar.getCurrentSuggestion();
this.onOK(); if (word.isEmpty()) {
return;
} }
mInputMode.onAcceptSuggestion(word);
commitCurrentSuggestion();
autoCorrectSpace(word, true, fromKey);
resetKeyRepeat();
}
private void acceptCurrentSuggestion() {
acceptCurrentSuggestion(-1);
} }
@ -798,6 +807,7 @@ public class TraditionalT9 extends KeyPadHandler {
if (mInputMode.isPassthrough() || isInputViewShown()) { if (mInputMode.isPassthrough() || isInputViewShown()) {
return; return;
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
requestShowSelf(InputMethodManager.SHOW_IMPLICIT); requestShowSelf(InputMethodManager.SHOW_IMPLICIT);
} else { } else {