1
0
Fork 0

Predictive Mode: fixed the text case seemingly not changing in some cases

This commit is contained in:
Dimo Karaivanov 2022-12-09 11:53:54 +02:00 committed by sspanak
parent 6fed5b69d6
commit 55211b9cd9
3 changed files with 21 additions and 6 deletions

View file

@ -469,13 +469,24 @@ public class TraditionalT9 extends KeyPadHandler {
}
// when typing a word or viewing scrolling the suggestions, only change the case
else if (!isSuggestionViewHidden()) {
mInputMode.nextTextCase();
setSuggestions(mInputMode.getSuggestions(mLanguage), mSuggestionView.getCurrentIndex());
refreshComposingText();
String currentSuggestionBefore = getComposingText();
// When we are in AUTO mode and the dictionary word is in uppercase,
// the mode would switch to UPPERCASE, but visually, the word would not change.
// This is why we retry, until there is a visual change.
for (int retries = 0; retries < 2; retries ++) {
mInputMode.nextTextCase();
setSuggestions(mInputMode.getSuggestions(mLanguage), mSuggestionView.getCurrentIndex());
refreshComposingText();
if (!currentSuggestionBefore.equals(getComposingText())) {
break;
}
}
}
// make "abc" and "ABC" separate modes from user perspective
else if (mInputMode.isABC() && mInputMode.getTextCase() == InputMode.CASE_LOWER) {
mInputMode.setTextCase(InputMode.CASE_UPPER);
mInputMode.nextTextCase();
} else {
int modeIndex = (allowedInputModes.indexOf(mInputMode.getId()) + 1) % allowedInputModes.size();
mInputMode = InputMode.getInstance(settings, allowedInputModes.get(modeIndex));

View file

@ -102,8 +102,6 @@ abstract public class InputMode {
}
public void nextTextCase() {
textFieldTextCase = CASE_UNDEFINED; // since it's a user's choice, the default matters no more
int nextIndex = (allowedTextCases.indexOf(textCase) + 1) % allowedTextCases.size();
textCase = allowedTextCases.get(nextIndex);
}

View file

@ -550,6 +550,12 @@ public class ModePredictive extends InputMode {
}
@Override
public void nextTextCase() {
textFieldTextCase = CASE_UNDEFINED; // since it's a user's choice, the default matters no more
super.nextTextCase();
}
@Override final public boolean isPredictive() { return true; }
@Override public int getSequenceLength() { return digitSequence.length(); }
@Override public boolean shouldTrackUpDown() { return true; }