-
Notifications
You must be signed in to change notification settings - Fork 664
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
Add formatted content description for Expiration Date text field #10185
Conversation
stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/TextFieldUI.kt
Outdated
Show resolved
Hide resolved
stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/TextFieldUI.kt
Outdated
Show resolved
Hide resolved
stripe-ui-core/src/main/java/com/stripe/android/uicore/elements/TextFieldUI.kt
Outdated
Show resolved
Hide resolved
return resolvableString(R.string.stripe_expiration_date_empty_content_description) | ||
} | ||
|
||
val canOnlyBeSingleDigitMonth = input.isNotBlank() && !(input[0] == '0' || input[0] == '1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This split logic taken from ExpiryDateVisualTransformation
Diffuse output:
APK
DEX
ARSC
|
...-ui-core/src/test/java/com/stripe/android/utils/ExpiryDateContentDescriptionFormatterTest.kt
Show resolved
Hide resolved
|
||
return input.resolvableString | ||
} catch (e: Exception) { | ||
return input.resolvableString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which exceptions are we catching here and why is it ok to ignore them?
Can you consider:
- catching specific exceptions here
- adding a comment about why it is ok that we are ignoring the exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to ParseException
and left a comment on why it's fine to ignore. ParseException
should never be thrown but since the text passed in here is coming directly from the TextField input we don't want to crash the app if somehow a non numeric string is entered
…t description as the label has been removed from semantics
Summary
Adds custom content description for expiry date text field
Adds
formatExpirationDateForAccessibility
which takes raw input from Expiry Date text field and returns a resolvable string formatted with month and yearFor the following inputs, a screen reader will announce:
""
->Expiration date. Two digit month and two digit year, empty
"4 /"
->Expiration date. April and two digit year, empty
"4 / 2"
->Expiration date. April and two digit year, incomplete
"4 / 25"
->Expiration date. April 2025
Motivation
Improve accessibility
Testing
Screen.Recording.2025-02-14.at.4.57.05.PM.mov