diff --git a/src/io/github/sspanak/tt9/ime/TraditionalT9.java b/src/io/github/sspanak/tt9/ime/TraditionalT9.java index a49e5524b..aeedda553 100644 --- a/src/io/github/sspanak/tt9/ime/TraditionalT9.java +++ b/src/io/github/sspanak/tt9/ime/TraditionalT9.java @@ -345,7 +345,7 @@ protected boolean onNumber(int key, boolean hold, int repeat) { if (mInputMode.shouldSelectNextSuggestion() && !isSuggestionViewHidden()) { nextSuggestion(); - autoAcceptCurrentSuggestion(mInputMode.getAutoAcceptTimeout()); + scheduleAutoAccept(mInputMode.getAutoAcceptTimeout()); } else { getSuggestions(); } @@ -418,7 +418,7 @@ public boolean onKeyNextLanguage() { public boolean onKeyNextInputMode() { - autoAcceptCurrentSuggestion(mInputMode.getAutoAcceptTimeout()); // reset the auto-accept timer + scheduleAutoAccept(mInputMode.getAutoAcceptTimeout()); // restart the timer nextInputMode(); mainView.render(); @@ -480,18 +480,14 @@ private boolean nextSuggestion() { } - private boolean autoAcceptCurrentSuggestion(int delay) { + private boolean scheduleAutoAccept(int delay) { cancelAutoAccept(); - if (getComposingText().equals("")) { - return false; - } - if (delay == 0) { this.onOK(); return true; } else if (delay > 0) { - autoAcceptHandler.postDelayed(this::onOK, delay); + autoAcceptHandler.postDelayed(this::autoAccept, delay); } return false; @@ -503,6 +499,13 @@ private void cancelAutoAccept() { } + private void autoAccept() { + if (suggestionBar.hasElements()) { + this.onOK(); + } + } + + private String acceptIncompleteSuggestion() { String currentWord = getComposingText(); mInputMode.onAcceptSuggestion(currentWord); @@ -555,7 +558,7 @@ private void handleSuggestions() { setSuggestions(mInputMode.getSuggestions()); // flush the first suggestion, if the InputMode has requested it - if (autoAcceptCurrentSuggestion(mInputMode.getAutoAcceptTimeout())) { + if (scheduleAutoAccept(mInputMode.getAutoAcceptTimeout())) { return; }