fixed the on-screen Shift icon alternating between 'on' and 'off' when typing punctuation or when accepting a word
This commit is contained in:
parent
c9e5573b58
commit
8261804bf8
3 changed files with 16 additions and 12 deletions
|
|
@ -150,18 +150,11 @@ public abstract class TypingHandler extends KeyPadHandler {
|
||||||
mInputMode.reset();
|
mInputMode.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatusIcon(mInputMode, mLanguage);
|
|
||||||
|
|
||||||
if (!mainView.isTextEditingPaletteShown() && !mainView.isCommandPaletteShown()) {
|
if (!mainView.isTextEditingPaletteShown() && !mainView.isCommandPaletteShown()) {
|
||||||
statusBar.setText(mInputMode);
|
statusBar.setText(mInputMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this updates Shift and Filter, so we can't do it only when recomposing
|
|
||||||
if (settings.isMainLayoutNumpad()) {
|
|
||||||
mainView.renderKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package io.github.sspanak.tt9.ime;
|
||||||
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.ime.modes.InputMode;
|
import io.github.sspanak.tt9.ime.modes.InputMode;
|
||||||
import io.github.sspanak.tt9.languages.Language;
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
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();
|
boolean hasUpperCase = language != null && language.hasUpperCase();
|
||||||
if (!hasUpperCase) {
|
if (!hasUpperCase) {
|
||||||
return InputMode.CASE_UNDEFINED;
|
return InputMode.CASE_UNDEFINED;
|
||||||
|
|
@ -66,13 +68,19 @@ abstract class UiHandler extends AbstractHandler {
|
||||||
return InputMode.CASE_UPPER;
|
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;
|
return wordTextCase == InputMode.CASE_UPPER ? InputMode.CASE_CAPITALIZE : wordTextCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void setStatusIcon(InputMode mode, Language language) {
|
protected void setStatusIcon(@Nullable InputMode mode, @Nullable Language language) {
|
||||||
int resId = new StatusIcon(settings, mode, language, getDisplayTextCase(language, mode.getTextCase())).resourceId;
|
int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
|
||||||
|
int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
|
||||||
if (resId == 0) {
|
if (resId == 0) {
|
||||||
hideStatusIcon();
|
hideStatusIcon();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,10 @@ class ModeWords extends ModeCheonjiin {
|
||||||
@Override
|
@Override
|
||||||
public int getTextCase() {
|
public int getTextCase() {
|
||||||
// Filter out the internally used text cases. They have no meaning outside this class.
|
// 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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue