Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ExpiryDateEditText allowlist #2976

Merged
merged 1 commit into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions stripe/res/layout/card_input_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:imeOptions="actionNext"
android:inputType="date"
android:maxLength="5"
android:digits="@string/stripe_expiration_date_allowlist"
android:hint="@string/expiry_date_hint"
style="@style/Stripe.CardInputWidget.EditText"
/>
Expand Down
3 changes: 1 addition & 2 deletions stripe/res/layout/card_multiline_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="date"
android:maxLength="@integer/stripe_date_length"
android:digits="@string/stripe_expiration_date_allowlist"
android:nextFocusDown="@+id/et_cvc"
android:nextFocusForward="@+id/et_cvc"
/>
Expand Down
1 change: 1 addition & 0 deletions stripe/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<string name="cvc_amex_hint">CVV</string>
<string name="cvc_multiline_helper">123</string>
<string name="cvc_multiline_helper_amex">1234</string>
<string name="stripe_expiration_date_allowlist">0123456789/</string>
<string name="zip_helper">12345</string>
<string name="paymentsheet_payment_method_item_card_number" translatable="false">····%1$s</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.stripe.android.view
import android.content.Context
import android.os.Build
import android.text.Editable
import android.text.InputFilter
import android.text.InputType
import android.util.AttributeSet
import android.view.View
import android.widget.EditText
Expand All @@ -20,6 +22,13 @@ class ExpiryDateEditText @JvmOverloads constructor(
) : StripeEditText(context, attrs, defStyleAttr) {

init {
inputType = InputType.TYPE_CLASS_NUMBER
filters = listOf(
InputFilter.LengthFilter(
context.resources.getInteger(R.integer.stripe_date_length)
)
).toTypedArray()

setErrorMessage(resources.getString(R.string.invalid_expiry_year))
listenForTextChanges()

Expand Down