Skip to content

Commit

Permalink
fixed a regression with holding keys to type a number was not working…
Browse files Browse the repository at this point in the history
… in Predictive Mode
  • Loading branch information
sspanak committed Jun 1, 2023
1 parent 209a226 commit 2b4e57f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/io/github/sspanak/tt9/ime/TraditionalT9.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand All @@ -503,6 +499,13 @@ private void cancelAutoAccept() {
}


private void autoAccept() {
if (suggestionBar.hasElements()) {
this.onOK();
}
}


private String acceptIncompleteSuggestion() {
String currentWord = getComposingText();
mInputMode.onAcceptSuggestion(currentWord);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2b4e57f

Please sign in to comment.