1
0
Fork 0

fixed the on-screen Shift icon alternating between 'on' and 'off' when typing punctuation or when accepting a word

This commit is contained in:
sspanak 2025-06-04 17:46:34 +03:00 committed by Dimo Karaivanov
parent c9e5573b58
commit 8261804bf8
3 changed files with 16 additions and 12 deletions

View file

@ -150,18 +150,11 @@ public abstract class TypingHandler extends KeyPadHandler {
mInputMode.reset();
}
setStatusIcon(mInputMode, mLanguage);
if (!mainView.isTextEditingPaletteShown() && !mainView.isCommandPaletteShown()) {
statusBar.setText(mInputMode);
}
}
// this updates Shift and Filter, so we can't do it only when recomposing
if (settings.isMainLayoutNumpad()) {
mainView.renderKeys();
}
return true;
}

View file

@ -2,6 +2,8 @@ package io.github.sspanak.tt9.ime;
import android.view.inputmethod.InputMethodManager;
import androidx.annotation.Nullable;
import io.github.sspanak.tt9.ime.modes.InputMode;
import io.github.sspanak.tt9.languages.Language;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
@ -56,7 +58,7 @@ abstract class UiHandler extends AbstractHandler {
}
public int getDisplayTextCase(Language language, int modeTextCase) {
public int getDisplayTextCase(@Nullable Language language, int modeTextCase) {
boolean hasUpperCase = language != null && language.hasUpperCase();
if (!hasUpperCase) {
return InputMode.CASE_UNDEFINED;
@ -66,13 +68,19 @@ abstract class UiHandler extends AbstractHandler {
return InputMode.CASE_UPPER;
}
int wordTextCase = new Text(language, getSuggestionOps().getCurrent()).getTextCase();
Text currentWord = new Text(language, getSuggestionOps().getCurrent());
if (currentWord.isEmpty() || !currentWord.isAlphabetic()) {
return modeTextCase;
}
int wordTextCase = currentWord.getTextCase();
return wordTextCase == InputMode.CASE_UPPER ? InputMode.CASE_CAPITALIZE : wordTextCase;
}
protected void setStatusIcon(InputMode mode, Language language) {
int resId = new StatusIcon(settings, mode, language, getDisplayTextCase(language, mode.getTextCase())).resourceId;
protected void setStatusIcon(@Nullable InputMode mode, @Nullable Language language) {
int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
if (resId == 0) {
hideStatusIcon();
} else {

View file

@ -355,7 +355,10 @@ class ModeWords extends ModeCheonjiin {
@Override
public int getTextCase() {
// Filter out the internally used text cases. They have no meaning outside this class.
return (textCase == CASE_UPPER || textCase == CASE_LOWER) ? textCase : CASE_CAPITALIZE;
return switch (textCase) {
case CASE_UPPER, CASE_LOWER -> textCase;
default -> seq.isAnySpecialCharSequence(digitSequence) ? CASE_LOWER : CASE_CAPITALIZE;
};
}