Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
sspanak committed Aug 1, 2023
1 parent ffc6b83 commit b68d5c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
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_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");
}


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

0 comments on commit b68d5c6

Please sign in to comment.