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 flag to disable the soft keyboard. #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Or for latest snapshot:
* `pinInputType` - Set the input type, default number, options:
* `text` - full keyboard, any available character allowed
* `number` - numeric keyboard, only numbers allowed
* `softKeyboardAllowed` - show soft keyboard on touch? default true

## License

Expand Down
14 changes: 13 additions & 1 deletion pinentry/src/main/java/me/philio/pinentry/PinEntryView.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public class PinEntryView extends ViewGroup {
*/
private boolean accentRequiresFocus;

/**
* If set to false, on touch of the DigitView soft keyboard will not be shown
* If set to true, default behaviour
*/
private boolean softKeyboardAllowed = true;

public PinEntryView(Context context) {
this(context, null);
}
Expand Down Expand Up @@ -171,6 +177,8 @@ public PinEntryView(Context context, AttributeSet attrs, int defStyle) {
// Accent shown, default to only when focused
accentRequiresFocus = array.getBoolean(R.styleable.PinEntryView_accentRequiresFocus, true);

softKeyboardAllowed = array.getBoolean(R.styleable.PinEntryView_softKeyboardAllowed, true);

// Recycle the typed array
array.recycle();

Expand Down Expand Up @@ -214,7 +222,7 @@ public PinEntryView(Context context, AttributeSet attrs, int defStyle) {
}

@Override public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (event.getAction() == MotionEvent.ACTION_DOWN && isSoftKeyboardAllowed()) {
// Make sure this view is focused
editText.requestFocus();

Expand Down Expand Up @@ -369,6 +377,10 @@ public boolean getAccentRequiresFocus() {
return accentRequiresFocus;
}

public boolean isSoftKeyboardAllowed() {
return softKeyboardAllowed;
}

/**
* Create views and add them to the view group
*/
Expand Down
2 changes: 2 additions & 0 deletions pinentry/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@
</attr>
<!-- Only draw accent when View has focus -->
<attr name="accentRequiresFocus" format="boolean" />
<!-- On touch of DigitView should we request focus on the hidden EditText? -->
<attr name="softKeyboardAllowed" format="boolean" />
</declare-styleable>
</resources>