From 0e5b3d536f58ada1c14cdb3d239eb682ee4fae6c Mon Sep 17 00:00:00 2001 From: Sankaran Kaliappan Date: Fri, 29 Sep 2017 09:20:31 +0530 Subject: [PATCH 1/2] Added flag to disable the soft keyboard. Fixes: #18, #39, enables the developer to have custom keyboard as requested in #10 --- .../main/java/me/philio/pinentry/PinEntryView.java | 12 +++++++++++- pinentry/src/main/res/values/attrs.xml | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java b/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java index 8ff5e1d..69bdfd9 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); } @@ -214,7 +220,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 +375,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 From 434736d6d5e0224050bac5b0752ea9fc3fe6ff3c Mon Sep 17 00:00:00 2001 From: Sankaran Kaliappan Date: Fri, 29 Sep 2017 09:48:50 +0530 Subject: [PATCH 2/2] Added flag to disable the soft keyboard. Fixes: #18, #39, enables the developer to have custom keyboard as requested in #10 --- README.md | 1 + pinentry/src/main/java/me/philio/pinentry/PinEntryView.java | 2 ++ 2 files changed, 3 insertions(+) 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 69bdfd9..bb53730 100644 --- a/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java +++ b/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java @@ -177,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();