Repository navigation
fix(android): announce real minutes for spinner with minuteInterval - #1071
Open
pebblechris wants to merge 1 commit into
Open
pebblechris wants to merge 1 commit into
pebblechris wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Android, when
display="spinner"is used with a customminuteInterval, TalkBack announces the wrong time. For example, withminuteInterval={15}and 12:15 selected, TalkBack announces "12:01".Cause
To show only interval-aligned minutes,
MinuteIntervalSnappableTimePickerDialogturns the minuteNumberPickerinto an index picker and usessetDisplayedValues()to show the labels (00,15,30,45). The labels are correct, but theTimePicker's minute value is now the index.When the time changes, the platform's
TimePickerSpinnerDelegatesendsTYPE_VIEW_SELECTEDand builds the announcement inonPopulateAccessibilityEvent()fromgetHour()/getMinute(). Index1is therefore announced as minute1.Fix
In the existing spinner branch of
setupPickerDialog(), set aView.AccessibilityDelegateon theTimePicker. It overridesdispatchPopulateAccessibilityEvent()and builds the announcement fromgetRealMinutes()(index × interval). The time is formatted the same way as the platform:DateUtils.formatDateTime()withFORMAT_SHOW_TIMEand the 12/24-hour flag fromis24HourView().dispatchPopulateAccessibilityEvent()is overridden rather thanonPopulateAccessibilityEvent()becauseTimePicker.dispatchPopulateAccessibilityEventInternal()calls its internal delegate directly, which adds the platform text without going throughView.onPopulateAccessibilityEvent(). Overriding onlyonPopulate…still adds the wrong text. The platform's dispatch adds nothing besides that announcement, so nothing else is lost.Impact
display="spinner"with a non-defaultminuteIntervalon Android.Test Plan
What's required for testing (prerequisites)?
yarn start, thenyarn start:androidWhat are the steps to reproduce (after prerequisites)?
spinnerand minute interval prop to15.Verified:
Compatibility
Checklist
README.md(N/A)example/App.js) (N/A — existing example covers it)