restricted the text case changes at the beginning of a line, before typing anything, when 'Automatic Capital Letters after a Newline' option is on
This commit is contained in:
parent
5f459ee3dd
commit
ee19f08b43
4 changed files with 20 additions and 9 deletions
|
|
@ -209,13 +209,13 @@ abstract public class CommandHandler extends TextEditingHandler {
|
||||||
|
|
||||||
|
|
||||||
protected boolean nextTextCase() {
|
protected boolean nextTextCase() {
|
||||||
if (!mInputMode.nextTextCase()) {
|
if (!mInputMode.nextTextCase(true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 currentWord = suggestionOps.isEmpty() || mInputMode.getSequence().isEmpty() ? "" : suggestionOps.getCurrent();
|
||||||
if (before.isEmpty() || !Character.isAlphabetic(before.charAt(0))) {
|
if (currentWord.isEmpty() || !Character.isAlphabetic(currentWord.charAt(0))) {
|
||||||
settings.saveTextCase(mInputMode.getTextCase());
|
settings.saveTextCase(mInputMode.getTextCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -227,7 +227,7 @@ abstract public class CommandHandler extends TextEditingHandler {
|
||||||
currentSuggestionIndex = suggestionOps.containsStem() ? currentSuggestionIndex - 1 : currentSuggestionIndex;
|
currentSuggestionIndex = suggestionOps.containsStem() ? currentSuggestionIndex - 1 : currentSuggestionIndex;
|
||||||
|
|
||||||
for (int retries = 0; retries <= 2; retries++) {
|
for (int retries = 0; retries <= 2; retries++) {
|
||||||
if (!before.equals(mInputMode.getSuggestions().get(currentSuggestionIndex)) || !mInputMode.nextTextCase()) {
|
if (!currentWord.equals(mInputMode.getSuggestions().get(currentSuggestionIndex)) || !mInputMode.nextTextCase(false)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,12 @@ abstract public class InputMode {
|
||||||
textCase = allowedTextCases.get(0);
|
textCase = allowedTextCases.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean nextTextCase() {
|
/**
|
||||||
|
* Switches to the next available text case. Returns "false" when the language has no upper case.
|
||||||
|
* 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(boolean analyzeSurroundingText) {
|
||||||
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() { return false; }
|
@Override public boolean nextTextCase(boolean analyzeSurroundingText) { return false; }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -381,10 +381,16 @@ class ModeWords extends ModeCheonjiin {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean nextTextCase() {
|
public boolean nextTextCase(boolean analyzeSurroundingText) {
|
||||||
boolean changed = super.nextTextCase();
|
boolean changed = super.nextTextCase(analyzeSurroundingText);
|
||||||
|
|
||||||
|
// Prevent lowercase at the beginning of a line when the respective setting is enabled.
|
||||||
|
// "analyzeSurroundingText" is true only when Shift is pressed to avoid expensive
|
||||||
|
// calls to getStringBeforeCursor().
|
||||||
|
if (analyzeSurroundingText && textCase == CASE_LOWER && language.hasUpperCase() && settings.getAutoCapitalsAfterNewline() && textField.getStringBeforeCursor(1).equals("\n")) {
|
||||||
|
changed = super.nextTextCase(analyzeSurroundingText);
|
||||||
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue