Skip to content

Commit

Permalink
Add CardInputWidget#setPostalCodeTextWatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
mshafrir-stripe committed Feb 20, 2020
1 parent 3c884cd commit 0f1a0aa
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
13 changes: 10 additions & 3 deletions stripe/src/main/java/com/stripe/android/view/CardInputWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -381,24 +381,31 @@ class CardInputWidget @JvmOverloads constructor(
/**
* Expose a text watcher to receive updates when the card number is changed.
*/
fun setCardNumberTextWatcher(cardNumberTextWatcher: TextWatcher?) {
override fun setCardNumberTextWatcher(cardNumberTextWatcher: TextWatcher?) {
cardNumberEditText.addTextChangedListener(cardNumberTextWatcher)
}

/**
* Expose a text watcher to receive updates when the expiry date is changed.
*/
fun setExpiryDateTextWatcher(expiryDateTextWatcher: TextWatcher?) {
override fun setExpiryDateTextWatcher(expiryDateTextWatcher: TextWatcher?) {
expiryDateEditText.addTextChangedListener(expiryDateTextWatcher)
}

/**
* Expose a text watcher to receive updates when the cvc number is changed.
*/
fun setCvcNumberTextWatcher(cvcNumberTextWatcher: TextWatcher?) {
override fun setCvcNumberTextWatcher(cvcNumberTextWatcher: TextWatcher?) {
cvcNumberEditText.addTextChangedListener(cvcNumberTextWatcher)
}

/**
* Expose a text watcher to receive updates when the cvc number is changed.
*/
override fun setPostalCodeTextWatcher(postalCodeTextWatcher: TextWatcher?) {
postalCodeEditText.addTextChangedListener(postalCodeTextWatcher)
}

/**
* Override of [View.isEnabled] that returns `true` only
* if all three sub-controls are enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,28 +415,28 @@ class CardMultilineWidget @JvmOverloads constructor(
/**
* Expose a text watcher to receive updates when the card number is changed.
*/
fun setCardNumberTextWatcher(cardNumberTextWatcher: TextWatcher?) {
override fun setCardNumberTextWatcher(cardNumberTextWatcher: TextWatcher?) {
cardNumberEditText.addTextChangedListener(cardNumberTextWatcher)
}

/**
* Expose a text watcher to receive updates when the expiry date is changed.
*/
fun setExpiryDateTextWatcher(expiryDateTextWatcher: TextWatcher?) {
override fun setExpiryDateTextWatcher(expiryDateTextWatcher: TextWatcher?) {
expiryDateEditText.addTextChangedListener(expiryDateTextWatcher)
}

/**
* Expose a text watcher to receive updates when the cvc number is changed.
*/
fun setCvcNumberTextWatcher(cvcNumberTextWatcher: TextWatcher?) {
override fun setCvcNumberTextWatcher(cvcNumberTextWatcher: TextWatcher?) {
cvcEditText.addTextChangedListener(cvcNumberTextWatcher)
}

/**
* Expose a text watcher to receive updates when the cvc number is changed.
*/
fun setPostalCodeTextWatcher(postalCodeTextWatcher: TextWatcher?) {
override fun setPostalCodeTextWatcher(postalCodeTextWatcher: TextWatcher?) {
postalCodeEditText.addTextChangedListener(postalCodeTextWatcher)
}

Expand Down
21 changes: 21 additions & 0 deletions stripe/src/main/java/com/stripe/android/view/CardWidget.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android.view

import android.text.TextWatcher
import androidx.annotation.IntRange
import com.stripe.android.model.Card
import com.stripe.android.model.PaymentMethodCreateParams
Expand Down Expand Up @@ -28,6 +29,26 @@ internal interface CardWidget {

fun setCardInputListener(listener: CardInputListener?)

/**
* Expose a text watcher to receive updates when the card number is changed.
*/
fun setCardNumberTextWatcher(cardNumberTextWatcher: TextWatcher?)

/**
* Expose a text watcher to receive updates when the expiry date is changed.
*/
fun setExpiryDateTextWatcher(expiryDateTextWatcher: TextWatcher?)

/**
* Expose a text watcher to receive updates when the cvc number is changed.
*/
fun setCvcNumberTextWatcher(cvcNumberTextWatcher: TextWatcher?)

/**
* Expose a text watcher to receive updates when the cvc number is changed.
*/
fun setPostalCodeTextWatcher(postalCodeTextWatcher: TextWatcher?)

fun setCardHint(cardHint: String)

fun clear()
Expand Down

0 comments on commit 0f1a0aa

Please sign in to comment.