Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added OR operator for calculator app #326

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/io/github/sspanak/tt9/ime/helpers/InputType.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ 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: <a href="https://github.com/sspanak/tt9/issues/46">in this Github issue</a>.
* More info: <a href="https://github.com/sspanak/tt9/issues/46">in this Github issue</a>
* and <a href="https://github.com/sspanak/tt9/pull/326">the PR about calculators</a>.
*/
public boolean isDialer() {
public boolean isSpecialNumeric() {
if (field == null) {
return false;
}

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 && field.packageName.contains("com.android.calculator");
}


Expand Down
7 changes: 4 additions & 3 deletions src/io/github/sspanak/tt9/ime/helpers/TextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ public ArrayList<Integer> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/io/github/sspanak/tt9/ime/modes/ModePassthrough.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import androidx.annotation.NonNull;

// see: InputType.isDialer()
// see: InputType.isSpecialNumeric()
public class ModePassthrough extends InputMode {
ModePassthrough() {
reset();
Expand Down
Loading