diff --git a/packages/SystemUI/res/layout/media_ttt_chip.xml b/packages/SystemUI/res/layout/media_ttt_chip.xml
index 5b3590bfb0a79..2fe55477af967 100644
--- a/packages/SystemUI/res/layout/media_ttt_chip.xml
+++ b/packages/SystemUI/res/layout/media_ttt_chip.xml
@@ -15,6 +15,7 @@
-->
+
+
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 89c9a359af439..a09f94d872acc 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -979,6 +979,7 @@
16dp
16sp
+ 16dp
35dp
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt
index 9964d881ff925..e733ff1c88004 100644
--- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt
@@ -20,6 +20,7 @@ import android.content.Context
import android.graphics.PixelFormat
import android.view.Gravity
import android.view.LayoutInflater
+import android.view.View
import android.view.WindowManager
import android.widget.LinearLayout
import android.widget.TextView
@@ -78,6 +79,11 @@ class MediaTttChipController @Inject constructor(
text = context.getString(chipType.chipText, otherDeviceName)
}
+ // Loading
+ val showLoading = chipType == ChipType.TRANSFER_INITIATED
+ currentChipView.requireViewById(R.id.loading).visibility =
+ if (showLoading) { View.VISIBLE } else { View.GONE }
+
if (oldChipView == null) {
windowManager.addView(chipView, windowLayoutParams)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt
index 9438ee3dace2b..f5a4649d30744 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt
@@ -110,24 +110,46 @@ class MediaTttChipControllerTest : SysuiTestCase() {
}
@Test
- fun moveCloserToTransfer_chipTextContainsDeviceName() {
+ fun moveCloserToTransfer_chipTextContainsDeviceName_noLoadingIcon() {
commandRegistry.onShellCommand(pw, getMoveCloserToTransferCommand())
- assertThat(getChipText()).contains(DEVICE_NAME)
+ val chipView = getChipView()
+ assertThat(chipView.getChipText()).contains(DEVICE_NAME)
+ assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
}
@Test
- fun transferInitiated_chipTextContainsDeviceName() {
+ fun transferInitiated_chipTextContainsDeviceName_loadingIcon() {
commandRegistry.onShellCommand(pw, getTransferInitiatedCommand())
- assertThat(getChipText()).contains(DEVICE_NAME)
+ val chipView = getChipView()
+ assertThat(chipView.getChipText()).contains(DEVICE_NAME)
+ assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE)
}
@Test
- fun transferSucceeded_chipTextContainsDeviceName() {
+ fun transferSucceeded_chipTextContainsDeviceName_noLoadingIcon() {
commandRegistry.onShellCommand(pw, getTransferSucceededCommand())
- assertThat(getChipText()).contains(DEVICE_NAME)
+ val chipView = getChipView()
+ assertThat(chipView.getChipText()).contains(DEVICE_NAME)
+ assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE)
+ }
+
+ @Test
+ fun changeFromCloserToTransferToTransferInitiated_loadingIconAppears() {
+ commandRegistry.onShellCommand(pw, getMoveCloserToTransferCommand())
+ commandRegistry.onShellCommand(pw, getTransferInitiatedCommand())
+
+ assertThat(getChipView().getLoadingIconVisibility()).isEqualTo(View.VISIBLE)
+ }
+
+ @Test
+ fun changeFromTransferInitiatedToTransferSucceeded_loadingIconDisappears() {
+ commandRegistry.onShellCommand(pw, getTransferInitiatedCommand())
+ commandRegistry.onShellCommand(pw, getTransferSucceededCommand())
+
+ assertThat(getChipView().getLoadingIconVisibility()).isEqualTo(View.GONE)
}
private fun getMoveCloserToTransferCommand(): Array =
@@ -151,11 +173,16 @@ class MediaTttChipControllerTest : SysuiTestCase() {
MediaTttChipController.ChipType.TRANSFER_SUCCEEDED.name
)
- private fun getChipText(): String {
+ private fun LinearLayout.getChipText(): String =
+ (this.requireViewById(R.id.text)).text as String
+
+ private fun LinearLayout.getLoadingIconVisibility(): Int =
+ this.requireViewById(R.id.loading).visibility
+
+ private fun getChipView(): LinearLayout {
val viewCaptor = ArgumentCaptor.forClass(View::class.java)
verify(windowManager).addView(viewCaptor.capture(), any())
- val chipView = viewCaptor.value as LinearLayout
- return (chipView.requireViewById(R.id.text) as TextView).text as String
+ return viewCaptor.value as LinearLayout
}
class EmptyCommand : Command {