Read media durations as natural language for TalkBack#6465
Conversation
|
@CodeRabbit review |
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughThis pull request adds comprehensive accessibility enhancements by introducing a locale-aware ChangesAccessibility enhancements for audio/video durations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SDK Size Comparison 📏
|
ConfigurationCompat.getLocales(...)[0] can return null on a degenerate empty locale list. Crashing the app for a TalkBack content-description is disproportionate; Locale.getDefault() is a graceful fallback that costs nothing and stays correct.
The helper is used in audio, video, media badges, and quoted-message builders. Moving it out of PlaybackTimer.kt into SpokenDuration.kt (same package) makes it easier to locate without changing any call sites.
… off PlaybackTimerText and other playback / recording UIs recomputed the spoken duration on every frame, re-resolving the locale and calling MeasureFormat.getInstance(...) each time. Introduce SpokenDurationFormatter, which selects a strategy once at construction (locale-aware natural language on API 24+, the visible clock format below), and a rememberSpokenDurationFormatter helper that resolves locale once per composition and returns null when no accessibility service is active — call sites then skip setting contentDescription entirely in the common case.
PR #6441 refactored the recording overview content into OverviewPlaybackButton and OverviewPlaybackRow, and put a merged-row contentDescription on the row. During the rebase, the spoken-duration contentDescription that lived on the inline duration Text was dropped along with the inline body. Without it, TalkBack reads the visible "0:00" as "audio recording, zero hundred". Restore the spoken-duration contentDescription on the duration Text so the merged-row announcement becomes "audio recording, 0 seconds" and tracks the visible position while scrubbing.
ad66389 to
6efc257
Compare
|


AND-1180
Goal
TalkBack used to read media durations character by character ("zero colon two three"), which is slow and hard to parse. This PR makes durations spoken as natural language ("23 seconds", "1 minute 23 seconds") across every surface that displays a duration in the Compose SDK.
Implementation
spokenDurationhelper inPlaybackTimer.ktproduces a speech-friendly duration string viaMeasureFormat(API 24+), falling back to the existingChatTheme.durationFormatteron older API levels. A non-Composable variant is exposed for call sites that build strings outside Compose (QuotedMessageBodyBuilder).contentDescriptionon every visiblemm:ssTextwhile keeping the displayed text unchanged:PlaybackTimerText)AudioRecordingContent)VideoPlaybackControls)VideoBadgeandAudioBadge(MediaBadges)QuotedMessageBody.spokenTextpopulated byQuotedMessageBodyBuilder, consumed byQuotedMessageText)No visible UI changes; the rendered text and layout are unchanged.
Testing
Summary by CodeRabbit