diff --git a/packages/SystemUI/ktfmt_includes.txt b/packages/SystemUI/ktfmt_includes.txt
index bda396faca60b..f53e3f6b2ea91 100644
--- a/packages/SystemUI/ktfmt_includes.txt
+++ b/packages/SystemUI/ktfmt_includes.txt
@@ -485,7 +485,6 @@
-packages/SystemUI/src/com/android/systemui/statusbar/window/StatusBarWindowStateController.kt
-packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewInfo.kt
-packages/SystemUI/src/com/android/systemui/temporarydisplay/TemporaryViewDisplayController.kt
--packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
-packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarRootView.kt
-packages/SystemUI/src/com/android/systemui/toast/ToastDefaultAnimation.kt
-packages/SystemUI/src/com/android/systemui/toast/ToastLogger.kt
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 200c478a569a0..977adde635aa6 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -2362,6 +2362,8 @@
Playing on %1$s
Something went wrong. Try again.
+
+ Loading
Inactive, check app
diff --git a/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt b/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
index 52980c3c1f9bd..04b1a50169899 100644
--- a/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt
@@ -65,26 +65,27 @@ import javax.inject.Inject
* in the list of notifications until the user dismisses them.
*
* Only one chipbar may be shown at a time.
- * TODO(b/245610654): Should we just display whichever chipbar was most recently requested, or do we
- * need to maintain a priority ordering?
*/
@SysUISingleton
-open class ChipbarCoordinator @Inject constructor(
- context: Context,
- logger: ChipbarLogger,
- windowManager: WindowManager,
- @Main mainExecutor: DelayableExecutor,
- accessibilityManager: AccessibilityManager,
- configurationController: ConfigurationController,
- dumpManager: DumpManager,
- powerManager: PowerManager,
- private val falsingManager: FalsingManager,
- private val falsingCollector: FalsingCollector,
- private val viewUtil: ViewUtil,
- private val vibratorHelper: VibratorHelper,
- wakeLockBuilder: WakeLock.Builder,
- systemClock: SystemClock,
-) : TemporaryViewDisplayController(
+open class ChipbarCoordinator
+@Inject
+constructor(
+ context: Context,
+ logger: ChipbarLogger,
+ windowManager: WindowManager,
+ @Main mainExecutor: DelayableExecutor,
+ accessibilityManager: AccessibilityManager,
+ configurationController: ConfigurationController,
+ dumpManager: DumpManager,
+ powerManager: PowerManager,
+ private val falsingManager: FalsingManager,
+ private val falsingCollector: FalsingCollector,
+ private val viewUtil: ViewUtil,
+ private val vibratorHelper: VibratorHelper,
+ wakeLockBuilder: WakeLock.Builder,
+ systemClock: SystemClock,
+) :
+ TemporaryViewDisplayController(
context,
logger,
windowManager,
@@ -96,18 +97,14 @@ open class ChipbarCoordinator @Inject constructor(
R.layout.chipbar,
wakeLockBuilder,
systemClock,
-) {
+ ) {
private lateinit var parent: ChipbarRootView
- override val windowLayoutParams = commonWindowLayoutParams.apply {
- gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL)
- }
+ override val windowLayoutParams =
+ commonWindowLayoutParams.apply { gravity = Gravity.TOP.or(Gravity.CENTER_HORIZONTAL) }
- override fun updateView(
- newInfo: ChipbarInfo,
- currentView: ViewGroup
- ) {
+ override fun updateView(newInfo: ChipbarInfo, currentView: ViewGroup) {
logger.logViewUpdate(
newInfo.windowTitle,
newInfo.text.loadText(context),
@@ -123,12 +120,13 @@ open class ChipbarCoordinator @Inject constructor(
// Detect falsing touches on the chip.
parent = currentView.requireViewById(R.id.chipbar_root_view)
- parent.touchHandler = object : Gefingerpoken {
- override fun onTouchEvent(ev: MotionEvent?): Boolean {
- falsingCollector.onTouchEvent(ev)
- return false
+ parent.touchHandler =
+ object : Gefingerpoken {
+ override fun onTouchEvent(ev: MotionEvent?): Boolean {
+ falsingCollector.onTouchEvent(ev)
+ return false
+ }
}
- }
// ---- Start icon ----
val iconView = currentView.requireViewById(R.id.start_icon)
@@ -155,10 +153,12 @@ open class ChipbarCoordinator @Inject constructor(
if (newInfo.endItem is ChipbarEndItem.Button) {
TextViewBinder.bind(buttonView, newInfo.endItem.text)
- val onClickListener = View.OnClickListener { clickedView ->
- if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return@OnClickListener
- newInfo.endItem.onClickListener.onClick(clickedView)
- }
+ val onClickListener =
+ View.OnClickListener { clickedView ->
+ if (falsingManager.isFalseTap(FalsingManager.LOW_PENALTY))
+ return@OnClickListener
+ newInfo.endItem.onClickListener.onClick(clickedView)
+ }
buttonView.setOnClickListener(onClickListener)
buttonView.visibility = View.VISIBLE
@@ -168,21 +168,27 @@ open class ChipbarCoordinator @Inject constructor(
// ---- Overall accessibility ----
val iconDesc = newInfo.startIcon.icon.contentDescription
- val loadedIconDesc = if (iconDesc != null) {
- "${iconDesc.loadContentDescription(context)} "
- } else {
- ""
- }
+ val loadedIconDesc =
+ if (iconDesc != null) {
+ "${iconDesc.loadContentDescription(context)} "
+ } 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)
// ---- Haptics ----
- newInfo.vibrationEffect?.let {
- vibratorHelper.vibrate(it)
- }
+ newInfo.vibrationEffect?.let { vibratorHelper.vibrate(it) }
}
private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
index d3411c2b44169..90178c6a00966 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt
@@ -124,7 +124,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
)
)
- val contentDescView = getChipbarView().requireViewById(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(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(R.id.chipbar_inner)
+
private fun ViewGroup.getStartIconView() = this.requireViewById(R.id.start_icon)
private fun ViewGroup.getChipText(): String =