Skip to content

Commit

Permalink
fixed auto-accepting causig MainView to hide unexpectedly when changi…
Browse files Browse the repository at this point in the history
…ng the input mode (#324)
  • Loading branch information
sspanak committed Jul 28, 2023
1 parent 49eda37 commit 005683b
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/io/github/sspanak/tt9/ime/TraditionalT9.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,7 @@ public boolean onOK() {
return performOKAction();
}

String word = suggestionBar.getCurrentSuggestion();

mInputMode.onAcceptSuggestion(word);
commitCurrentSuggestion();
autoCorrectSpace(word, true, KeyEvent.KEYCODE_ENTER);
resetKeyRepeat();
acceptCurrentSuggestion(KeyEvent.KEYCODE_ENTER);

return true;
}
Expand Down Expand Up @@ -504,11 +499,15 @@ private boolean nextSuggestion() {
private boolean scheduleAutoAccept(int delay) {
cancelAutoAccept();

if (!suggestionBar.hasElements()) {
return false;
}

if (delay == 0) {
this.onOK();
this.acceptCurrentSuggestion();
return true;
} else if (delay > 0) {
autoAcceptHandler.postDelayed(this::autoAccept, delay);
autoAcceptHandler.postDelayed(this::acceptCurrentSuggestion, delay);
}

return false;
Expand All @@ -520,10 +519,20 @@ private void cancelAutoAccept() {
}


private void autoAccept() {
if (suggestionBar.hasElements()) {
this.onOK();
private void acceptCurrentSuggestion(int fromKey) {
String word = suggestionBar.getCurrentSuggestion();
if (word.isEmpty()) {
return;
}

mInputMode.onAcceptSuggestion(word);
commitCurrentSuggestion();
autoCorrectSpace(word, true, fromKey);
resetKeyRepeat();
}

private void acceptCurrentSuggestion() {
acceptCurrentSuggestion(-1);
}


Expand Down Expand Up @@ -798,6 +807,7 @@ protected void forceShowWindowIfHidden() {
if (mInputMode.isPassthrough() || isInputViewShown()) {
return;
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
requestShowSelf(InputMethodManager.SHOW_IMPLICIT);
} else {
Expand Down

0 comments on commit 005683b

Please sign in to comment.