-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* proper handling of POUND and STAR, when no hotkey function is assi…
…gned to them * Mode123 types numbers as text again, instead of using key codes * removed the InputMode.onOtherKey() functionality, all "other" stuff will be typed as text from now on * slightly optimized TraditionalT9.getComposingText() to return faster when there is no text
- Loading branch information
Showing
9 changed files
with
38 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
package io.github.sspanak.tt9.ime.modes; | ||
|
||
import android.view.KeyEvent; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import io.github.sspanak.tt9.ime.helpers.Key; | ||
|
||
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 boolean onNumber(int number, boolean hold, int repeat) { | ||
reset(); | ||
keyCode = (number == 0 && hold) ? KeyEvent.KEYCODE_PLUS : Key.numberToCode(number); | ||
return true; | ||
@Override public void reset() { | ||
super.reset(); | ||
autoAcceptTimeout = 0; | ||
} | ||
|
||
@Override | ||
public boolean onOtherKey(int key) { | ||
@Override public boolean onNumber(int number, boolean hold, int repeat) { | ||
reset(); | ||
if (Key.isDecimalSeparator(key) || Key.isPoundOrStar(key)) { | ||
keyCode = key; | ||
return true; | ||
} | ||
suggestions.add((number == 0 && hold) ? "+" : String.valueOf(number)); | ||
return true; | ||
} | ||
|
||
return false; | ||
/** | ||
* shouldIgnoreText | ||
* Since this is a numeric mode, we allow typing only numbers and: | ||
* 1. In numeric fields, we must allow math chars | ||
* 2. In dialer fields, we must allow various punctuation chars, because they are used as dialing shortcuts | ||
* at least in Japan. | ||
* More info and discussion: <a href="https://github.com/sspanak/tt9/issues/241">issue 241 on Github</a>. | ||
*/ | ||
@Override public boolean shouldIgnoreText(String text) { | ||
return | ||
text == null | ||
|| text.length() != 1 | ||
|| !( | ||
(text.charAt(0) > 31 && text.charAt(0) < 65) | ||
|| (text.charAt(0) > 90 && text.charAt(0) < 97) | ||
|| (text.charAt(0) > 122 && text.charAt(0) < 127) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters