@Override public void onTextChanged(String text) { if (ViewUtils.isCvcMaximalLength(mCardBrand, text)) { updateBrand(mCardBrand); if (mShouldShowPostalCode) { mPostalCodeEditText.requestFocus(); } if (mCardInputListener != null) { mCardInputListener.onCvcComplete(); } } else { flipToCvcIconIfNotFinished(); } mCvcEditText.setShouldShowError(false); } });
@Override public void onTextChanged(String text) { if (mCardInputListener != null && ViewUtils.isCvcMaximalLength (mCardNumberEditText.getCardBrand(), text)) { mCardInputListener.onCvcComplete(); } updateIconCvc(mCardNumberEditText.getCardBrand(), mCvcNumberEditText.hasFocus(), text); } });
@Test public void onCompleteCvc_whenValid_shiftsFocusOnlyIfPostalCodeShown() { mCardMultilineWidget.setCardInputListener(mFullCardListener); mNoZipCardMultilineWidget.setCardInputListener(mNoZipCardListener); mFullGroup.cardNumberEditText.setText(VALID_VISA_WITH_SPACES); mFullGroup.expiryDateEditText.append("12"); mFullGroup.expiryDateEditText.append("50"); mFullGroup.cvcEditText.append("123"); verify(mFullCardListener, times(1)).onCvcComplete(); verify(mFullCardListener, times(1)).onFocusChange(FOCUS_POSTAL); assertTrue(mFullGroup.postalCodeEditText.hasFocus()); mNoZipGroup.cardNumberEditText.setText(VALID_VISA_WITH_SPACES); mNoZipGroup.expiryDateEditText.append("12"); mNoZipGroup.expiryDateEditText.append("50"); mNoZipGroup.cvcEditText.append("123"); verify(mNoZipCardListener, times(1)).onCvcComplete(); verify(mNoZipCardListener, times(0)).onFocusChange(FOCUS_POSTAL); assertTrue(mNoZipGroup.cvcEditText.hasFocus()); }