Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.
Open
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
25 changes: 15 additions & 10 deletions card.io/src/main/java/io/card/payment/DataEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public final class DataEntryActivity extends Activity implements TextWatcher {
private int defaultTextColor;

private static final String TAG = DataEntryActivity.class.getSimpleName();

boolean requireExpiry;
boolean requireCVV;
boolean requirePostalCode;

@SuppressWarnings("ResourceType")
@Override
Expand Down Expand Up @@ -199,9 +203,9 @@ protected void onCreate(Bundle savedInstanceState) {
ViewUtil.setPadding(optionLayout, null, PADDING_DIP, null, PADDING_DIP);
optionLayout.setOrientation(LinearLayout.HORIZONTAL);

boolean requireExpiry = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, false);
boolean requireCVV = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false);
boolean requirePostalCode = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false);
requireExpiry = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, false);
requireCVV = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false);
requirePostalCode = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false);

if (requireExpiry) {
LinearLayout expiryLayout = new LinearLayout(this);
Expand Down Expand Up @@ -514,13 +518,14 @@ public void afterTextChanged(Editable et) {
} else {
setDefaultColor(numberEdit);
}

if (cvvEdit != null) {
CardType type = CardType.fromCardNumber(numberValidator.getValue().toString());
FixedLengthValidator v = (FixedLengthValidator) cvvValidator;
int length = type.cvvLength();
v.requiredLength = length;
cvvEdit.setHint(length == 4 ? "1234" : "123");
if (requireCVV) {
if (cvvEdit != null) {
CardType type = CardType.fromCardNumber(numberValidator.getValue().toString());
FixedLengthValidator v = (FixedLengthValidator) cvvValidator;
int length = type.cvvLength();
v.requiredLength = length;
cvvEdit.setHint(length == 4 ? "1234" : "123");
}
}
} else if (expiryEdit != null && et == expiryEdit.getText()) {
if (expiryValidator.hasFullLength()) {
Expand Down