From 2c57305e45910b554f691fa3415cd6c2a1eef6ed Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 Apr 2015 11:54:13 -0700 Subject: [PATCH] Don't focus credit card by default. Add mechanism for clients to focus any field if desired. --- .../internal/CreditCardEntry.java | 32 +++++++++++++++++-- .../library/CreditCardForm.java | 32 +++++++++++++++++++ README.md | 3 ++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java index 6b583f7..e51061e 100644 --- a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java +++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java @@ -119,8 +119,6 @@ public void onClick(View v) { focusOnField(creditCardText); } }); - - creditCardText.requestFocus(); } @Override @@ -292,6 +290,36 @@ public CreditCard getCreditCard() { creditCardText.getType()); } + /** + * request focus for the credit card field + */ + public void focusCreditCard() { + focusOnField(creditCardText); + } + + /** + * request focus for the expiration field + */ + public void focusExp() { + focusOnField(expDateText); + } + + /** + * request focus for the security code field + */ + public void focusSecurityCode() { + focusOnField(securityCodeText); + } + + /** + * request focus for the zip field (IF it's enabled) + */ + public void focusZip() { + if (includeZip) { + focusOnField(zipCodeText); + } + } + private void hideKeyboard() { InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(this.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/library/CreditCardForm.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/library/CreditCardForm.java index 5e6eb37..c087d42 100644 --- a/CreditCardEntry/src/com/devmarvel/creditcardentry/library/CreditCardForm.java +++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/library/CreditCardForm.java @@ -137,4 +137,36 @@ public boolean isCreditCardValid() { public CreditCard getCreditCard() { return entry.getCreditCard(); } + + /** + * request focus for the credit card field + */ + @SuppressWarnings("unused") + public void focusCreditCard() { + entry.focusCreditCard(); + } + + /** + * request focus for the expiration field + */ + @SuppressWarnings("unused") + public void focusExp() { + entry.focusExp(); + } + + /** + * request focus for the security code field + */ + @SuppressWarnings("unused") + public void focusSecurityCode() { + entry.focusSecurityCode(); + } + + /** + * request focus for the zip field (IF it's enabled) + */ + @SuppressWarnings("unused") + public void focusZip() { + entry.focusZip(); + } } diff --git a/README.md b/README.md index 59f037b..0704b03 100644 --- a/README.md +++ b/README.md @@ -136,4 +136,7 @@ In code: - Expose CardType on CreditCard object - Transferred repo ownership +###4/21/2015 + - Don't focus credit card by default. Add mechanism for clients to focus any field if desired. + [1]: https://raw.github.com/dbachelder/CreditCardEntry/master/demo.gif "Demo GIF"