1
0
Fork 0

fixed the text case cycle order when the current word is a special character again

This commit is contained in:
sspanak 2025-06-26 17:44:06 +03:00 committed by Dimo Karaivanov
parent c30c2a3109
commit 24013c9207
5 changed files with 17 additions and 18 deletions

View file

@ -211,7 +211,7 @@ abstract public class CommandHandler extends TextEditingHandler {
protected boolean nextTextCase() {
final String currentWord = suggestionOps.isEmpty() || mInputMode.getSequence().isEmpty() ? "" : suggestionOps.getCurrent();
if (!mInputMode.nextTextCase(currentWord, statusBar.getText())) {
if (!mInputMode.nextTextCase(currentWord, statusIconTextCase)) {
return false;
}

View file

@ -15,6 +15,7 @@ import io.github.sspanak.tt9.util.sys.DeviceInfo;
import io.github.sspanak.tt9.util.sys.SystemSettings;
abstract class UiHandler extends AbstractHandler {
protected int statusIconTextCase = InputMode.CASE_UNDEFINED;
protected SettingsStore settings;
protected ResizableMainView mainView = null;
protected StatusBar statusBar = null;
@ -83,8 +84,8 @@ abstract class UiHandler extends AbstractHandler {
return;
}
final int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
final int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
statusIconTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
final int resId = new StatusIcon(settings, mode, language, statusIconTextCase).resourceId;
if (resId == 0) {
hideStatusIcon();
} else {

View file

@ -206,7 +206,7 @@ abstract public class InputMode {
* If "analyzeSurroundingText" is true, and when the mode supports text analyzing, it may apply
* additional logic to determine the next valid text case.
*/
public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) {
public boolean nextTextCase(@Nullable String currentWord, int displayTextCase) {
if (!language.hasUpperCase()) {
return false;
}

View file

@ -30,7 +30,7 @@ public class ModeIdeograms extends ModeWords {
@Override protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
@Override public void determineNextWordTextCase(int nextDigit) {}
@Override public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) { return false; }
@Override public boolean nextTextCase(@Nullable String currentWord, int displayTextCase) { return false; }
@Override

View file

@ -383,28 +383,26 @@ class ModeWords extends ModeCheonjiin {
}
@Override
public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) {
public boolean nextTextCase(@Nullable String currentWord, int displayTextCase) {
if (!language.hasUpperCase()) {
return false;
}
// if the user is typing, assume the text case of the current word
if (currentWord == null || currentWord.isEmpty()) {
textCase = getTextCase();
}
// if not typing, assume the displayed text case
else if (statusBarText != null && !statusBarText.isEmpty() && currentWord.length() == 1 && !Character.isAlphabetic(currentWord.charAt(0))) {
textCase = new Text(language, statusBarText).getTextCase();
}
// ... or fallback to the mode text case
else {
boolean isTyping = currentWord != null && !currentWord.isEmpty();
boolean isTyingSpecialChar = isTyping && currentWord.length() == 1 && !Character.isAlphabetic(currentWord.charAt(0));
if (isTyingSpecialChar) {
textCase = displayTextCase;
} else if (isTyping) {
textCase = new Text(language, currentWord).getTextCase();
} else {
textCase = getTextCase();
}
// do not capitalize words like: 've, 's, 'll, etc, only allow upper and lower cases.
boolean changed = super.nextTextCase(currentWord, statusBarText);
boolean changed = super.nextTextCase(currentWord, displayTextCase);
if (textCase != CASE_LOWER && textCase != CASE_UPPER && currentWord != null && currentWord.length() > 1 && !Character.isAlphabetic(currentWord.charAt(0))) {
changed = super.nextTextCase(currentWord, statusBarText);
changed = super.nextTextCase(currentWord, displayTextCase);
}
// since the user made an explicit choice, the app default matters no more