Loading packages/SystemUI/res/layout/media_ttt_chip.xml +11 −0 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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> packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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> Loading packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt +6 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) } Loading packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt +36 −9 Original line number Diff line number Diff line Loading @@ -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> = Loading @@ -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 { Loading Loading
packages/SystemUI/res/layout/media_ttt_chip.xml +11 −0 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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>
packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -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> Loading
packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt +6 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) } Loading
packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt +36 −9 Original line number Diff line number Diff line Loading @@ -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> = Loading @@ -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 { Loading