removed all restrictions for switching to lowercase in Predictive mode when the Automatic Capitalization option is on
This commit is contained in:
parent
7e43bcc114
commit
9c63e66a1d
5 changed files with 15 additions and 25 deletions
|
|
@ -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
|
// 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 String before = suggestionOps.isEmpty() || mInputMode.getSequence().isEmpty() ? "" : suggestionOps.getCurrent();
|
||||||
final boolean beforeStartsWithLetter = !before.isEmpty() && Character.isAlphabetic(before.charAt(0));
|
if (before.isEmpty() || !Character.isAlphabetic(before.charAt(0))) {
|
||||||
if (!beforeStartsWithLetter) {
|
|
||||||
settings.saveTextCase(mInputMode.getTextCase());
|
settings.saveTextCase(mInputMode.getTextCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import io.github.sspanak.tt9.languages.LanguageCollection;
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.ui.UI;
|
import io.github.sspanak.tt9.ui.UI;
|
||||||
|
import io.github.sspanak.tt9.util.Text;
|
||||||
|
|
||||||
public abstract class TypingHandler extends KeyPadHandler {
|
public abstract class TypingHandler extends KeyPadHandler {
|
||||||
// internal settings/data
|
// internal settings/data
|
||||||
|
|
@ -437,9 +438,11 @@ public abstract class TypingHandler extends KeyPadHandler {
|
||||||
String trimmedWord = suggestionOps.getCurrent(mLanguage, mInputMode.getSequenceLength());
|
String trimmedWord = suggestionOps.getCurrent(mLanguage, mInputMode.getSequenceLength());
|
||||||
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
|
appHacks.setComposingTextWithHighlightedStem(trimmedWord, mInputMode);
|
||||||
|
|
||||||
setStatusIcon(mInputMode, mLanguage);
|
if (new Text(suggestionOps.getCurrent()).isAlphabetic()) {
|
||||||
if (settings.isMainLayoutNumpad()) {
|
setStatusIcon(mInputMode, mLanguage);
|
||||||
mainView.renderKeys();
|
if (settings.isMainLayoutNumpad()) {
|
||||||
|
mainView.renderKeys();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forceShowWindow();
|
forceShowWindow();
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ abstract class UiHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
|
||||||
protected void setStatusIcon(@Nullable InputMode mode, @Nullable Language language) {
|
protected void setStatusIcon(@Nullable InputMode mode, @Nullable Language language) {
|
||||||
int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
|
final int displayTextCase = getDisplayTextCase(language, mode != null ? mode.getTextCase() : InputMode.CASE_UNDEFINED);
|
||||||
int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
|
final int resId = new StatusIcon(settings, mode, language, displayTextCase).resourceId;
|
||||||
if (resId == 0) {
|
if (resId == 0) {
|
||||||
hideStatusIcon();
|
hideStatusIcon();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -362,29 +362,17 @@ class ModeWords extends ModeCheonjiin {
|
||||||
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 switch (textCase) {
|
return switch (textCase) {
|
||||||
case CASE_UPPER, CASE_LOWER -> textCase;
|
case CASE_UPPER, CASE_CAPITALIZE -> textCase;
|
||||||
default -> seq.isAnySpecialCharSequence(digitSequence) ? CASE_LOWER : CASE_CAPITALIZE;
|
case CASE_DICTIONARY -> CASE_CAPITALIZE;
|
||||||
|
default -> CASE_LOWER;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean nextTextCase() {
|
public boolean nextTextCase() {
|
||||||
int before = textCase;
|
|
||||||
boolean changed = super.nextTextCase();
|
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
|
// since it's a user's choice, the default matters no more
|
||||||
textFieldTextCase = changed ? CASE_UNDEFINED : textFieldTextCase;
|
textFieldTextCase = changed ? CASE_UNDEFINED : textFieldTextCase;
|
||||||
|
|
||||||
|
|
@ -494,7 +482,7 @@ class ModeWords extends ModeCheonjiin {
|
||||||
String modeString = language.getName();
|
String modeString = language.getName();
|
||||||
if (textCase == CASE_UPPER) {
|
if (textCase == CASE_UPPER) {
|
||||||
return modeString.toUpperCase(language.getLocale());
|
return modeString.toUpperCase(language.getLocale());
|
||||||
} else if (textCase == CASE_LOWER && !settings.getAutoTextCase()) {
|
} else if (textCase == CASE_LOWER) {
|
||||||
return modeString.toLowerCase(language.getLocale());
|
return modeString.toLowerCase(language.getLocale());
|
||||||
} else {
|
} else {
|
||||||
return modeString;
|
return modeString;
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ public class AutoTextCase {
|
||||||
if (
|
if (
|
||||||
// When the setting is off, don't do any changes.
|
// When the setting is off, don't do any changes.
|
||||||
!settings.getAutoTextCase()
|
!settings.getAutoTextCase()
|
||||||
// If the user wants to type in uppercase, this must be for a reason, so we better not override it.
|
// If the user has explicitly selected a text case, we respect that.
|
||||||
|| currentTextCase == InputMode.CASE_UPPER
|
|| 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
|
// we do not have text fields that expect sentences, so disable the feature to save some resources
|
||||||
|| isUs
|
|| isUs
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue