fixed 0-key and 1-key showing hardcoded punctuation list in Predictive mode, instead of what is defined in the respective Language class
This commit is contained in:
parent
c3aa0e8055
commit
b5cd92f1f7
3 changed files with 15 additions and 7 deletions
|
|
@ -289,14 +289,14 @@ public class ModePredictive extends InputMode {
|
||||||
* Similar to "loadSuggestions()", but loads suggestions that are not in the database.
|
* Similar to "loadSuggestions()", but loads suggestions that are not in the database.
|
||||||
* Returns "false", when there are no static suggestions for the current digitSequence.
|
* Returns "false", when there are no static suggestions for the current digitSequence.
|
||||||
*/
|
*/
|
||||||
private boolean loadStaticSuggestions() {
|
private boolean loadStaticSuggestions(Language language) {
|
||||||
if (digitSequence.equals("0")) {
|
if (digitSequence.equals("0")) {
|
||||||
stem = "";
|
stem = "";
|
||||||
suggestions = Punctuation.Secondary;
|
suggestions = language.getKeyCharacters(0, false);
|
||||||
} else if (containsOnly1Regex.matcher(digitSequence).matches()) {
|
} else if (containsOnly1Regex.matcher(digitSequence).matches()) {
|
||||||
stem = "";
|
stem = "";
|
||||||
if (digitSequence.length() == 1) {
|
if (digitSequence.length() == 1) {
|
||||||
suggestions = Punctuation.Main;
|
suggestions = language.getKeyCharacters(1, false);
|
||||||
} else {
|
} else {
|
||||||
digitSequence = digitSequence.length() <= maxEmojiSequence.length() ? digitSequence : maxEmojiSequence;
|
digitSequence = digitSequence.length() <= maxEmojiSequence.length() ? digitSequence : maxEmojiSequence;
|
||||||
suggestions = Punctuation.getEmoji(digitSequence.length() - 2);
|
suggestions = Punctuation.getEmoji(digitSequence.length() - 2);
|
||||||
|
|
@ -319,7 +319,7 @@ public class ModePredictive extends InputMode {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean loadSuggestions(Handler handler, Language language, String currentWord) {
|
public boolean loadSuggestions(Handler handler, Language language, String currentWord) {
|
||||||
if (loadStaticSuggestions()) {
|
if (loadStaticSuggestions(language)) {
|
||||||
super.onSuggestionsUpdated(handler);
|
super.onSuggestionsUpdated(handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,19 +89,23 @@ public class Language {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getKeyCharacters(int key) {
|
public ArrayList<String> getKeyCharacters(int key, boolean includeDigit) {
|
||||||
if (key < 0 || key >= characterMap.size()) {
|
if (key < 0 || key >= characterMap.size()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> chars = new ArrayList<>(characterMap.get(key));
|
ArrayList<String> chars = new ArrayList<>(characterMap.get(key));
|
||||||
if (chars.size() > 0) {
|
if (includeDigit && chars.size() > 0) {
|
||||||
chars.add(String.valueOf(key));
|
chars.add(String.valueOf(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return chars;
|
return chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getKeyCharacters(int key) {
|
||||||
|
return getKeyCharacters(key, true);
|
||||||
|
}
|
||||||
|
|
||||||
public String getDigitSequenceForWord(String word) throws InvalidLanguageCharactersException {
|
public String getDigitSequenceForWord(String word) throws InvalidLanguageCharactersException {
|
||||||
StringBuilder sequence = new StringBuilder();
|
StringBuilder sequence = new StringBuilder();
|
||||||
String lowerCaseWord = word.toLowerCase(locale);
|
String lowerCaseWord = word.toLowerCase(locale);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package io.github.sspanak.tt9.languages.definitions;
|
package io.github.sspanak.tt9.languages.definitions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
|
import io.github.sspanak.tt9.languages.Punctuation;
|
||||||
|
|
||||||
public class Spanish extends English {
|
public class Spanish extends English {
|
||||||
public Spanish() {
|
public Spanish() {
|
||||||
|
|
@ -18,11 +20,13 @@ public class Spanish extends English {
|
||||||
|
|
||||||
isPunctuationPartOfWords = false;
|
isPunctuationPartOfWords = false;
|
||||||
|
|
||||||
|
characterMap.set(1, new ArrayList<>(Punctuation.Main));
|
||||||
characterMap.get(1).addAll(Arrays.asList("¡", "¿"));
|
characterMap.get(1).addAll(Arrays.asList("¡", "¿"));
|
||||||
|
|
||||||
characterMap.get(2).addAll(Collections.singletonList("á"));
|
characterMap.get(2).addAll(Collections.singletonList("á"));
|
||||||
characterMap.get(3).addAll(Collections.singletonList("é"));
|
characterMap.get(3).addAll(Collections.singletonList("é"));
|
||||||
characterMap.get(4).addAll(Collections.singletonList("í"));
|
characterMap.get(4).addAll(Collections.singletonList("í"));
|
||||||
characterMap.get(6).clear(); characterMap.get(6).addAll(Arrays.asList("m", "n", "ñ", "o", "ó"));
|
characterMap.set(6, new ArrayList<>(Arrays.asList("m", "n", "ñ", "o", "ó")));
|
||||||
characterMap.get(8).addAll(Arrays.asList("ú", "ü"));
|
characterMap.get(8).addAll(Arrays.asList("ú", "ü"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue