[Media TTT] Add "loading" to the content description if needed.

Fixes: 261992171
Test: `adb shell cmd statusbar media-ttt-chip-sender MyTablet
TRANSFER_TO_THIS_DEVICE_TRIGGERED` -> "loading" is in content
description
Test: `adb shell cmd statusbar media-ttt-chip-sender MyTablet
TRANSFER_TO_THIS_DEVICE_SUCCEEDED` -> "loading" is not in content
description
Test: atest ChipbarCoordinatorTest

Change-Id: I3f8392574008b908878843edcd4ef6d60d87f4d4
This commit is contained in:
Caitlin Shkuratov
2023-01-03 21:19:15 +00:00
parent c3f30502f8
commit 7d7cf4131f
3 changed files with 46 additions and 3 deletions

View File

@@ -2362,6 +2362,8 @@
<string name="media_transfer_playing_different_device">Playing on <xliff:g id="deviceName" example="My Tablet">%1$s</xliff:g></string>
<!-- Text informing the user that the media transfer has failed because something went wrong. [CHAR LIsMIT=50] -->
<string name="media_transfer_failed">Something went wrong. Try again.</string>
<!-- Text to indicate that a media transfer is currently in-progress, aka loading. [CHAR LIMIT=NONE] -->
<string name="media_transfer_loading">Loading</string>
<!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] -->
<string name="controls_error_timeout">Inactive, check app</string>

View File

@@ -173,9 +173,16 @@ open class ChipbarCoordinator @Inject constructor(
} else {
""
}
val endItemDesc =
if (newInfo.endItem is ChipbarEndItem.Loading) {
". ${context.resources.getString(R.string.media_transfer_loading)}."
} else {
""
}
val chipInnerView = currentView.getInnerView()
chipInnerView.contentDescription = "$loadedIconDesc${newInfo.text.loadText(context)}"
chipInnerView.contentDescription =
"$loadedIconDesc${newInfo.text.loadText(context)}$endItemDesc"
chipInnerView.accessibilityLiveRegion = ACCESSIBILITY_LIVE_REGION_ASSERTIVE
maybeGetAccessibilityFocus(newInfo, currentView)

View File

@@ -124,7 +124,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
)
)
val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner)
val contentDescView = getChipbarView().getInnerView()
assertThat(contentDescView.contentDescription.toString()).contains("loadedCD")
assertThat(contentDescView.contentDescription.toString()).contains("text")
}
@@ -139,10 +139,42 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
)
)
val contentDescView = getChipbarView().requireViewById<ViewGroup>(R.id.chipbar_inner)
val contentDescView = getChipbarView().getInnerView()
assertThat(contentDescView.contentDescription.toString()).isEqualTo("text")
}
@Test
fun displayView_contentDescription_endIsLoading() {
underTest.displayView(
createChipbarInfo(
Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")),
Text.Loaded("text"),
endItem = ChipbarEndItem.Loading,
)
)
val contentDescView = getChipbarView().getInnerView()
val loadingDesc = context.resources.getString(R.string.media_transfer_loading)
assertThat(contentDescView.contentDescription.toString()).contains("text")
assertThat(contentDescView.contentDescription.toString()).contains(loadingDesc)
}
@Test
fun displayView_contentDescription_endNotLoading() {
underTest.displayView(
createChipbarInfo(
Icon.Resource(R.drawable.ic_cake, ContentDescription.Loaded("loadedCD")),
Text.Loaded("text"),
endItem = ChipbarEndItem.Error,
)
)
val contentDescView = getChipbarView().getInnerView()
val loadingDesc = context.resources.getString(R.string.media_transfer_loading)
assertThat(contentDescView.contentDescription.toString()).contains("text")
assertThat(contentDescView.contentDescription.toString()).doesNotContain(loadingDesc)
}
@Test
fun displayView_loadedIcon_correctlyRendered() {
val drawable = context.getDrawable(R.drawable.ic_celebration)!!
@@ -417,6 +449,8 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
)
}
private fun ViewGroup.getInnerView() = this.requireViewById<ViewGroup>(R.id.chipbar_inner)
private fun ViewGroup.getStartIconView() = this.requireViewById<ImageView>(R.id.start_icon)
private fun ViewGroup.getChipText(): String =