1
0
Fork 0

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

This commit is contained in:
sspanak 2025-06-25 11:22:51 +03:00 committed by Dimo Karaivanov
parent 1a8e34461c
commit c30c2a3109
5 changed files with 27 additions and 10 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)) {
if (!mInputMode.nextTextCase(currentWord, statusBar.getText())) {
return false;
}

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) {
public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) {
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) { return false; }
@Override public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) { return false; }
@Override

View file

@ -383,20 +383,31 @@ class ModeWords extends ModeCheonjiin {
}
@Override
public boolean nextTextCase(@Nullable String currentWord) {
if (currentWord == null || currentWord.isEmpty() || (currentWord.length() == 1 && !Character.isAlphabetic(currentWord.charAt(0)))) {
public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) {
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();
} else {
}
// 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 {
textCase = new Text(language, currentWord).getTextCase();
}
// Skip capitalized text for words like: 've, 's, 'll, etc... only allow upper and lower cases.
boolean changed = super.nextTextCase(currentWord);
// do not capitalize words like: 've, 's, 'll, etc, only allow upper and lower cases.
boolean changed = super.nextTextCase(currentWord, statusBarText);
if (textCase != CASE_LOWER && textCase != CASE_UPPER && currentWord != null && currentWord.length() > 1 && !Character.isAlphabetic(currentWord.charAt(0))) {
changed = super.nextTextCase(currentWord);
changed = super.nextTextCase(currentWord, statusBarText);
}
// since it's a user's choice, the default matters no more
// since the user made an explicit choice, the app default matters no more
textFieldTextCase = changed ? CASE_UNDEFINED : textFieldTextCase;
return changed;

View file

@ -35,6 +35,12 @@ public class StatusBar {
}
@Nullable
public String getText() {
return statusText;
}
public boolean isErrorShown() {
return statusText != null && statusText.startsWith("");
}