[Media TTT] Show a loading icon when a media transfer is in
progress. Bug: 203800327 Fixes: 203800721 Test: `adb shell cmd statusbar media-ttt-chip-add Tablet TRANSFER_INITIATED` shows text AND loading icon. No other chip states show loading icon. Test: atest MediaTttChipControllerTest Change-Id: I31740695f41627814d0d72094c7f9c927bffa9d3
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -33,4 +34,14 @@
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:indeterminate="true"
|
||||
android:layout_width="@dimen/media_ttt_icon_size"
|
||||
android:layout_height="@dimen/media_ttt_icon_size"
|
||||
android:layout_marginStart="12dp"
|
||||
android:indeterminateTint="?androidprv:attr/colorAccentPrimaryVariant"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -979,6 +979,7 @@
|
||||
<!-- Media tap-to-transfer chip -->
|
||||
<dimen name="media_ttt_chip_outer_padding">16dp</dimen>
|
||||
<dimen name="media_ttt_text_size">16sp</dimen>
|
||||
<dimen name="media_ttt_icon_size">16dp</dimen>
|
||||
|
||||
<!-- Window magnification -->
|
||||
<dimen name="magnification_border_drag_size">35dp</dimen>
|
||||
|
||||
@@ -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<View>(R.id.loading).visibility =
|
||||
if (showLoading) { View.VISIBLE } else { View.GONE }
|
||||
|
||||
if (oldChipView == null) {
|
||||
windowManager.addView(chipView, windowLayoutParams)
|
||||
}
|
||||
|
||||
@@ -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<String> =
|
||||
@@ -151,11 +173,16 @@ class MediaTttChipControllerTest : SysuiTestCase() {
|
||||
MediaTttChipController.ChipType.TRANSFER_SUCCEEDED.name
|
||||
)
|
||||
|
||||
private fun getChipText(): String {
|
||||
private fun LinearLayout.getChipText(): String =
|
||||
(this.requireViewById<TextView>(R.id.text)).text as String
|
||||
|
||||
private fun LinearLayout.getLoadingIconVisibility(): Int =
|
||||
this.requireViewById<View>(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 {
|
||||
|
||||
Reference in New Issue
Block a user