Loading packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +8 −5 Original line number Diff line number Diff line Loading @@ -156,11 +156,14 @@ open class ChipbarCoordinator @Inject constructor( } // ---- Overall accessibility ---- currentView.requireViewById<ViewGroup>( R.id.chipbar_inner ).contentDescription = "${newInfo.startIcon.icon.contentDescription.loadContentDescription(context)} " + "${newInfo.text.loadText(context)}" val iconDesc = newInfo.startIcon.icon.contentDescription val loadedIconDesc = if (iconDesc != null) { "${iconDesc.loadContentDescription(context)} " } else { "" } currentView.requireViewById<ViewGroup>(R.id.chipbar_inner).contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}" // ---- Haptics ---- newInfo.vibrationEffect?.let { Loading packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,35 @@ class ChipbarCoordinatorTest : SysuiTestCase() { underTest.start() } @Test fun displayView_contentDescription_iconHasDescription() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")), Text.Loaded("text"), endItem = null, ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) assertThat(contentDescView.contentDescription.toString()).contains("loadedCD") assertThat(contentDescView.contentDescription.toString()).contains("text") } @Test fun displayView_contentDescription_iconHasNoDescription() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, contentDescription = null), Text.Loaded("text"), endItem = null, ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) assertThat(contentDescView.contentDescription.toString()).isEqualTo("text") } @Test fun displayView_loadedIcon_correctlyRendered() { val drawable = context.getDrawable(R.drawable.ic_celebration)!! Loading Loading
packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +8 −5 Original line number Diff line number Diff line Loading @@ -156,11 +156,14 @@ open class ChipbarCoordinator @Inject constructor( } // ---- Overall accessibility ---- currentView.requireViewById<ViewGroup>( R.id.chipbar_inner ).contentDescription = "${newInfo.startIcon.icon.contentDescription.loadContentDescription(context)} " + "${newInfo.text.loadText(context)}" val iconDesc = newInfo.startIcon.icon.contentDescription val loadedIconDesc = if (iconDesc != null) { "${iconDesc.loadContentDescription(context)} " } else { "" } currentView.requireViewById<ViewGroup>(R.id.chipbar_inner).contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}" // ---- Haptics ---- newInfo.vibrationEffect?.let { Loading
packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +29 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,35 @@ class ChipbarCoordinatorTest : SysuiTestCase() { underTest.start() } @Test fun displayView_contentDescription_iconHasDescription() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")), Text.Loaded("text"), endItem = null, ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) assertThat(contentDescView.contentDescription.toString()).contains("loadedCD") assertThat(contentDescView.contentDescription.toString()).contains("text") } @Test fun displayView_contentDescription_iconHasNoDescription() { underTest.displayView( createChipbarInfo( Icon.Resource(R.drawable.ic_cake, contentDescription = null), Text.Loaded("text"), endItem = null, ) ) val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner) assertThat(contentDescView.contentDescription.toString()).isEqualTo("text") } @Test fun displayView_loadedIcon_correctlyRendered() { val drawable = context.getDrawable(R.drawable.ic_celebration)!! Loading