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()) {
|
if (repeat == 0 && mInputMode.onBackspace()) {
|
||||||
getSuggestions(null);
|
getSuggestions(null);
|
||||||
} else {
|
} else {
|
||||||
suggestionOps.commitCurrent(false);
|
suggestionOps.commitCurrent(false, true);
|
||||||
mInputMode.reset();
|
mInputMode.reset();
|
||||||
deleteText(settings.getBackspaceAcceleration() && repeat > 0);
|
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,
|
// Automatically accept the previous word, when the next one is a space or punctuation,
|
||||||
// instead of requiring "OK" before that.
|
// instead of requiring "OK" before that.
|
||||||
// First pass, analyze the incoming key press and decide whether it could be the start of
|
// 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)) {
|
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);
|
mInputMode.onAcceptSuggestion(lastWord);
|
||||||
autoCorrectSpace(lastWord, false, key);
|
autoCorrectSpace(lastWord, false, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-adjust the text case before each word, if the InputMode supports it.
|
// Auto-adjust the text case before each word, if the InputMode supports it.
|
||||||
if (suggestionOps.getCurrent().isEmpty()) {
|
if (mInputMode.getSuggestions().isEmpty()) {
|
||||||
mInputMode.determineNextWordTextCase();
|
mInputMode.determineNextWordTextCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +191,7 @@ public abstract class TypingHandler extends KeyPadHandler {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInputMode.shouldSelectNextSuggestion() && !suggestionOps.isEmpty()) {
|
if (mInputMode.shouldSelectNextSuggestion() && !mInputMode.getSuggestions().isEmpty()) {
|
||||||
scrollSuggestions(false);
|
scrollSuggestions(false);
|
||||||
suggestionOps.scheduleDelayedAccept(mInputMode.getAutoAcceptTimeout());
|
suggestionOps.scheduleDelayedAccept(mInputMode.getAutoAcceptTimeout());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public class SuggestionOps {
|
||||||
public String acceptCurrent() {
|
public String acceptCurrent() {
|
||||||
String word = getCurrent();
|
String word = getCurrent();
|
||||||
if (!word.isEmpty()) {
|
if (!word.isEmpty()) {
|
||||||
commitCurrent(true);
|
commitCurrent(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return word;
|
return word;
|
||||||
|
|
@ -106,24 +106,30 @@ public class SuggestionOps {
|
||||||
|
|
||||||
public String acceptIncomplete() {
|
public String acceptIncomplete() {
|
||||||
String currentWord = this.getCurrent();
|
String currentWord = this.getCurrent();
|
||||||
commitCurrent(false);
|
commitCurrent(false, true);
|
||||||
|
|
||||||
return currentWord;
|
return currentWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String acceptIncompleteAndKeepList() {
|
||||||
|
commitCurrent(false, false);
|
||||||
|
return this.getCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String acceptPrevious(Language language, int sequenceLength) {
|
public String acceptPrevious(Language language, int sequenceLength) {
|
||||||
if (sequenceLength <= 0) {
|
if (sequenceLength <= 0) {
|
||||||
set(null);
|
set(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
String lastComposingText = getCurrent(language, sequenceLength - 1);
|
String lastComposingText = getCurrent(language, sequenceLength - 1);
|
||||||
commitCurrent(false);
|
commitCurrent(false, true);
|
||||||
return lastComposingText;
|
return lastComposingText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void commitCurrent(boolean entireSuggestion) {
|
public void commitCurrent(boolean entireSuggestion, boolean clearList) {
|
||||||
if (!isEmpty()) {
|
if (!isEmpty()) {
|
||||||
if (entireSuggestion) {
|
if (entireSuggestion) {
|
||||||
textField.setComposingText(getCurrent());
|
textField.setComposingText(getCurrent());
|
||||||
|
|
@ -131,7 +137,10 @@ public class SuggestionOps {
|
||||||
textField.finishComposingText();
|
textField.finishComposingText();
|
||||||
}
|
}
|
||||||
|
|
||||||
set(null);
|
|
||||||
|
if (clearList) {
|
||||||
|
set(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ abstract public class InputMode {
|
||||||
onSuggestionsUpdated.run();
|
onSuggestionsUpdated.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public ArrayList<String> getSuggestions() {
|
public ArrayList<String> getSuggestions() {
|
||||||
ArrayList<String> newSuggestions = new ArrayList<>();
|
ArrayList<String> newSuggestions = new ArrayList<>();
|
||||||
for (String s : suggestions) {
|
for (String s : suggestions) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue