From 55211b9cd9690f8c27db1e6e153b672fd118fae2 Mon Sep 17 00:00:00 2001 From: Dimo Karaivanov Date: Fri, 9 Dec 2022 11:53:54 +0200 Subject: [PATCH] Predictive Mode: fixed the text case seemingly not changing in some cases --- .../github/sspanak/tt9/ime/TraditionalT9.java | 19 +++++++++++++++---- .../sspanak/tt9/ime/modes/InputMode.java | 2 -- .../sspanak/tt9/ime/modes/ModePredictive.java | 6 ++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/io/github/sspanak/tt9/ime/TraditionalT9.java b/src/io/github/sspanak/tt9/ime/TraditionalT9.java index 40603772..b1bc5965 100644 --- a/src/io/github/sspanak/tt9/ime/TraditionalT9.java +++ b/src/io/github/sspanak/tt9/ime/TraditionalT9.java @@ -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)); diff --git a/src/io/github/sspanak/tt9/ime/modes/InputMode.java b/src/io/github/sspanak/tt9/ime/modes/InputMode.java index 035d57e7..99e11671 100644 --- a/src/io/github/sspanak/tt9/ime/modes/InputMode.java +++ b/src/io/github/sspanak/tt9/ime/modes/InputMode.java @@ -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); } diff --git a/src/io/github/sspanak/tt9/ime/modes/ModePredictive.java b/src/io/github/sspanak/tt9/ime/modes/ModePredictive.java index 678797ce..498171e8 100644 --- a/src/io/github/sspanak/tt9/ime/modes/ModePredictive.java +++ b/src/io/github/sspanak/tt9/ime/modes/ModePredictive.java @@ -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; }