fixed character case switching issues (#443)
* fixed issues with switching the text case * fixed not possible to type currency characters in RTL languages
This commit is contained in:
parent
861b3856fd
commit
cd7215b6fc
5 changed files with 27 additions and 25 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest
|
<manifest
|
||||||
android:versionCode="381"
|
android:versionCode="382"
|
||||||
android:versionName="28.0"
|
android:versionName="28.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -720,8 +720,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
// When we are in AUTO mode and the dictionary word is in uppercase,
|
// When we are in AUTO mode and the dictionary word is in uppercase,
|
||||||
// the mode would switch to UPPERCASE, but visually, the word would not change.
|
// the mode would switch to UPPERCASE, but visually, the word would not change.
|
||||||
// This is why we retry, until there is a visual change.
|
// This is why we retry, until there is a visual change.
|
||||||
for (int retries = 0; retries < 2 && mLanguage.hasUpperCase(); retries++) {
|
for (int retries = 0; retries < 2 && mInputMode.nextTextCase(); retries++) {
|
||||||
mInputMode.nextTextCase();
|
|
||||||
setSuggestions(mInputMode.getSuggestions(), suggestionBar.getCurrentIndex());
|
setSuggestions(mInputMode.getSuggestions(), suggestionBar.getCurrentIndex());
|
||||||
textField.setComposingText(suggestionBar.getCurrentSuggestion());
|
textField.setComposingText(suggestionBar.getCurrentSuggestion());
|
||||||
|
|
||||||
|
|
@ -731,7 +730,7 @@ public class TraditionalT9 extends KeyPadHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// make "abc" and "ABC" separate modes from user perspective
|
// make "abc" and "ABC" separate modes from user perspective
|
||||||
else if (mInputMode instanceof ModeABC && mInputMode.getTextCase() == InputMode.CASE_LOWER && mLanguage.hasUpperCase()) {
|
else if (mInputMode instanceof ModeABC && mLanguage.hasUpperCase() && mInputMode.getTextCase() == InputMode.CASE_LOWER) {
|
||||||
mInputMode.nextTextCase();
|
mInputMode.nextTextCase();
|
||||||
} else {
|
} else {
|
||||||
int nextModeIndex = (allowedInputModes.indexOf(mInputMode.getId()) + 1) % allowedInputModes.size();
|
int nextModeIndex = (allowedInputModes.indexOf(mInputMode.getId()) + 1) % allowedInputModes.size();
|
||||||
|
|
|
||||||
|
|
@ -129,16 +129,6 @@ abstract public class InputMode {
|
||||||
textCase = allowedTextCases.get(0);
|
textCase = allowedTextCases.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean nextTextCase() {
|
|
||||||
if (nextSpecialCharacters()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int nextIndex = (allowedTextCases.indexOf(textCase) + 1) % allowedTextCases.size();
|
|
||||||
textCase = allowedTextCases.get(nextIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used in nextTextCase() for switching to the next set of characters. Obviously,
|
* This is used in nextTextCase() for switching to the next set of characters. Obviously,
|
||||||
* special chars do not have a text case, but we use this trick to alternate the char groups.
|
* special chars do not have a text case, but we use this trick to alternate the char groups.
|
||||||
|
|
@ -148,9 +138,10 @@ abstract public class InputMode {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int previousGroup = specialCharSelectedGroup;
|
||||||
int key = digitSequence.charAt(0) - '0';
|
int key = digitSequence.charAt(0) - '0';
|
||||||
|
|
||||||
ArrayList<String> chars = language.getKeyCharacters(key, ++specialCharSelectedGroup);
|
ArrayList<String> chars = language.getKeyCharacters(key, ++specialCharSelectedGroup);
|
||||||
|
|
||||||
if (chars.isEmpty() && specialCharSelectedGroup == 1) {
|
if (chars.isEmpty() && specialCharSelectedGroup == 1) {
|
||||||
specialCharSelectedGroup = 0;
|
specialCharSelectedGroup = 0;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -162,6 +153,21 @@ abstract public class InputMode {
|
||||||
suggestions.clear();
|
suggestions.clear();
|
||||||
suggestions.addAll(chars);
|
suggestions.addAll(chars);
|
||||||
|
|
||||||
|
return previousGroup != specialCharSelectedGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean nextTextCase() {
|
||||||
|
if (nextSpecialCharacters()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!language.hasUpperCase() || digitSequence.startsWith(Language.PUNCTUATION_KEY) || digitSequence.startsWith(Language.SPECIAL_CHARS_KEY)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nextIndex = (allowedTextCases.indexOf(textCase) + 1) % allowedTextCases.size();
|
||||||
|
textCase = allowedTextCases.get(nextIndex);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,7 @@ public class Mode123 extends ModePassthrough {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override protected boolean nextSpecialCharacters() {
|
||||||
@Override
|
|
||||||
protected boolean nextSpecialCharacters() {
|
|
||||||
return digitSequence.equals(Language.SPECIAL_CHARS_KEY) && super.nextSpecialCharacters();
|
return digitSequence.equals(Language.SPECIAL_CHARS_KEY) && super.nextSpecialCharacters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,8 +120,7 @@ public class Mode123 extends ModePassthrough {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override public void reset() {
|
||||||
public void reset() {
|
|
||||||
super.reset();
|
super.reset();
|
||||||
digitSequence = "";
|
digitSequence = "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -314,11 +314,6 @@ public class ModePredictive extends InputMode {
|
||||||
return autoTextCase.adjustSuggestionTextCase(new Text(language, word), newTextCase);
|
return autoTextCase.adjustSuggestionTextCase(new Text(language, word), newTextCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean nextSpecialCharacters() {
|
|
||||||
return digitSequence.equals(Language.SPECIAL_CHARS_KEY) && super.nextSpecialCharacters();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void determineNextWordTextCase(Text textBeforeCursor) {
|
public void determineNextWordTextCase(Text textBeforeCursor) {
|
||||||
textCase = autoTextCase.determineNextWordTextCase(textCase, textFieldTextCase, textBeforeCursor);
|
textCase = autoTextCase.determineNextWordTextCase(textCase, textFieldTextCase, textBeforeCursor);
|
||||||
|
|
@ -330,6 +325,11 @@ public class ModePredictive extends InputMode {
|
||||||
return (textCase == CASE_UPPER || textCase == CASE_LOWER) ? textCase : CASE_CAPITALIZE;
|
return (textCase == CASE_UPPER || textCase == CASE_LOWER) ? textCase : CASE_CAPITALIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean nextSpecialCharacters() {
|
||||||
|
return digitSequence.equals(Language.SPECIAL_CHARS_KEY) && super.nextSpecialCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean nextTextCase() {
|
public boolean nextTextCase() {
|
||||||
boolean changed = super.nextTextCase();
|
boolean changed = super.nextTextCase();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue