consistent the handling and typing of the language-specific Space character
This commit is contained in:
parent
1e2c006931
commit
94f3ffd9a8
7 changed files with 25 additions and 21 deletions
|
|
@ -10,6 +10,7 @@ import io.github.sspanak.tt9.ime.modes.InputModeKind;
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
import io.github.sspanak.tt9.ui.UI;
|
import io.github.sspanak.tt9.ui.UI;
|
||||||
import io.github.sspanak.tt9.util.Ternary;
|
import io.github.sspanak.tt9.util.Ternary;
|
||||||
|
import io.github.sspanak.tt9.util.chars.Characters;
|
||||||
|
|
||||||
public abstract class HotkeyHandler extends CommandHandler {
|
public abstract class HotkeyHandler extends CommandHandler {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -411,7 +412,7 @@ public abstract class HotkeyHandler extends CommandHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// type a space when there is nothing to accept
|
// type a space when there is nothing to accept
|
||||||
return onText(" ", validateOnly);
|
return onText(Characters.getSpace(mLanguage), validateOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class Mode123 extends ModePassthrough {
|
||||||
if (inputType.isPhoneNumber()) {
|
if (inputType.isPhoneNumber()) {
|
||||||
setSpecificSpecialCharacters(Characters.Phone, false);
|
setSpecificSpecialCharacters(Characters.Phone, false);
|
||||||
} else if (inputType.isNumeric()) {
|
} else if (inputType.isNumeric()) {
|
||||||
setSpecificSpecialCharacters(Characters.getNumberSpecialCharacters(inputType.isDecimal(), inputType.isSignedNumber()), false);
|
setSpecificSpecialCharacters(Characters.getSpecialForNumbers(inputType.isDecimal(), inputType.isSignedNumber()), false);
|
||||||
} else if (isEmailMode) {
|
} else if (isEmailMode) {
|
||||||
setSpecificSpecialCharacters(Characters.Email, true);
|
setSpecificSpecialCharacters(Characters.Email, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class ModeBopomofo extends ModePinyin {
|
||||||
*/
|
*/
|
||||||
protected void setCustomSpecialCharacters() {
|
protected void setCustomSpecialCharacters() {
|
||||||
// special
|
// special
|
||||||
KEY_CHARACTERS.add(TextTools.removeLettersFromList(applyPunctuationOrder(Characters.Special, 0)));
|
KEY_CHARACTERS.add(TextTools.removeLettersFromList(applyPunctuationOrder(Characters.getSpecial(language), 0)));
|
||||||
KEY_CHARACTERS.get(0).add(0, "0");
|
KEY_CHARACTERS.get(0).add(0, "0");
|
||||||
|
|
||||||
// punctuation
|
// punctuation
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class ModeCheonjiin extends InputMode {
|
||||||
*/
|
*/
|
||||||
protected void setCustomSpecialCharacters() {
|
protected void setCustomSpecialCharacters() {
|
||||||
// special
|
// special
|
||||||
KEY_CHARACTERS.add(TextTools.removeLettersFromList(applyPunctuationOrder(Characters.Special, 0)));
|
KEY_CHARACTERS.add(TextTools.removeLettersFromList(applyPunctuationOrder(Characters.getSpecial(language), 0)));
|
||||||
KEY_CHARACTERS.get(0).add(0, "0");
|
KEY_CHARACTERS.get(0).add(0, "0");
|
||||||
|
|
||||||
// punctuation
|
// punctuation
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
import io.github.sspanak.tt9.util.Text;
|
import io.github.sspanak.tt9.util.Text;
|
||||||
import io.github.sspanak.tt9.util.TextTools;
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
import io.github.sspanak.tt9.util.chars.Characters;
|
|
||||||
|
|
||||||
public class ModeIdeograms extends ModeWords {
|
public class ModeIdeograms extends ModeWords {
|
||||||
private static final String LOG_TAG = ModeIdeograms.class.getSimpleName();
|
private static final String LOG_TAG = ModeIdeograms.class.getSimpleName();
|
||||||
|
|
@ -50,16 +49,6 @@ public class ModeIdeograms extends ModeWords {
|
||||||
isFiltering = false;
|
isFiltering = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setCustomSpecialCharacters() {
|
|
||||||
KEY_CHARACTERS.add(applyPunctuationOrder(Characters.Special, 0));
|
|
||||||
int spaceIndex = KEY_CHARACTERS.get(0).indexOf(" ");
|
|
||||||
if (spaceIndex >= 0) {
|
|
||||||
KEY_CHARACTERS.get(0).set(spaceIndex, Characters.IDEOGRAPHIC_SPACE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************* LOAD SUGGESTIONS *********************************/
|
/******************************* LOAD SUGGESTIONS *********************************/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public class NaturalLanguage extends TranscribedLanguage {
|
||||||
final String PUNCTUATION_PLACEHOLDER = "PUNCTUATION";
|
final String PUNCTUATION_PLACEHOLDER = "PUNCTUATION";
|
||||||
|
|
||||||
final Map<String, List<String>> specialChars = new HashMap<>();
|
final Map<String, List<String>> specialChars = new HashMap<>();
|
||||||
specialChars.put(SPECIAL_CHARS_PLACEHOLDER, Characters.Special);
|
specialChars.put(SPECIAL_CHARS_PLACEHOLDER, Characters.getSpecial(this));
|
||||||
specialChars.put(PUNCTUATION_PLACEHOLDER, Characters.PunctuationEnglish);
|
specialChars.put(PUNCTUATION_PLACEHOLDER, Characters.PunctuationEnglish);
|
||||||
specialChars.put(PUNCTUATION_PLACEHOLDER + "_AR", Characters.PunctuationArabic);
|
specialChars.put(PUNCTUATION_PLACEHOLDER + "_AR", Characters.PunctuationArabic);
|
||||||
specialChars.put(PUNCTUATION_PLACEHOLDER + "_ZH", Characters.PunctuationChinese);
|
specialChars.put(PUNCTUATION_PLACEHOLDER + "_ZH", Characters.PunctuationChinese);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.languages.Language;
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
|
|
||||||
public class Characters extends Emoji {
|
public class Characters extends Emoji {
|
||||||
public static final String COMBINING_ZERO_BASE = "◌";
|
public static final String COMBINING_ZERO_BASE = "◌";
|
||||||
|
|
@ -13,10 +14,6 @@ public class Characters extends Emoji {
|
||||||
"$", "€", "₿", "¢", "¤", "₱", "¥", "£"
|
"$", "€", "₿", "¢", "¤", "₱", "¥", "£"
|
||||||
));
|
));
|
||||||
|
|
||||||
final public static ArrayList<String> Special = new ArrayList<>(Arrays.asList(
|
|
||||||
" ", "\n", "@", "_", "#", "%", "[", "]", "{", "}", "§", "|", "^", "<", ">", "\\", "/", "=", "*", "+"
|
|
||||||
));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The English punctuation filtered to contain only valid email characters.
|
* The English punctuation filtered to contain only valid email characters.
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,10 +31,27 @@ public class Characters extends Emoji {
|
||||||
new ArrayList<>(Arrays.asList("-", "(", ")", ".", ";", ","))
|
new ArrayList<>(Arrays.asList("-", "(", ")", ".", ";", ","))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the language-specific space character.
|
||||||
|
*/
|
||||||
|
public static String getSpace(Language language) {
|
||||||
|
return LanguageKind.isChinese(language) || LanguageKind.isJapanese(language) ? IDEOGRAPHIC_SPACE : " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard special characters with automatic Space selection based on the language. Useful for
|
||||||
|
* text fields.
|
||||||
|
*/
|
||||||
|
public static ArrayList<String> getSpecial(Language language) {
|
||||||
|
return new ArrayList<>(Arrays.asList(
|
||||||
|
getSpace(language), "\n", "@", "_", "#", "%", "[", "]", "{", "}", "§", "|", "^", "<", ">", "\\", "/", "=", "*", "+"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special characters for all kinds of numeric fields: integer, decimal with +/- included as necessary.
|
* Special characters for all kinds of numeric fields: integer, decimal with +/- included as necessary.
|
||||||
*/
|
*/
|
||||||
public static ArrayList<ArrayList<String>> getNumberSpecialCharacters(boolean decimal, boolean signed) {
|
public static ArrayList<ArrayList<String>> getSpecialForNumbers(boolean decimal, boolean signed) {
|
||||||
ArrayList<ArrayList<String>> keyCharacters = new ArrayList<>();
|
ArrayList<ArrayList<String>> keyCharacters = new ArrayList<>();
|
||||||
keyCharacters.add(signed ? new ArrayList<>(Arrays.asList("-", "+")) : new ArrayList<>());
|
keyCharacters.add(signed ? new ArrayList<>(Arrays.asList("-", "+")) : new ArrayList<>());
|
||||||
if (decimal) {
|
if (decimal) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue