diff --git a/README.md b/README.md index 7cd81d8..44d5171 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java b/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java index 8ff5e1d..bb53730 100644 --- a/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java +++ b/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java @@ -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); } @@ -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(); @@ -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(); @@ -369,6 +377,10 @@ public boolean getAccentRequiresFocus() { return accentRequiresFocus; } + public boolean isSoftKeyboardAllowed() { + return softKeyboardAllowed; + } + /** * Create views and add them to the view group */ diff --git a/pinentry/src/main/res/values/attrs.xml b/pinentry/src/main/res/values/attrs.xml index 6d2f172..beddf25 100644 --- a/pinentry/src/main/res/values/attrs.xml +++ b/pinentry/src/main/res/values/attrs.xml @@ -35,5 +35,7 @@ + + \ No newline at end of file