From b0a8477c1b5428e4cdff58cb0dd21611de82e591 Mon Sep 17 00:00:00 2001 From: Alex Knop Date: Sun, 30 Jul 2023 13:17:29 -0400 Subject: [PATCH 1/3] added or operator for calculator app --- src/io/github/sspanak/tt9/ime/helpers/InputType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/github/sspanak/tt9/ime/helpers/InputType.java b/src/io/github/sspanak/tt9/ime/helpers/InputType.java index 08ed2b95c..8ee8ca0c7 100644 --- a/src/io/github/sspanak/tt9/ime/helpers/InputType.java +++ b/src/io/github/sspanak/tt9/ime/helpers/InputType.java @@ -51,7 +51,7 @@ public boolean isDialer() { int inputType = field.inputType & android.text.InputType.TYPE_MASK_CLASS; return - inputType == android.text.InputType.TYPE_CLASS_PHONE && field.packageName.equals("com.android.dialer"); + inputType == android.text.InputType.TYPE_CLASS_PHONE && field.packageName.equals("com.android.dialer") || inputType == android.text.InputType.TYPE_CLASS_NUMBER; } From ffc6b8367a95ffbd7b86a716c793cbd3ee1d0939 Mon Sep 17 00:00:00 2001 From: Alex Knop Date: Mon, 31 Jul 2023 09:08:00 -0400 Subject: [PATCH 2/3] placeholder for package name --- src/io/github/sspanak/tt9/ime/helpers/InputType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/github/sspanak/tt9/ime/helpers/InputType.java b/src/io/github/sspanak/tt9/ime/helpers/InputType.java index 8ee8ca0c7..d2e0d8787 100644 --- a/src/io/github/sspanak/tt9/ime/helpers/InputType.java +++ b/src/io/github/sspanak/tt9/ime/helpers/InputType.java @@ -51,7 +51,7 @@ public boolean isDialer() { int inputType = field.inputType & android.text.InputType.TYPE_MASK_CLASS; return - inputType == android.text.InputType.TYPE_CLASS_PHONE && field.packageName.equals("com.android.dialer") || inputType == android.text.InputType.TYPE_CLASS_NUMBER; + inputType == android.text.InputType.TYPE_CLASS_PHONE && field.packageName.equals("com.android.dialer") || inputType == android.text.InputType.TYPE_CLASS_NUMBER && field.packageName.contains("com.android.calculator"); } From b68d5c62d224e79c2a72c693215d0bbe540a100c Mon Sep 17 00:00:00 2001 From: sspanak Date: Tue, 1 Aug 2023 10:05:18 +0300 Subject: [PATCH 3/3] code style --- src/io/github/sspanak/tt9/ime/helpers/InputType.java | 12 +++++++----- src/io/github/sspanak/tt9/ime/helpers/TextField.java | 7 ++++--- .../sspanak/tt9/ime/modes/ModePassthrough.java | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/io/github/sspanak/tt9/ime/helpers/InputType.java b/src/io/github/sspanak/tt9/ime/helpers/InputType.java index d2e0d8787..e8227c86a 100644 --- a/src/io/github/sspanak/tt9/ime/helpers/InputType.java +++ b/src/io/github/sspanak/tt9/ime/helpers/InputType.java @@ -33,17 +33,18 @@ public boolean isLimited() { /** - * isDialer - * Dialer fields seem to take care of numbers and backspace on their own, + * isSpecialNumeric + * Calculator and Dialer fields seem to take care of numbers and backspace on their own, * so we need to be aware of them. * * NOTE: A Dialer field is not the same as Phone field. Dialer is where you * actually dial and call a phone number. While the Phone field is a text * field in any app or a webpage, intended for typing phone numbers. * - * More info: in this Github issue. + * More info: in this Github issue + * and the PR about calculators. */ - public boolean isDialer() { + public boolean isSpecialNumeric() { if (field == null) { return false; } @@ -51,7 +52,8 @@ public boolean isDialer() { int inputType = field.inputType & android.text.InputType.TYPE_MASK_CLASS; return - inputType == android.text.InputType.TYPE_CLASS_PHONE && field.packageName.equals("com.android.dialer") || inputType == android.text.InputType.TYPE_CLASS_NUMBER && field.packageName.contains("com.android.calculator"); + inputType == android.text.InputType.TYPE_CLASS_PHONE && field.packageName.equals("com.android.dialer") + || inputType == android.text.InputType.TYPE_CLASS_NUMBER && field.packageName.contains("com.android.calculator"); } diff --git a/src/io/github/sspanak/tt9/ime/helpers/TextField.java b/src/io/github/sspanak/tt9/ime/helpers/TextField.java index b80145d5b..2d2ab23ec 100644 --- a/src/io/github/sspanak/tt9/ime/helpers/TextField.java +++ b/src/io/github/sspanak/tt9/ime/helpers/TextField.java @@ -90,9 +90,10 @@ public ArrayList determineInputModes(InputType inputType) { return allowedModes; } - // Dialer field, not to be confused with Phone text field. - // It only accepts 0-9, "#" and "*". - if (inputType.isDialer()) { + // Calculators (support only 0-9 and math) and Dialer (0-9, "#" and "*"), + // handle all input themselves, so we are supposed to pass through all key presses. + // Note: A Dialer field is not a Phone number field. + if (inputType.isSpecialNumeric()) { allowedModes.add(InputMode.MODE_PASSTHROUGH); return allowedModes; } diff --git a/src/io/github/sspanak/tt9/ime/modes/ModePassthrough.java b/src/io/github/sspanak/tt9/ime/modes/ModePassthrough.java index 29cdbd798..b70f61e74 100644 --- a/src/io/github/sspanak/tt9/ime/modes/ModePassthrough.java +++ b/src/io/github/sspanak/tt9/ime/modes/ModePassthrough.java @@ -2,7 +2,7 @@ import androidx.annotation.NonNull; -// see: InputType.isDialer() +// see: InputType.isSpecialNumeric() public class ModePassthrough extends InputMode { ModePassthrough() { reset();