fixed suggestion bar flashing without debouncing hacks
This commit is contained in:
parent
fed5ee10da
commit
4220bda614
3 changed files with 23 additions and 10 deletions
|
|
@ -131,7 +131,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
if (repeat == 0 && mInputMode.onBackspace()) {
|
||||
getSuggestions(null);
|
||||
} else {
|
||||
suggestionOps.commitCurrent(false);
|
||||
suggestionOps.commitCurrent(false, true);
|
||||
mInputMode.reset();
|
||||
deleteText(settings.getBackspaceAcceleration() && repeat > 0);
|
||||
}
|
||||
|
|
@ -171,15 +171,18 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
// Automatically accept the previous word, when the next one is a space or punctuation,
|
||||
// instead of requiring "OK" before that.
|
||||
// First pass, analyze the incoming key press and decide whether it could be the start of
|
||||
// a new word.
|
||||
// a new word. In case we do accept it, we preserve the suggestion list instead of clearing,
|
||||
// to prevent flashing while the next suggestions are being loaded.
|
||||
else if (mInputMode.shouldAcceptPreviousSuggestion(key, hold)) {
|
||||
String lastWord = suggestionOps.acceptIncomplete();
|
||||
// WARNING! Ensure the code after "acceptIncompleteAndKeepList()" does not depend on
|
||||
// the suggestions in SuggestionOps, since we don't clear that list.
|
||||
String lastWord = suggestionOps.acceptIncompleteAndKeepList();
|
||||
mInputMode.onAcceptSuggestion(lastWord);
|
||||
autoCorrectSpace(lastWord, false, key);
|
||||
}
|
||||
|
||||
// Auto-adjust the text case before each word, if the InputMode supports it.
|
||||
if (suggestionOps.getCurrent().isEmpty()) {
|
||||
if (mInputMode.getSuggestions().isEmpty()) {
|
||||
mInputMode.determineNextWordTextCase();
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +191,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (mInputMode.shouldSelectNextSuggestion() && !suggestionOps.isEmpty()) {
|
||||
if (mInputMode.shouldSelectNextSuggestion() && !mInputMode.getSuggestions().isEmpty()) {
|
||||
scrollSuggestions(false);
|
||||
suggestionOps.scheduleDelayedAccept(mInputMode.getAutoAcceptTimeout());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class SuggestionOps {
|
|||
public String acceptCurrent() {
|
||||
String word = getCurrent();
|
||||
if (!word.isEmpty()) {
|
||||
commitCurrent(true);
|
||||
commitCurrent(true, true);
|
||||
}
|
||||
|
||||
return word;
|
||||
|
|
@ -106,24 +106,30 @@ public class SuggestionOps {
|
|||
|
||||
public String acceptIncomplete() {
|
||||
String currentWord = this.getCurrent();
|
||||
commitCurrent(false);
|
||||
commitCurrent(false, true);
|
||||
|
||||
return currentWord;
|
||||
}
|
||||
|
||||
|
||||
public String acceptIncompleteAndKeepList() {
|
||||
commitCurrent(false, false);
|
||||
return this.getCurrent();
|
||||
}
|
||||
|
||||
|
||||
public String acceptPrevious(Language language, int sequenceLength) {
|
||||
if (sequenceLength <= 0) {
|
||||
set(null);
|
||||
}
|
||||
|
||||
String lastComposingText = getCurrent(language, sequenceLength - 1);
|
||||
commitCurrent(false);
|
||||
commitCurrent(false, true);
|
||||
return lastComposingText;
|
||||
}
|
||||
|
||||
|
||||
public void commitCurrent(boolean entireSuggestion) {
|
||||
public void commitCurrent(boolean entireSuggestion, boolean clearList) {
|
||||
if (!isEmpty()) {
|
||||
if (entireSuggestion) {
|
||||
textField.setComposingText(getCurrent());
|
||||
|
|
@ -131,7 +137,10 @@ public class SuggestionOps {
|
|||
textField.finishComposingText();
|
||||
}
|
||||
|
||||
set(null);
|
||||
|
||||
if (clearList) {
|
||||
set(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ abstract public class InputMode {
|
|||
onSuggestionsUpdated.run();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ArrayList<String> getSuggestions() {
|
||||
ArrayList<String> newSuggestions = new ArrayList<>();
|
||||
for (String s : suggestions) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue