added the ability to type special characters in 123 mode
This commit is contained in:
parent
9e873af4ba
commit
7f54586825
4 changed files with 40 additions and 36 deletions
|
|
@ -73,7 +73,7 @@ _**NB2:** In messaging applications, you need to enable their "Send with ENTER"
|
|||
#### 0-key:
|
||||
- **In 123 mode:**
|
||||
- **Press:** type "0".
|
||||
- **Hold:** type "+".
|
||||
- **Hold:** type special/math characters.
|
||||
- **In ABC mode:**
|
||||
- **Press:** type space, newline or special/math characters.
|
||||
- **Hold:** type "0".
|
||||
|
|
@ -83,7 +83,7 @@ _**NB2:** In messaging applications, you need to enable their "Send with ENTER"
|
|||
- **Hold:** type "0".
|
||||
|
||||
#### 1- to 9-key:
|
||||
- **In 123 mode:** type the respective number.
|
||||
- **In 123 mode:** type the respective number or hold to type punctuation.
|
||||
- **In ABC and Predictive mode:** type a letter/punctuation character or hold to type the respective number.
|
||||
|
||||
#### Add Word Key (Default: Press ✱):
|
||||
|
|
|
|||
|
|
@ -2,21 +2,50 @@ package io.github.sspanak.tt9.ime.modes;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import io.github.sspanak.tt9.languages.Characters;
|
||||
|
||||
public class Mode123 extends ModePassthrough {
|
||||
@Override public int getId() { return MODE_123; }
|
||||
@Override @NonNull public String toString() { return "123"; }
|
||||
|
||||
@Override public final boolean is123() { return true; }
|
||||
@Override public boolean isPassthrough() { return false; }
|
||||
@Override public int getSequenceLength() { return 1; }
|
||||
@Override public boolean shouldAcceptPreviousSuggestion(int nextKey) { return true; }
|
||||
|
||||
@Override public void reset() {
|
||||
super.reset();
|
||||
autoAcceptTimeout = 0;
|
||||
private final ArrayList<ArrayList<String>> KEY_CHARACTERS = new ArrayList<>();
|
||||
|
||||
public Mode123() {
|
||||
// 0-key
|
||||
KEY_CHARACTERS.add(new ArrayList<>(Collections.singletonList("+")));
|
||||
for (String character : Characters.Special) {
|
||||
if (!character.equals("+") && !character.equals("\n")) {
|
||||
KEY_CHARACTERS.get(0).add(character);
|
||||
}
|
||||
}
|
||||
|
||||
// 1-key
|
||||
KEY_CHARACTERS.add(new ArrayList<>(Collections.singletonList(".")));
|
||||
for (String character : Characters.PunctuationEnglish) {
|
||||
if (!character.equals(".")) {
|
||||
KEY_CHARACTERS.get(1).add(character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public boolean onNumber(int number, boolean hold, int repeat) {
|
||||
reset();
|
||||
suggestions.add((number == 0 && hold) ? "+" : String.valueOf(number));
|
||||
|
||||
if (hold && number < KEY_CHARACTERS.size()) {
|
||||
suggestions.addAll(KEY_CHARACTERS.get(number));
|
||||
} else {
|
||||
autoAcceptTimeout = 0;
|
||||
suggestions.add(String.valueOf(number));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,16 +73,16 @@ public class SoftNumberKey extends SoftKey {
|
|||
}
|
||||
}
|
||||
|
||||
// no special labels in 123 mode
|
||||
if (tt9.getInputMode() == InputMode.MODE_123) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1
|
||||
if (number == 1) {
|
||||
return ",:-)";
|
||||
}
|
||||
|
||||
// no other special labels in 123 mode
|
||||
if (tt9.getInputMode() == InputMode.MODE_123) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 2-9
|
||||
Language language = LanguageCollection.getLanguage(tt9.getApplicationContext(), tt9.getSettings().getInputLanguage());
|
||||
if (language == null) {
|
||||
|
|
|
|||
|
|
@ -19,20 +19,6 @@ public class SoftPunctuationKey extends SoftKey {
|
|||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleHold() {
|
||||
if (tt9 == null || tt9.getInputMode() != InputMode.MODE_123) {
|
||||
return super.handleHold();
|
||||
}
|
||||
|
||||
preventRepeat();
|
||||
int keyId = getId();
|
||||
if (keyId == R.id.soft_key_punctuation_1) return tt9.onText(",");
|
||||
if (keyId == R.id.soft_key_punctuation_2) return tt9.onText(".");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
if (!validateTT9Handler()) {
|
||||
|
|
@ -68,15 +54,4 @@ public class SoftPunctuationKey extends SoftKey {
|
|||
|
||||
return "PUNC";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSubTitle() {
|
||||
int keyId = getId();
|
||||
if (tt9 != null && tt9.getInputMode() == InputMode.MODE_123) {
|
||||
if (keyId == R.id.soft_key_punctuation_1) return ",";
|
||||
if (keyId == R.id.soft_key_punctuation_2) return ".";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue