added Bopomofo support (without an actual dictionary)
This commit is contained in:
parent
6469444cc6
commit
b446e41120
20 changed files with 319 additions and 59 deletions
60
app/languages/definitions/ChineseBopomofo.hidden
Normal file
60
app/languages/definitions/ChineseBopomofo.hidden
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
locale: zh-TW
|
||||||
|
dictionaryFile: zh-bopomofo.csv
|
||||||
|
name: 中文 / 繁體
|
||||||
|
abcString: ㄅㄆㄇ
|
||||||
|
hasSpaceBetweenWords: no
|
||||||
|
hasUpperCase: no
|
||||||
|
layout:
|
||||||
|
- [ㄧ, ㄨ, ㄩ, SPECIAL] # 0
|
||||||
|
- [ㄅ, ㄆ, ㄇ, ㄈ, PUNCTUATION_ZH] # 1
|
||||||
|
- [ㄉ, ㄊ, ㄋ, ㄌ] # 2
|
||||||
|
- [ㄍ, ㄎ, ㄏ] # 3
|
||||||
|
- [ㄐ, ㄑ, ㄒ] # 4
|
||||||
|
- [ㄓ, ㄔ, ㄕ, ㄖ] # 5
|
||||||
|
- [ㄗ, ㄘ, ㄙ] # 6
|
||||||
|
- [ㄚ, ㄛ, ㄜ, ㄝ] # 7
|
||||||
|
- [ㄞ, ㄟ, ㄠ, ㄡ] # 8
|
||||||
|
- [ㄢ, ㄣ, ㄤ, ㄥ, ㄦ] # 9
|
||||||
|
sounds:
|
||||||
|
- [I,0] # ㄧ
|
||||||
|
- [Yi,0] # ㄧ, probably unnecessary
|
||||||
|
- [Y,0] # ㄧ, probably unnecessary
|
||||||
|
- [U,0] # ㄨ
|
||||||
|
- [Wu,0] # ㄨ, probably unnecessary
|
||||||
|
- [W,0] # ㄨ, probably unnecessary
|
||||||
|
- [Yu,0] # ㄩ
|
||||||
|
- [Uu,0] # ㄩ, actually "ü", probably unnecessary
|
||||||
|
- [B,1] # ㄅ
|
||||||
|
- [P,1] # ㄆ
|
||||||
|
- [M,1] # ㄇ
|
||||||
|
- [F,1] # ㄈ
|
||||||
|
- [D,2] # ㄉ
|
||||||
|
- [T,2] # ㄊ
|
||||||
|
- [N,2] # ㄋ
|
||||||
|
- [L,2] # ㄌ
|
||||||
|
- [G,3] # ㄍ
|
||||||
|
- [K,3] # ㄎ
|
||||||
|
- [H,3] # ㄏ
|
||||||
|
- [J,4] # ㄐ
|
||||||
|
- [Q,4] # ㄑ
|
||||||
|
- [X,4] # ㄒ
|
||||||
|
- [Zh,5] # ㄓ
|
||||||
|
- [Ch,5] # ㄔ
|
||||||
|
- [Sh,5] # ㄕ
|
||||||
|
- [R,5] # ㄖ
|
||||||
|
- [Z,6] # ㄗ
|
||||||
|
- [C,6] # ㄘ
|
||||||
|
- [S,6] # ㄙ
|
||||||
|
- [A,7] # ㄚ
|
||||||
|
- [O,7] # ㄛ
|
||||||
|
- [E,7] # ㄜ
|
||||||
|
- [Ie,7] # ㄝ
|
||||||
|
- [Ai,8] # ㄞ
|
||||||
|
- [Ei,8] # ㄟ
|
||||||
|
- [Ao,8] # ㄠ
|
||||||
|
- [Ou,8] # ㄡ
|
||||||
|
- [An,9] # ㄢ
|
||||||
|
- [En,9] # ㄣ
|
||||||
|
- [Ang,9] # ㄤ
|
||||||
|
- [Eng,9] # ㄥ
|
||||||
|
- [Er,9] # ㄦ
|
||||||
37
app/languages/dictionaries/zh-bopomofo.hidden
Normal file
37
app/languages/dictionaries/zh-bopomofo.hidden
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
ㄧ I
|
||||||
|
ㄨ U
|
||||||
|
ㄩ Yu
|
||||||
|
ㄅ B
|
||||||
|
ㄆ P
|
||||||
|
ㄇ M
|
||||||
|
ㄈ F
|
||||||
|
ㄉ D
|
||||||
|
ㄊ T
|
||||||
|
ㄋ N
|
||||||
|
ㄌ L
|
||||||
|
ㄍ G
|
||||||
|
ㄎ K
|
||||||
|
ㄏ H
|
||||||
|
ㄐ J
|
||||||
|
ㄑ Q
|
||||||
|
ㄒ X
|
||||||
|
ㄓ Zh
|
||||||
|
ㄔ Ch
|
||||||
|
ㄕ Sh
|
||||||
|
ㄖ R
|
||||||
|
ㄗ Z
|
||||||
|
ㄘ C
|
||||||
|
ㄙ S
|
||||||
|
ㄚ A
|
||||||
|
ㄛ O
|
||||||
|
ㄜ E
|
||||||
|
ㄝ Ie
|
||||||
|
ㄞ Ai
|
||||||
|
ㄟ Ei
|
||||||
|
ㄠ Ao
|
||||||
|
ㄡ Ou
|
||||||
|
ㄢ An
|
||||||
|
ㄣ En
|
||||||
|
ㄤ Ang
|
||||||
|
ㄥ Eng
|
||||||
|
ㄦ Er
|
||||||
|
|
@ -10,6 +10,7 @@ import io.github.sspanak.tt9.ime.helpers.OrientationListener;
|
||||||
import io.github.sspanak.tt9.ime.modes.InputModeKind;
|
import io.github.sspanak.tt9.ime.modes.InputModeKind;
|
||||||
import io.github.sspanak.tt9.ime.voice.VoiceInputOps;
|
import io.github.sspanak.tt9.ime.voice.VoiceInputOps;
|
||||||
import io.github.sspanak.tt9.languages.Language;
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
||||||
|
|
||||||
|
|
@ -191,6 +192,11 @@ abstract public class MainViewHandler extends HotkeyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasLettersOnAllKeys() {
|
||||||
|
return LanguageKind.isKorean(mLanguage) || LanguageKind.isChineseBopomofo(mLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void resetNormalizedDimensions() {
|
private void resetNormalizedDimensions() {
|
||||||
normalizedWidth = -1;
|
normalizedWidth = -1;
|
||||||
normalizedHeight = -1;
|
normalizedHeight = -1;
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ abstract public class InputMode {
|
||||||
public static InputMode getInstance(SettingsStore settings, @Nullable Language language, InputType inputType, TextField textField, int mode) {
|
public static InputMode getInstance(SettingsStore settings, @Nullable Language language, InputType inputType, TextField textField, int mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_PREDICTIVE:
|
case MODE_PREDICTIVE:
|
||||||
if (LanguageKind.isChinese(language)) return new ModePinyin(settings, language, inputType, textField);
|
if (LanguageKind.isChineseBopomofo(language)) return new ModeBopomofo(settings, language, inputType, textField);
|
||||||
|
if (LanguageKind.isChinesePinyin(language)) return new ModePinyin(settings, language, inputType, textField);
|
||||||
if (LanguageKind.isJapanese(language)) return new ModeKanji(settings, language, inputType, textField);
|
if (LanguageKind.isJapanese(language)) return new ModeKanji(settings, language, inputType, textField);
|
||||||
if (LanguageKind.isKorean(language)) return new ModeCheonjiin(settings, inputType, textField);
|
if (LanguageKind.isKorean(language)) return new ModeCheonjiin(settings, inputType, textField);
|
||||||
if (language != null && language.isTranscribed()) return new ModeIdeograms(settings, language, inputType, textField);
|
if (language != null && language.isTranscribed()) return new ModeIdeograms(settings, language, inputType, textField);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class ModeABC extends InputMode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean changeLanguage(@Nullable Language newLanguage) {
|
public boolean changeLanguage(@Nullable Language newLanguage) {
|
||||||
if (newLanguage != null && newLanguage.isTranscribed()) {
|
if (newLanguage != null && !newLanguage.hasABC()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
package io.github.sspanak.tt9.ime.modes;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import io.github.sspanak.tt9.hacks.InputType;
|
||||||
|
import io.github.sspanak.tt9.ime.helpers.TextField;
|
||||||
|
import io.github.sspanak.tt9.languages.EmojiLanguage;
|
||||||
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
|
import io.github.sspanak.tt9.languages.NaturalLanguage;
|
||||||
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
|
import io.github.sspanak.tt9.util.chars.Characters;
|
||||||
|
|
||||||
|
public class ModeBopomofo extends ModePinyin {
|
||||||
|
private static final String SPECIAL_CHAR_SEQUENCE_PREFIX = "S0";
|
||||||
|
private static final String PUNCTUATION_SEQUENCE_PREFIX = "S1";
|
||||||
|
|
||||||
|
protected ModeBopomofo(SettingsStore settings, Language lang, InputType inputType, TextField textField) {
|
||||||
|
super(settings, lang, inputType, textField);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean changeLanguage(@Nullable Language newLanguage) {
|
||||||
|
if (LanguageKind.isChineseBopomofo(newLanguage)) {
|
||||||
|
setLanguage(newLanguage);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* **************************** LOAD SUGGESTIONS *********************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not possible in Bopomofo mode, because 0-key is used for typing letters.
|
||||||
|
*/
|
||||||
|
@Override protected boolean loadPreferredChar() { return false; }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setCustomSpecialCharacters
|
||||||
|
* Filter out the letters from the 0-key list and add "0", because there is no other way of
|
||||||
|
* typing it.
|
||||||
|
*/
|
||||||
|
protected void setCustomSpecialCharacters() {
|
||||||
|
// special
|
||||||
|
KEY_CHARACTERS.add(TextTools.removeLettersFromList(applyPunctuationOrder(Characters.Special, 0)));
|
||||||
|
KEY_CHARACTERS.get(0).add(0, "0");
|
||||||
|
|
||||||
|
// punctuation
|
||||||
|
KEY_CHARACTERS.add(
|
||||||
|
TextTools.removeLettersFromList(applyPunctuationOrder(Characters.PunctuationChinese, 1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void setSpecialCharacterConstants() {
|
||||||
|
CUSTOM_EMOJI_SEQUENCE = PUNCTUATION_SEQUENCE_PREFIX + EmojiLanguage.CUSTOM_EMOJI_SEQUENCE;
|
||||||
|
EMOJI_SEQUENCE = PUNCTUATION_SEQUENCE_PREFIX + EmojiLanguage.EMOJI_SEQUENCE;
|
||||||
|
PUNCTUATION_SEQUENCE = PUNCTUATION_SEQUENCE_PREFIX + NaturalLanguage.PUNCTUATION_KEY;
|
||||||
|
SPECIAL_CHAR_SEQUENCE = SPECIAL_CHAR_SEQUENCE_PREFIX + NaturalLanguage.SPECIAL_CHAR_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** TYPING *********************************/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBackspace() {
|
||||||
|
if (digitSequence.equals(PUNCTUATION_SEQUENCE) || digitSequence.equals(SPECIAL_CHAR_SEQUENCE)) {
|
||||||
|
digitSequence = "";
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return super.onBackspace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNumberPress(int nextNumber) {
|
||||||
|
if (digitSequence.startsWith(PUNCTUATION_SEQUENCE)) {
|
||||||
|
digitSequence = PUNCTUATION_SEQUENCE_PREFIX + EmojiLanguage.validateEmojiSequence(digitSequence.substring(PUNCTUATION_SEQUENCE_PREFIX.length()), nextNumber);
|
||||||
|
} else {
|
||||||
|
digitSequence += String.valueOf(nextNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onNumberHold(int number) {
|
||||||
|
if (number == 0) {
|
||||||
|
disablePredictions = false;
|
||||||
|
digitSequence = SPECIAL_CHAR_SEQUENCE;
|
||||||
|
} else if (number == 1) {
|
||||||
|
disablePredictions = false;
|
||||||
|
digitSequence = PUNCTUATION_SEQUENCE;
|
||||||
|
} else {
|
||||||
|
autoAcceptTimeout = 0;
|
||||||
|
suggestions.add(language.getKeyNumeral(number));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************* ACCEPT WORDS *********************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In Bopomofo mode, the 0-key is not Spacebar, so we do not rely on the parents to handle accepting
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean shouldAcceptPreviousSuggestion(int nextKey, boolean hold) {
|
||||||
|
String newSequence = digitSequence + (char)(nextKey + '0');
|
||||||
|
return hold
|
||||||
|
|| newSequence.startsWith(SPECIAL_CHAR_SEQUENCE)
|
||||||
|
|| (newSequence.startsWith(PUNCTUATION_SEQUENCE) && nextKey != NaturalLanguage.PUNCTUATION_KEY.charAt(0) - '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,7 @@ public class ModePinyin extends ModeIdeograms {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean changeLanguage(@Nullable Language newLanguage) {
|
public boolean changeLanguage(@Nullable Language newLanguage) {
|
||||||
if (LanguageKind.isChinese(newLanguage)) {
|
if (LanguageKind.isChinesePinyin(newLanguage)) {
|
||||||
setLanguage(newLanguage);
|
setLanguage(newLanguage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ class ModeWords extends ModeCheonjiin {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean loadPreferredChar() {
|
protected boolean loadPreferredChar() {
|
||||||
if (digitSequence.startsWith(NaturalLanguage.PREFERRED_CHAR_SEQUENCE)) {
|
if (digitSequence.startsWith(NaturalLanguage.PREFERRED_CHAR_SEQUENCE)) {
|
||||||
suggestions.clear();
|
suggestions.clear();
|
||||||
suggestions.add(getPreferredChar());
|
suggestions.add(getPreferredChar());
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ public class LanguageKind {
|
||||||
|
|
||||||
public static boolean isArabic(Language language) { return language != null && language.getId() == 502337; }
|
public static boolean isArabic(Language language) { return language != null && language.getId() == 502337; }
|
||||||
public static boolean isEnglish(Language language) { return language != null && language.getLocale().equals(Locale.ENGLISH); }
|
public static boolean isEnglish(Language language) { return language != null && language.getLocale().equals(Locale.ENGLISH); }
|
||||||
public static boolean isChinese(Language language) { return language != null && language.getId() == 462106; }
|
public static boolean isChinese(Language language) { return isChineseBopomofo(language) || isChinesePinyin(language); }
|
||||||
|
public static boolean isChineseBopomofo(Language language) { return language != null && language.getId() == 774426; }
|
||||||
|
public static boolean isChinesePinyin(Language language) { return language != null && language.getId() == 462106; }
|
||||||
public static boolean isFarsi(Language language) { return language != null && language.getId() == 599078; }
|
public static boolean isFarsi(Language language) { return language != null && language.getId() == 599078; }
|
||||||
public static boolean isFrench(Language language) { return language != null && language.getId() == 596550; }
|
public static boolean isFrench(Language language) { return language != null && language.getId() == 596550; }
|
||||||
public static boolean isJapanese(Language language) { return language != null && language.getId() == 534570; }
|
public static boolean isJapanese(Language language) { return language != null && language.getId() == 534570; }
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.ime.TraditionalT9;
|
import io.github.sspanak.tt9.ime.TraditionalT9;
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.ui.main.keys.SoftKey;
|
import io.github.sspanak.tt9.ui.main.keys.SoftKey;
|
||||||
import io.github.sspanak.tt9.ui.main.keys.SoftKeySettings;
|
import io.github.sspanak.tt9.ui.main.keys.SoftKeySettings;
|
||||||
|
|
@ -283,7 +282,7 @@ class MainLayoutNumpad extends BaseMainLayout {
|
||||||
setKeyColumnWidth(tt9.getSettings().getNumpadFnKeyScale());
|
setKeyColumnWidth(tt9.getSettings().getNumpadFnKeyScale());
|
||||||
setBackgroundBlending();
|
setBackgroundBlending();
|
||||||
showLongSpace(
|
showLongSpace(
|
||||||
tt9.getSettings().isNumpadShapeLongSpace() && !tt9.isInputModeNumeric() && !LanguageKind.isKorean(tt9.getLanguage()),
|
tt9.getSettings().isNumpadShapeLongSpace() && !tt9.isInputModeNumeric() && !tt9.hasLettersOnAllKeys(),
|
||||||
defaultKeyHeight
|
defaultKeyHeight
|
||||||
);
|
);
|
||||||
for (SoftKey key : getKeys()) {
|
for (SoftKey key : getKeys()) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.util.Text;
|
import io.github.sspanak.tt9.util.Text;
|
||||||
import io.github.sspanak.tt9.util.chars.Characters;
|
import io.github.sspanak.tt9.util.chars.Characters;
|
||||||
|
|
@ -30,6 +31,20 @@ public class SoftKey extends BaseClickableKey {
|
||||||
public SoftKey(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
public SoftKey(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bopomofo letters are very large, so we need to scale them down a bit in some keys. Hence,
|
||||||
|
* the convenience method.
|
||||||
|
*/
|
||||||
|
protected boolean isBopomofo() {
|
||||||
|
return tt9 != null && !tt9.isInputModeNumeric() && LanguageKind.isChineseBopomofo(tt9.getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean hasLettersOnAllKeys() {
|
||||||
|
return tt9 != null && tt9.hasLettersOnAllKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a scale factor for the screen width, used to adjust the key size and text size. Mostly,
|
* Returns a scale factor for the screen width, used to adjust the key size and text size. Mostly,
|
||||||
* useful for tablets or larger devices, where the keys are too big but the text remains small.
|
* useful for tablets or larger devices, where the keys are too big but the text remains small.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.R;
|
import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
|
||||||
import io.github.sspanak.tt9.ui.Vibration;
|
import io.github.sspanak.tt9.ui.Vibration;
|
||||||
|
|
||||||
public class SoftKeyFilter extends BaseSoftKeyWithIcons {
|
public class SoftKeyFilter extends BaseSoftKeyWithIcons {
|
||||||
|
|
@ -12,13 +11,9 @@ public class SoftKeyFilter extends BaseSoftKeyWithIcons {
|
||||||
public SoftKeyFilter(Context context, AttributeSet attrs) { super(context, attrs); }
|
public SoftKeyFilter(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||||
public SoftKeyFilter(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
public SoftKeyFilter(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||||
|
|
||||||
private boolean isKorean() {
|
|
||||||
return tt9 != null && LanguageKind.isKorean(tt9.getLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleHold() {
|
protected void handleHold() {
|
||||||
if (isKorean()) {
|
if (hasLettersOnAllKeys()) {
|
||||||
handleRelease();
|
handleRelease();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +32,7 @@ public class SoftKeyFilter extends BaseSoftKeyWithIcons {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isKorean()) {
|
if (hasLettersOnAllKeys()) {
|
||||||
return tt9.onKeySpaceKorean(false);
|
return tt9.onKeySpaceKorean(false);
|
||||||
} else {
|
} else {
|
||||||
return tt9.onKeyFilterSuggestions(false, getLastPressedKey() == getId());
|
return tt9.onKeyFilterSuggestions(false, getLastPressedKey() == getId());
|
||||||
|
|
@ -45,21 +40,21 @@ public class SoftKeyFilter extends BaseSoftKeyWithIcons {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override protected String getTitle() { return isKorean() ? "␣" : ""; }
|
@Override protected String getTitle() { return hasLettersOnAllKeys() ? "␣" : ""; }
|
||||||
@Override protected int getCentralIcon() { return isKorean() ? 0 : R.drawable.ic_fn_filter; }
|
@Override protected int getCentralIcon() { return hasLettersOnAllKeys() ? 0 : R.drawable.ic_fn_filter; }
|
||||||
@Override protected int getHoldIcon() { return isKorean() ? 0 : R.drawable.ic_fn_filter_off; }
|
@Override protected int getHoldIcon() { return hasLettersOnAllKeys() ? 0 : R.drawable.ic_fn_filter_off; }
|
||||||
|
|
||||||
@Override protected float getTitleScale() { return isKorean() ? 1.3f * Math.min(1, getTT9Height()) * getScreenScaleY() : super.getTitleScale(); }
|
@Override protected float getTitleScale() { return hasLettersOnAllKeys() ? 1.3f * Math.min(1, getTT9Height()) * getScreenScaleY() : super.getTitleScale(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
if (tt9 != null) {
|
if (tt9 != null) {
|
||||||
setEnabled(
|
setEnabled(
|
||||||
!tt9.isInputModeNumeric()
|
!tt9.isInputModeNumeric()
|
||||||
&& !tt9.isInputModeABC()
|
|
||||||
&& !tt9.isVoiceInputActive()
|
&& !tt9.isVoiceInputActive()
|
||||||
|
&& (!tt9.isInputModeABC() || hasLettersOnAllKeys())
|
||||||
&& (
|
&& (
|
||||||
LanguageKind.isKorean(tt9.getLanguage())
|
hasLettersOnAllKeys()
|
||||||
|| (tt9.isFilteringSupported() && !tt9.isTextEditingActive())
|
|| (tt9.isFilteringSupported() && !tt9.isTextEditingActive())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class SoftKeyLF4 extends BaseSwipeableKey {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getTitleScale() {
|
protected float getTitleScale() {
|
||||||
return super.getTitleScale() * 0.9f;
|
return super.getTitleScale() * (isBopomofo() && tt9.isInputModeABC() ? 0.63f : 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
import io.github.sspanak.tt9.ui.Vibration;
|
import io.github.sspanak.tt9.ui.Vibration;
|
||||||
|
|
||||||
public class SoftKeyNumber extends BaseSoftKeyWithIcons {
|
public class SoftKeyNumber extends BaseSoftKeyWithIcons {
|
||||||
|
protected static final float TITLE_SCALE_BOPOMOFO = 0.7f;
|
||||||
|
|
||||||
private final static SparseArray<Integer> NUMBERS = new SparseArray<>() {{
|
private final static SparseArray<Integer> NUMBERS = new SparseArray<>() {{
|
||||||
put(R.id.soft_key_0, 0);
|
put(R.id.soft_key_0, 0);
|
||||||
put(R.id.soft_key_1, 1);
|
put(R.id.soft_key_1, 1);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
|
|
||||||
public class SoftKeyNumber0 extends SoftKeyNumber {
|
public class SoftKeyNumber0 extends SoftKeyNumber {
|
||||||
private static final String CHARS_NUMERIC_MODE = "+%$";
|
private static final String CHARS_NUMERIC_MODE = "+%$";
|
||||||
|
|
@ -13,8 +14,13 @@ public class SoftKeyNumber0 extends SoftKeyNumber {
|
||||||
public SoftKeyNumber0(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
public SoftKeyNumber0(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isKorean() {
|
||||||
|
return tt9 != null && !tt9.isInputModeNumeric() && LanguageKind.isKorean(tt9.getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isTransparentWhenTextEditing() {
|
private boolean isTransparentWhenTextEditing() {
|
||||||
return tt9 != null && LanguageKind.isKorean(tt9.getLanguage()) && tt9.isTextEditingActive();
|
return tt9 != null && tt9.isTextEditingActive() && hasLettersOnAllKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22,7 +28,7 @@ public class SoftKeyNumber0 extends SoftKeyNumber {
|
||||||
return tt9 != null
|
return tt9 != null
|
||||||
&& tt9.getSettings().isNumpadShapeLongSpace()
|
&& tt9.getSettings().isNumpadShapeLongSpace()
|
||||||
&& !tt9.isInputModeNumeric()
|
&& !tt9.isInputModeNumeric()
|
||||||
&& !LanguageKind.isKorean(tt9.getLanguage());
|
&& !hasLettersOnAllKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,7 +50,7 @@ public class SoftKeyNumber0 extends SoftKeyNumber {
|
||||||
return "+/-";
|
return "+/-";
|
||||||
} else if (tt9.isInputModePhone()) {
|
} else if (tt9.isInputModePhone()) {
|
||||||
return "+";
|
return "+";
|
||||||
} else if (tt9.isInputModeNumeric() || LanguageKind.isKorean(tt9.getLanguage())) {
|
} else if (tt9.isInputModeNumeric() || hasLettersOnAllKeys()) {
|
||||||
return CHARS_NUMERIC_MODE;
|
return CHARS_NUMERIC_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,35 +64,28 @@ public class SoftKeyNumber0 extends SoftKeyNumber {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (LanguageKind.isKorean(tt9.getLanguage())) ? getKoreanCharList() : "␣";
|
if (hasLettersOnAllKeys() && tt9.getLanguage() != null) {
|
||||||
|
return TextTools.removeNonLettersFromListAndJoin(tt9.getLanguage().getKeyCharacters(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "␣";
|
||||||
private String getKoreanCharList() {
|
|
||||||
if (tt9 == null || tt9.getLanguage() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder list = new StringBuilder();
|
|
||||||
for (String character : tt9.getLanguage().getKeyCharacters(0)) {
|
|
||||||
if (Character.isAlphabetic(character.charAt(0))) {
|
|
||||||
list.append(character);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getTitleScale() {
|
protected float getTitleScale() {
|
||||||
if (tt9 != null && !tt9.isInputModeNumeric() && !LanguageKind.isKorean(tt9.getLanguage())) {
|
if (isBopomofo()) {
|
||||||
return 1.3f * Math.min(1, getTT9Height()) * getScreenScaleY();
|
return super.getTitleScale() * TITLE_SCALE_BOPOMOFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isKorean()) {
|
||||||
return super.getTitleScale();
|
return super.getTitleScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scale up the space character, because it is too small
|
||||||
|
return 1.3f * Math.min(1, getTT9Height()) * getScreenScaleY();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setVisibility() {
|
private void setVisibility() {
|
||||||
getOverlayWrapper();
|
getOverlayWrapper();
|
||||||
|
|
@ -101,13 +100,7 @@ public class SoftKeyNumber0 extends SoftKeyNumber {
|
||||||
|
|
||||||
|
|
||||||
private void setEnabled() {
|
private void setEnabled() {
|
||||||
setEnabled(
|
setEnabled(tt9 != null && !(tt9.isTextEditingActive() && hasLettersOnAllKeys()));
|
||||||
tt9 != null
|
|
||||||
&& (
|
|
||||||
!tt9.isTextEditingActive()
|
|
||||||
|| (!LanguageKind.isKorean(tt9.getLanguage()) && !tt9.isInputModeNumeric())
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,38 @@ package io.github.sspanak.tt9.ui.main.keys;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
|
|
||||||
public class SoftKeyNumber1 extends SoftKeyNumber {
|
public class SoftKeyNumber1 extends SoftKeyNumber {
|
||||||
private static final String DEFAULT_LARGE_LABEL = ",:-)";
|
private static final String LARGE_LABEL_NUMERIC = "1";
|
||||||
private static final String KOREAN_SMALL_LABEL = "1 :-)";
|
private static final String LARGE_LABEL_TEXT = ",:-)";
|
||||||
private static final String KOREAN_LARGE_LABEL = "ㅣ";
|
private static final String HOLD_LABEL_NUMERIC_WHEN_LETTERS = "1 :-)";
|
||||||
|
|
||||||
public SoftKeyNumber1(Context context) { super(context); }
|
public SoftKeyNumber1(Context context) { super(context); }
|
||||||
public SoftKeyNumber1(Context context, AttributeSet attrs) { super(context, attrs); }
|
public SoftKeyNumber1(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||||
public SoftKeyNumber1(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
public SoftKeyNumber1(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTitle() {
|
protected String getTitle() {
|
||||||
if (tt9 == null || tt9.isInputModeNumeric()) {
|
if (tt9 == null || tt9.isInputModeNumeric()) {
|
||||||
return "1";
|
return LARGE_LABEL_NUMERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return LanguageKind.isKorean(tt9.getLanguage()) ? KOREAN_LARGE_LABEL : DEFAULT_LARGE_LABEL;
|
if (hasLettersOnAllKeys() && tt9.getLanguage() != null) {
|
||||||
|
return TextTools.removeNonLettersFromListAndJoin(tt9.getLanguage().getKeyCharacters(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return LARGE_LABEL_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getTitleScale() {
|
||||||
|
return super.getTitleScale() * (isBopomofo() ? TITLE_SCALE_BOPOMOFO : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getHoldText() {
|
protected String getHoldText() {
|
||||||
if (tt9 == null || tt9.isNumericModeStrict()) {
|
if (tt9 == null || tt9.isNumericModeStrict()) {
|
||||||
|
|
@ -30,11 +42,11 @@ public class SoftKeyNumber1 extends SoftKeyNumber {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tt9.isInputModeNumeric()) {
|
if (tt9.isInputModeNumeric()) {
|
||||||
return DEFAULT_LARGE_LABEL;
|
return LARGE_LABEL_TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LanguageKind.isKorean(tt9.getLanguage())) {
|
if (hasLettersOnAllKeys() && !(tt9.isInputModeABC() && isBopomofo())) {
|
||||||
return KOREAN_SMALL_LABEL;
|
return HOLD_LABEL_NUMERIC_WHEN_LETTERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getLocalizedNumber(getNumber(getId()));
|
return super.getLocalizedNumber(getNumber(getId()));
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,12 @@ public class SoftKeyNumber2to9 extends SoftKeyNumber {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getTitleScale() {
|
||||||
|
return super.getTitleScale() * (isBopomofo() ? TITLE_SCALE_BOPOMOFO : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getKeyChars(@NonNull TraditionalT9 tt9, int number) {
|
private String getKeyChars(@NonNull TraditionalT9 tt9, int number) {
|
||||||
Language language = tt9.getLanguage();
|
Language language = tt9.getLanguage();
|
||||||
if (language == null) {
|
if (language == null) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public class SoftKeyPunctuation extends SoftKey {
|
||||||
tt9 != null
|
tt9 != null
|
||||||
&& tt9.getSettings().isNumpadShapeLongSpace()
|
&& tt9.getSettings().isNumpadShapeLongSpace()
|
||||||
&& !tt9.isInputModeNumeric()
|
&& !tt9.isInputModeNumeric()
|
||||||
&& !LanguageKind.isKorean(tt9.getLanguage());
|
&& !hasLettersOnAllKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isTransparentWhenTextEditing() {
|
protected boolean isTransparentWhenTextEditing() {
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,16 @@ public class TextTools {
|
||||||
|
|
||||||
return cleanList;
|
return cleanList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String removeNonLettersFromListAndJoin(ArrayList<String> list) {
|
||||||
|
StringBuilder cleanList = new StringBuilder();
|
||||||
|
for (String ch : list) {
|
||||||
|
if (Character.isAlphabetic(ch.codePointAt(0))) {
|
||||||
|
cleanList.append(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleanList.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ class Punctuation {
|
||||||
",", ZH_COMMA_LIST, ZH_FULL_STOP, "—", "~", "゠", "(", ")", ".", "「", "」", "『", "』", "•", "《", "》", "〈", "〉", "'", "“", "”", ";", ":", ZH_EXCLAMATION_MARK, ZH_QUESTION_MARK
|
",", ZH_COMMA_LIST, ZH_FULL_STOP, "—", "~", "゠", "(", ")", ".", "「", "」", "『", "』", "•", "《", "》", "〈", "〉", "'", "“", "”", ";", ":", ZH_EXCLAMATION_MARK, ZH_QUESTION_MARK
|
||||||
));
|
));
|
||||||
|
|
||||||
|
final public static ArrayList<String> PunctuationChineseBopomofo = insertChar(PunctuationChinese, "1", ZH_FULL_STOP);
|
||||||
|
|
||||||
final public static ArrayList<String> PunctuationEnglish = new ArrayList<>(Arrays.asList(
|
final public static ArrayList<String> PunctuationEnglish = new ArrayList<>(Arrays.asList(
|
||||||
",", ".", "-", "(", ")", "&", "~", "`", ";", ":", "'", "\"", "!", "?"
|
",", ".", "-", "(", ")", "&", "~", "`", ";", ":", "'", "\"", "!", "?"
|
||||||
));
|
));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue