fixed changing the language also causing the currency characters to change
This commit is contained in:
parent
60aa9acd32
commit
181d596c7c
2 changed files with 41 additions and 32 deletions
|
|
@ -129,34 +129,6 @@ abstract public class InputMode {
|
||||||
textCase = allowedTextCases.get(0);
|
textCase = allowedTextCases.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
protected boolean nextSpecialCharacters() { return nextSpecialCharacters(language); }
|
|
||||||
protected boolean nextSpecialCharacters(Language altLanguage) {
|
|
||||||
if (altLanguage == null || digitSequence.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int previousGroup = specialCharSelectedGroup;
|
|
||||||
int key = digitSequence.charAt(0) - '0';
|
|
||||||
ArrayList<String> chars = altLanguage.getKeyCharacters(key, ++specialCharSelectedGroup);
|
|
||||||
|
|
||||||
if (chars.isEmpty() && specialCharSelectedGroup == 1) {
|
|
||||||
specialCharSelectedGroup = 0;
|
|
||||||
return false;
|
|
||||||
} else if (chars.isEmpty()) {
|
|
||||||
specialCharSelectedGroup = 0;
|
|
||||||
chars = altLanguage.getKeyCharacters(key, specialCharSelectedGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
suggestions.clear();
|
|
||||||
suggestions.addAll(chars);
|
|
||||||
|
|
||||||
return previousGroup != specialCharSelectedGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean nextTextCase() {
|
public boolean nextTextCase() {
|
||||||
if (nextSpecialCharacters()) {
|
if (nextSpecialCharacters()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -177,6 +149,43 @@ abstract public class InputMode {
|
||||||
// Based on the internal logic of the mode (punctuation or grammar rules), re-adjust the text case for when getSuggestions() is called.
|
// Based on the internal logic of the mode (punctuation or grammar rules), re-adjust the text case for when getSuggestions() is called.
|
||||||
protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
protected String adjustSuggestionTextCase(String word, int newTextCase) { return word; }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
protected boolean nextSpecialCharacters() { return nextSpecialCharacters(language); }
|
||||||
|
protected boolean nextSpecialCharacters(Language altLanguage) {
|
||||||
|
int previousGroup = specialCharSelectedGroup;
|
||||||
|
specialCharSelectedGroup++;
|
||||||
|
|
||||||
|
return
|
||||||
|
loadSpecialCharacters(altLanguage) // validates specialCharSelectedGroup
|
||||||
|
&& previousGroup != specialCharSelectedGroup; // verifies validation has passed
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean loadSpecialCharacters(Language altLanguage) {
|
||||||
|
if (altLanguage == null || digitSequence.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int key = digitSequence.charAt(0) - '0';
|
||||||
|
ArrayList<String> chars = altLanguage.getKeyCharacters(key, specialCharSelectedGroup);
|
||||||
|
|
||||||
|
if (chars.isEmpty() && specialCharSelectedGroup == 1) {
|
||||||
|
specialCharSelectedGroup = 0;
|
||||||
|
return false;
|
||||||
|
} else if (chars.isEmpty()) {
|
||||||
|
specialCharSelectedGroup = 0;
|
||||||
|
chars = altLanguage.getKeyCharacters(key, specialCharSelectedGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
suggestions.clear();
|
||||||
|
suggestions.addAll(chars);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Stem filtering.
|
// Stem filtering.
|
||||||
// Where applicable, return "true" if the mode supports it and the operation was possible.
|
// Where applicable, return "true" if the mode supports it and the operation was possible.
|
||||||
public boolean clearWordStem() { return setWordStem("", true); }
|
public boolean clearWordStem() { return setWordStem("", true); }
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ public class ModePredictive extends InputMode {
|
||||||
.setStem(stem)
|
.setStem(stem)
|
||||||
.setLanguage(searchLanguage)
|
.setLanguage(searchLanguage)
|
||||||
.setInputWord(currentWord)
|
.setInputWord(currentWord)
|
||||||
.setWordsChangedHandler(this::getPredictions)
|
.setWordsChangedHandler(this::onPredictions)
|
||||||
.load();
|
.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +249,7 @@ public class ModePredictive extends InputMode {
|
||||||
*/
|
*/
|
||||||
private boolean loadStaticSuggestions(Runnable onLoad) {
|
private boolean loadStaticSuggestions(Runnable onLoad) {
|
||||||
if (digitSequence.equals(Language.PUNCTUATION_KEY) || digitSequence.equals(Language.SPECIAL_CHARS_KEY)) {
|
if (digitSequence.equals(Language.PUNCTUATION_KEY) || digitSequence.equals(Language.SPECIAL_CHARS_KEY)) {
|
||||||
super.nextSpecialCharacters();
|
super.loadSpecialCharacters(language);
|
||||||
onLoad.run();
|
onLoad.run();
|
||||||
return true;
|
return true;
|
||||||
} else if (!digitSequence.equals(EmojiLanguage.CUSTOM_EMOJI_SEQUENCE) && digitSequence.startsWith(EmojiLanguage.EMOJI_SEQUENCE)) {
|
} else if (!digitSequence.equals(EmojiLanguage.CUSTOM_EMOJI_SEQUENCE) && digitSequence.startsWith(EmojiLanguage.EMOJI_SEQUENCE)) {
|
||||||
|
|
@ -269,10 +269,10 @@ public class ModePredictive extends InputMode {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPredictions
|
* onPredictions
|
||||||
* Gets the currently available Predictions and sends them over to the external caller.
|
* Gets the currently available Predictions and sends them over to the external caller.
|
||||||
*/
|
*/
|
||||||
private void getPredictions() {
|
private void onPredictions() {
|
||||||
// in case the user hasn't added any custom emoji, do not allow advancing to the empty character group
|
// in case the user hasn't added any custom emoji, do not allow advancing to the empty character group
|
||||||
if (predictions.getList().isEmpty() && digitSequence.startsWith(EmojiLanguage.EMOJI_SEQUENCE)) {
|
if (predictions.getList().isEmpty() && digitSequence.startsWith(EmojiLanguage.EMOJI_SEQUENCE)) {
|
||||||
digitSequence = EmojiLanguage.EMOJI_SEQUENCE;
|
digitSequence = EmojiLanguage.EMOJI_SEQUENCE;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue