fixed the text case cycle order when the current word is a special character again
This commit is contained in:
parent
c30c2a3109
commit
24013c9207
5 changed files with 17 additions and 18 deletions
|
|
@ -211,7 +211,7 @@ abstract public class CommandHandler extends TextEditingHandler {
|
||||||
protected boolean nextTextCase() {
|
protected boolean nextTextCase() {
|
||||||
final String currentWord = suggestionOps.isEmpty() || mInputMode.getSequence().isEmpty() ? "" : suggestionOps.getCurrent();
|
final String currentWord = suggestionOps.isEmpty() || mInputMode.getSequence().isEmpty() ? "" : suggestionOps.getCurrent();
|
||||||
|
|
||||||
if (!mInputMode.nextTextCase(currentWord, statusBar.getText())) {
|
if (!mInputMode.nextTextCase(currentWord, statusIconTextCase)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import io.github.sspanak.tt9.util.sys.DeviceInfo;
|
||||||
import io.github.sspanak.tt9.util.sys.SystemSettings;
|
import io.github.sspanak.tt9.util.sys.SystemSettings;
|
||||||
|
|
||||||
abstract class UiHandler extends AbstractHandler {
|
abstract class UiHandler extends AbstractHandler {
|
||||||
|
protected int statusIconTextCase = InputMode.CASE_UNDEFINED;
|
||||||
protected SettingsStore settings;
|
protected SettingsStore settings;
|
||||||
protected ResizableMainView mainView = null;
|
protected ResizableMainView mainView = null;
|
||||||
protected StatusBar statusBar = null;
|
protected StatusBar statusBar = null;
|
||||||
|
|
@ -83,8 +84,8 @@ abstract class UiHandler extends AbstractHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
|
statusIconTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
|
||||||
final int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
|
final int resId = new StatusIcon(settings, mode, language, statusIconTextCase).resourceId;
|
||||||
if (resId == 0) {
|
if (resId == 0) {
|
||||||
hideStatusIcon();
|
hideStatusIcon();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ abstract public class InputMode {
|
||||||
* If "analyzeSurroundingText" is true, and when the mode supports text analyzing, it may apply
|
* If "analyzeSurroundingText" is true, and when the mode supports text analyzing, it may apply
|
||||||
* additional logic to determine the next valid text case.
|
* 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()) {
|
if (!language.hasUpperCase()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class ModeIdeograms extends ModeWords {
|
||||||
|
|
||||||
@Override protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
@Override protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
||||||
@Override public void determineNextWordTextCase(int nextDigit) {}
|
@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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -383,28 +383,26 @@ class ModeWords extends ModeCheonjiin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean nextTextCase(@Nullable String currentWord, @Nullable String statusBarText) {
|
public boolean nextTextCase(@Nullable String currentWord, int displayTextCase) {
|
||||||
if (!language.hasUpperCase()) {
|
if (!language.hasUpperCase()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the user is typing, assume the text case of the current word
|
boolean isTyping = currentWord != null && !currentWord.isEmpty();
|
||||||
if (currentWord == null || currentWord.isEmpty()) {
|
boolean isTyingSpecialChar = isTyping && currentWord.length() == 1 && !Character.isAlphabetic(currentWord.charAt(0));
|
||||||
textCase = getTextCase();
|
|
||||||
}
|
if (isTyingSpecialChar) {
|
||||||
// if not typing, assume the displayed text case
|
textCase = displayTextCase;
|
||||||
else if (statusBarText != null && !statusBarText.isEmpty() && currentWord.length() == 1 && !Character.isAlphabetic(currentWord.charAt(0))) {
|
} else if (isTyping) {
|
||||||
textCase = new Text(language, statusBarText).getTextCase();
|
|
||||||
}
|
|
||||||
// ... or fallback to the mode text case
|
|
||||||
else {
|
|
||||||
textCase = new Text(language, currentWord).getTextCase();
|
textCase = new Text(language, currentWord).getTextCase();
|
||||||
|
} else {
|
||||||
|
textCase = getTextCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not capitalize words like: 've, 's, 'll, etc, only allow upper and lower cases.
|
// 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))) {
|
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
|
// since the user made an explicit choice, the app default matters no more
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue