diff options
| author | 2024-06-26 13:59:57 +0000 | |
|---|---|---|
| committer | 2024-06-26 13:59:57 +0000 | |
| commit | 4982392a3884a2ca58bc90e7bd40d50ce518da94 (patch) | |
| tree | cbc98772d5b9104c735d4d5bc7a0861e3ba0f5c6 | |
| parent | 5b390559b78ecd3f7352414d707b44c0551b6f24 (diff) | |
| parent | c9cd5689b8a3871dd590a0d557a5e4563587e9ee (diff) | |
Merge "[SB][Screen Chips] Make chips accessible." into main
11 files changed, 53 insertions, 7 deletions
diff --git a/packages/SystemUI/res/layout/ongoing_activity_chip.xml b/packages/SystemUI/res/layout/ongoing_activity_chip.xml index beb16b38e6e0..154397d2b4a1 100644 --- a/packages/SystemUI/res/layout/ongoing_activity_chip.xml +++ b/packages/SystemUI/res/layout/ongoing_activity_chip.xml @@ -34,13 +34,13 @@ android:background="@drawable/ongoing_activity_chip_bg" android:paddingStart="@dimen/ongoing_activity_chip_side_padding" android:paddingEnd="@dimen/ongoing_activity_chip_side_padding" - android:contentDescription="@string/ongoing_phone_call_content_description" android:minWidth="@dimen/min_clickable_item_size" > <ImageView android:src="@*android:drawable/ic_phone" android:id="@+id/ongoing_activity_chip_icon" + android:contentDescription="@string/ongoing_phone_call_content_description" android:layout_width="@dimen/ongoing_activity_chip_icon_size" android:layout_height="@dimen/ongoing_activity_chip_icon_size" android:tint="?android:attr/colorPrimary" diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index f533cb84da03..31a999bf845e 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -330,6 +330,8 @@ <!-- Button to stop a screen recording [CHAR LIMIT=35] --> <string name="screenrecord_stop_dialog_button">Stop recording</string> + <!-- Content description for the status bar chip shown to the user when they're sharing their screen to another app on the device [CHAR LIMIT=NONE] --> + <string name="share_to_app_chip_accessibility_label">Sharing screen</string> <!-- Title for a dialog shown to the user that will let them stop sharing their screen to another app on the device [CHAR LIMIT=50] --> <string name="share_to_app_stop_dialog_title">Stop sharing screen?</string> <!-- Text telling a user that they will stop sharing their screen if they click the "Stop sharing" button [CHAR LIMIT=100] --> @@ -339,6 +341,8 @@ <!-- Button to stop screen sharing [CHAR LIMIT=35] --> <string name="share_to_app_stop_dialog_button">Stop sharing</string> + <!-- Content description for the status bar chip shown to the user when they're casting their screen to a different device [CHAR LIMIT=NONE] --> + <string name="cast_to_other_device_chip_accessibility_label">Casting screen</string> <!-- Title for a dialog shown to the user that will let them stop casting their screen to a different device [CHAR LIMIT=50] --> <string name="cast_to_other_device_stop_dialog_title">Stop casting screen?</string> <!-- Text telling a user that they will stop casting their screen to a different device if they click the "Stop casting" button [CHAR LIMIT=100] --> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt index 79f1874c1f32..3562fd1e9134 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.chips.call.ui.viewmodel import android.view.View import com.android.internal.jank.InteractionJankMonitor import com.android.systemui.animation.ActivityTransitionAnimator +import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application @@ -65,7 +66,9 @@ constructor( icon = Icon.Resource( com.android.internal.R.drawable.ic_phone, - contentDescription = null, + ContentDescription.Resource( + R.string.ongoing_phone_call_content_description, + ), ), colors = ColorsModel.Themed, startTimeMs = startTimeInElapsedRealtime, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt index 42e921ec2b69..73ccaab68ae9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt @@ -85,7 +85,13 @@ constructor( icon = Icon.Resource( CAST_TO_OTHER_DEVICE_ICON, - ContentDescription.Resource(R.string.accessibility_casting), + // Note: This string is "Casting screen", which is okay right now because this + // chip does not currently support audio-only casting. If the chip starts + // supporting audio-only casting (see b/342169876), update the content + // description to just "Casting". + ContentDescription.Resource( + R.string.cast_to_other_device_chip_accessibility_label, + ), ), colors = ColorsModel.Red, // TODO(b/332662551): Maybe use a MediaProjection API to fetch this time. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt index af6d7f27eddd..53679f1c0a6c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.chips.screenrecord.ui.viewmodel import android.app.ActivityManager import androidx.annotation.DrawableRes import com.android.systemui.animation.DialogTransitionAnimator +import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application @@ -64,8 +65,13 @@ constructor( } is ScreenRecordChipModel.Recording -> { OngoingActivityChipModel.Shown.Timer( - // TODO(b/332662551): Also provide a content description. - icon = Icon.Resource(ICON, contentDescription = null), + icon = + Icon.Resource( + ICON, + ContentDescription.Resource( + R.string.screenrecord_ongoing_screen_only, + ), + ), colors = ColorsModel.Red, startTimeMs = systemClock.elapsedRealtime(), createDialogLaunchOnClickListener( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt index c3b145624aba..8aef5a4e7629 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.chips.sharetoapp.ui.viewmodel import androidx.annotation.DrawableRes import com.android.systemui.animation.DialogTransitionAnimator +import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.Icon import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application @@ -78,8 +79,11 @@ constructor( state: ProjectionChipModel.Projecting, ): OngoingActivityChipModel.Shown { return OngoingActivityChipModel.Shown.Timer( - // TODO(b/332662551): Use the right content description. - icon = Icon.Resource(SHARE_TO_APP_ICON, contentDescription = null), + icon = + Icon.Resource( + SHARE_TO_APP_ICON, + ContentDescription.Resource(R.string.share_to_app_chip_accessibility_label), + ), colors = ColorsModel.Red, // TODO(b/332662551): Maybe use a MediaProjection API to fetch this time. startTimeMs = systemClock.elapsedRealtime(), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt index 68983a1a10b3..631befc5dd29 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/CollapsedStatusBarViewBinder.kt @@ -108,6 +108,9 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa setChipMainContent(chipModel, chipTextView, chipTimeView) chipView.setOnClickListener(chipModel.onClickListener) + // Accessibility + setChipAccessibility(chipModel, chipView) + // Colors val textColor = chipModel.colors.text(chipContext) chipIconView.imageTintList = ColorStateList.valueOf(textColor) @@ -116,6 +119,7 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa (chipBackgroundView.background as GradientDrawable).color = chipModel.colors.background(chipContext) + // Notify listeners listener.onOngoingActivityStatusChanged( hasOngoingActivity = true ) @@ -191,6 +195,18 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa this.setPaddingRelative(/* start= */ 0, paddingTop, paddingEnd, paddingBottom) } + private fun setChipAccessibility(chipModel: OngoingActivityChipModel.Shown, chipView: View) { + when (chipModel) { + is OngoingActivityChipModel.Shown.Countdown -> { + // Set as assertive so talkback will announce the countdown + chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE + } + is OngoingActivityChipModel.Shown.Timer -> { + chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE + } + } + } + private fun animateLightsOutView(view: View, visible: Boolean) { view.animate().cancel() diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt index c3e810ed1e31..6cab71fd8e88 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt @@ -105,6 +105,8 @@ class CallChipViewModelTest : SysuiTestCase() { assertThat(((latest as OngoingActivityChipModel.Shown).icon as Icon.Resource).res) .isEqualTo(com.android.internal.R.drawable.ic_phone) + assertThat((latest as OngoingActivityChipModel.Shown).icon!!.contentDescription) + .isNotNull() } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt index bde668ece83f..74b6ae2f9379 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt @@ -104,6 +104,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) val icon = (latest as OngoingActivityChipModel.Shown).icon assertThat((icon as Icon.Resource).res).isEqualTo(R.drawable.ic_cast_connected) + assertThat(icon.contentDescription).isNotNull() } @Test @@ -117,6 +118,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) val icon = (latest as OngoingActivityChipModel.Shown).icon assertThat((icon as Icon.Resource).res).isEqualTo(R.drawable.ic_cast_connected) + assertThat(icon.contentDescription).isNotNull() } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt index 8e8b0820110d..0a06cc773727 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt @@ -143,6 +143,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) val icon = (latest as OngoingActivityChipModel.Shown).icon assertThat((icon as Icon.Resource).res).isEqualTo(R.drawable.ic_screenrecord) + assertThat(icon.contentDescription).isNotNull() } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt index 2e5f7f55031c..3028d008f01d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt @@ -129,6 +129,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) val icon = (latest as OngoingActivityChipModel.Shown).icon assertThat((icon as Icon.Resource).res).isEqualTo(R.drawable.ic_present_to_all) + assertThat(icon.contentDescription).isNotNull() } @Test @@ -142,6 +143,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) val icon = (latest as OngoingActivityChipModel.Shown).icon assertThat((icon as Icon.Resource).res).isEqualTo(R.drawable.ic_present_to_all) + assertThat(icon.contentDescription).isNotNull() } @Test |