1
0
Fork 0

removed all restrictions for switching to lowercase in Predictive mode when the Automatic Capitalization option is on

This commit is contained in:
sspanak 2025-06-10 19:13:16 +03:00 committed by Dimo Karaivanov
parent 7e43bcc114
commit 9c63e66a1d
5 changed files with 15 additions and 25 deletions

View file

@ -218,8 +218,7 @@ abstract public class CommandHandler extends TextEditingHandler {
// if there are no suggestions or they are special chars, we don't need to adjust their text case
final String before = suggestionOps.isEmpty() || mInputMode.getSequence().isEmpty() ? "" : suggestionOps.getCurrent();
final boolean beforeStartsWithLetter = !before.isEmpty() && Character.isAlphabetic(before.charAt(0));
if (!beforeStartsWithLetter) {
if (before.isEmpty() || !Character.isAlphabetic(before.charAt(0))) {
settings.saveTextCase(mInputMode.getTextCase());
return true;
}

View file

@ -24,6 +24,7 @@ import io.github.sspanak.tt9.languages.LanguageCollection;
import io.github.sspanak.tt9.languages.LanguageKind;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
import io.github.sspanak.tt9.ui.UI;
import io.github.sspanak.tt9.util.Text;
public abstract class TypingHandler extends KeyPadHandler {
// internal settings/data
@ -437,9 +438,11 @@ public abstract class TypingHandler extends KeyPadHandler {
String trimmedWord = suggestionOps.getCurrent(mLanguage, mInputMode.getSequenceLength());
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
setStatusIcon(mInputMode, mLanguage);
if (settings.isMainLayoutNumpad()) {
mainView.renderKeys();
if (new Text(suggestionOps.getCurrent()).isAlphabetic()) {
setStatusIcon(mInputMode, mLanguage);
if (settings.isMainLayoutNumpad()) {
mainView.renderKeys();
}
}
forceShowWindow();

View file

@ -79,8 +79,8 @@ abstract class UiHandler extends AbstractHandler {
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;
final int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
final int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
if (resId == 0) {
hideStatusIcon();
} else {

View file

@ -362,29 +362,17 @@ class ModeWords extends ModeCheonjiin {
public int getTextCase() {
// Filter out the internally used text cases. They have no meaning outside this class.
return switch (textCase) {
case CASE_UPPER, CASE_LOWER -> textCase;
default -> seq.isAnySpecialCharSequence(digitSequence) ? CASE_LOWER : CASE_CAPITALIZE;
case CASE_UPPER, CASE_CAPITALIZE -> textCase;
case CASE_DICTIONARY -> CASE_CAPITALIZE;
default -> CASE_LOWER;
};
}
@Override
public boolean nextTextCase() {
int before = textCase;
boolean changed = super.nextTextCase();
// When we are in AUTO mode and current 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.
// Yet, we allow adjusting individual words to lowercase, if needed.
if (digitSequence.isEmpty() && settings.getAutoTextCase() && language.hasUpperCase() && (before == CASE_LOWER || textCase == CASE_LOWER)) {
changed = super.nextTextCase();
}
if (seq.startsWithAnySpecialCharSequence(digitSequence) && textCase == CASE_CAPITALIZE) {
super.nextTextCase();
}
// since it's a user's choice, the default matters no more
textFieldTextCase = changed ? CASE_UNDEFINED : textFieldTextCase;
@ -494,7 +482,7 @@ class ModeWords extends ModeCheonjiin {
String modeString = language.getName();
if (textCase == CASE_UPPER) {
return modeString.toUpperCase(language.getLocale());
} else if (textCase == CASE_LOWER && !settings.getAutoTextCase()) {
} else if (textCase == CASE_LOWER) {
return modeString.toLowerCase(language.getLocale());
} else {
return modeString;

View file

@ -51,8 +51,8 @@ public class AutoTextCase {
if (
// When the setting is off, don't do any changes.
!settings.getAutoTextCase()
// If the user wants to type in uppercase, this must be for a reason, so we better not override it.
|| currentTextCase == InputMode.CASE_UPPER
// If the user has explicitly selected a text case, we respect that.
|| currentTextCase == InputMode.CASE_UPPER || currentTextCase == InputMode.CASE_LOWER
// we do not have text fields that expect sentences, so disable the feature to save some resources
|| isUs
) {