Skip to content

Commit

Permalink
Don't focus credit card by default. Add mechanism for clients to focu…
Browse files Browse the repository at this point in the history
…s any field if desired.
  • Loading branch information
dbachelder committed Apr 21, 2015
1 parent 840625a commit 2c57305
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ public void onClick(View v) {
focusOnField(creditCardText);
}
});

creditCardText.requestFocus();
}

@Override
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 2c57305

Please sign in to comment.