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 f0ffde6 commit b0f1e95
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 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
2 changes: 1 addition & 1 deletion src/io/github/sspanak/tt9/ime/helpers/TextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public ArrayList<Integer> determineInputModes(InputType inputType) {

// Dialer field, not to be confused with Phone text field.
// It only accepts 0-9, "#" and "*".
if (inputType.isDialer()) {
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 b0f1e95

Please sign in to comment.