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

Make sure CVC, Date, and card number are always LTR regardless of the language #3524

Merged
merged 2 commits into from
Mar 26, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ import kotlin.properties.Delegates
*
* The individual `EditText` views of this widget can be styled by defining a style
* `Stripe.CardInputWidget.EditText` that extends `Stripe.Base.CardInputWidget.EditText`.
*
* The card number, cvc, and expiry date will always be left to right regardless of locale. Postal
* code layout direction will be set according to the locale.
*/
class CardInputWidget @JvmOverloads constructor(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import kotlin.properties.Delegates
*
* To enable 19-digit card support, [PaymentConfiguration.init] must be called before
* [CardMultilineWidget] is instantiated.
*
* The card number, cvc, and expiry date will always be left to right regardless of locale. Postal
* code layout direction will be set according to the locale.
*/
class CardMultilineWidget @JvmOverloads constructor(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class CardNumberEditText internal constructor(
}

updateLengthFilter()

this.layoutDirection = LAYOUT_DIRECTION_LTR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done in StripeEditText?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That feels like a wide sweep, like if you used it for email address, that wouldn't work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Should we do this for PostalCodeEditText?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can we add a comment in the card widgets that they are LTR only if we don't already have that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a little research, and from what I found the postal code edit text is functionality as other apps. I did make a note in the comment as well that this was explicit.

}

override fun onAttachedToWindow() {
Expand Down
2 changes: 2 additions & 0 deletions stripe/src/main/java/com/stripe/android/view/CvcEditText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class CvcEditText @JvmOverloads constructor(
shouldShowError = true
}
}

layoutDirection = LAYOUT_DIRECTION_LTR
}

override val accessibilityText: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class ExpiryDateEditText @JvmOverloads constructor(
shouldShowError = true
}
}

layoutDirection = LAYOUT_DIRECTION_LTR
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried several different approaches to try to set this up in robolectric without any luck.

/**
Expand Down