Loading packages/SystemUI/res/drawable/media_ttt_undo_background.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2021 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <solid android:color="?androidprv:attr/colorAccentPrimary" /> <corners android:radius="24dp" /> </shape> packages/SystemUI/res/layout/media_ttt_chip.xml +17 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,21 @@ style="?android:attr/progressBarStyleSmall" /> <TextView android:id="@+id/undo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/media_transfer_undo" android:textColor="?androidprv:attr/textColorOnAccent" android:layout_marginStart="12dp" android:textSize="@dimen/media_ttt_text_size" android:paddingStart="@dimen/media_ttt_chip_outer_padding" android:paddingEnd="@dimen/media_ttt_chip_outer_padding" android:paddingTop="@dimen/media_ttt_undo_button_vertical_padding" android:paddingBottom="@dimen/media_ttt_undo_button_vertical_padding" android:layout_marginTop="@dimen/media_ttt_undo_button_vertical_negative_margin" android:layout_marginBottom="@dimen/media_ttt_undo_button_vertical_negative_margin" android:background="@drawable/media_ttt_undo_background" /> </LinearLayout> packages/SystemUI/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -980,6 +980,8 @@ <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> <dimen name="media_ttt_undo_button_vertical_padding">8dp</dimen> <dimen name="media_ttt_undo_button_vertical_negative_margin">-8dp</dimen> <!-- Window magnification --> <dimen name="magnification_border_drag_size">35dp</dimen> Loading packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,11 @@ class MediaTttChipController @Inject constructor( currentChipView.requireViewById<View>(R.id.loading).visibility = if (showLoading) { View.VISIBLE } else { View.GONE } // Undo val showUndo = chipType == ChipType.TRANSFER_SUCCEEDED currentChipView.requireViewById<View>(R.id.undo).visibility = if (showUndo) { View.VISIBLE } else { View.GONE } if (oldChipView == null) { windowManager.addView(chipView, windowLayoutParams) } Loading packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt +25 −3 Original line number Diff line number Diff line Loading @@ -110,30 +110,33 @@ class MediaTttChipControllerTest : SysuiTestCase() { } @Test fun moveCloserToTransfer_chipTextContainsDeviceName_noLoadingIcon() { fun moveCloserToTransfer_chipTextContainsDeviceName_noLoadingIcon_noUndo() { commandRegistry.onShellCommand(pw, getMoveCloserToTransferCommand()) val chipView = getChipView() assertThat(chipView.getChipText()).contains(DEVICE_NAME) assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE) assertThat(chipView.getUndoButtonVisibility()).isEqualTo(View.GONE) } @Test fun transferInitiated_chipTextContainsDeviceName_loadingIcon() { fun transferInitiated_chipTextContainsDeviceName_loadingIcon_noUndo() { commandRegistry.onShellCommand(pw, getTransferInitiatedCommand()) val chipView = getChipView() assertThat(chipView.getChipText()).contains(DEVICE_NAME) assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE) assertThat(chipView.getUndoButtonVisibility()).isEqualTo(View.GONE) } @Test fun transferSucceeded_chipTextContainsDeviceName_noLoadingIcon() { fun transferSucceeded_chipTextContainsDeviceName_noLoadingIcon_undo() { commandRegistry.onShellCommand(pw, getTransferSucceededCommand()) val chipView = getChipView() assertThat(chipView.getChipText()).contains(DEVICE_NAME) assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE) assertThat(chipView.getUndoButtonVisibility()).isEqualTo(View.VISIBLE) } @Test Loading @@ -152,6 +155,22 @@ class MediaTttChipControllerTest : SysuiTestCase() { assertThat(getChipView().getLoadingIconVisibility()).isEqualTo(View.GONE) } @Test fun changeFromTransferInitiatedToTransferSucceeded_undoButtonAppears() { commandRegistry.onShellCommand(pw, getTransferInitiatedCommand()) commandRegistry.onShellCommand(pw, getTransferSucceededCommand()) assertThat(getChipView().getUndoButtonVisibility()).isEqualTo(View.VISIBLE) } @Test fun changeFromTransferSucceededToMoveCloser_undoButtonDisappears() { commandRegistry.onShellCommand(pw, getTransferSucceededCommand()) commandRegistry.onShellCommand(pw, getMoveCloserToTransferCommand()) assertThat(getChipView().getUndoButtonVisibility()).isEqualTo(View.GONE) } private fun getMoveCloserToTransferCommand(): Array<String> = arrayOf( MediaTttChipController.ADD_CHIP_COMMAND_TAG, Loading Loading @@ -179,6 +198,9 @@ class MediaTttChipControllerTest : SysuiTestCase() { private fun LinearLayout.getLoadingIconVisibility(): Int = this.requireViewById<View>(R.id.loading).visibility private fun LinearLayout.getUndoButtonVisibility(): Int = this.requireViewById<View>(R.id.undo).visibility private fun getChipView(): LinearLayout { val viewCaptor = ArgumentCaptor.forClass(View::class.java) verify(windowManager).addView(viewCaptor.capture(), any()) Loading Loading
packages/SystemUI/res/drawable/media_ttt_undo_background.xml 0 → 100644 +22 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright (C) 2021 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> <solid android:color="?androidprv:attr/colorAccentPrimary" /> <corners android:radius="24dp" /> </shape>
packages/SystemUI/res/layout/media_ttt_chip.xml +17 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,21 @@ style="?android:attr/progressBarStyleSmall" /> <TextView android:id="@+id/undo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/media_transfer_undo" android:textColor="?androidprv:attr/textColorOnAccent" android:layout_marginStart="12dp" android:textSize="@dimen/media_ttt_text_size" android:paddingStart="@dimen/media_ttt_chip_outer_padding" android:paddingEnd="@dimen/media_ttt_chip_outer_padding" android:paddingTop="@dimen/media_ttt_undo_button_vertical_padding" android:paddingBottom="@dimen/media_ttt_undo_button_vertical_padding" android:layout_marginTop="@dimen/media_ttt_undo_button_vertical_negative_margin" android:layout_marginBottom="@dimen/media_ttt_undo_button_vertical_negative_margin" android:background="@drawable/media_ttt_undo_background" /> </LinearLayout>
packages/SystemUI/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -980,6 +980,8 @@ <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> <dimen name="media_ttt_undo_button_vertical_padding">8dp</dimen> <dimen name="media_ttt_undo_button_vertical_negative_margin">-8dp</dimen> <!-- Window magnification --> <dimen name="magnification_border_drag_size">35dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttChipController.kt +5 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,11 @@ class MediaTttChipController @Inject constructor( currentChipView.requireViewById<View>(R.id.loading).visibility = if (showLoading) { View.VISIBLE } else { View.GONE } // Undo val showUndo = chipType == ChipType.TRANSFER_SUCCEEDED currentChipView.requireViewById<View>(R.id.undo).visibility = if (showUndo) { View.VISIBLE } else { View.GONE } if (oldChipView == null) { windowManager.addView(chipView, windowLayoutParams) } Loading
packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/MediaTttChipControllerTest.kt +25 −3 Original line number Diff line number Diff line Loading @@ -110,30 +110,33 @@ class MediaTttChipControllerTest : SysuiTestCase() { } @Test fun moveCloserToTransfer_chipTextContainsDeviceName_noLoadingIcon() { fun moveCloserToTransfer_chipTextContainsDeviceName_noLoadingIcon_noUndo() { commandRegistry.onShellCommand(pw, getMoveCloserToTransferCommand()) val chipView = getChipView() assertThat(chipView.getChipText()).contains(DEVICE_NAME) assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE) assertThat(chipView.getUndoButtonVisibility()).isEqualTo(View.GONE) } @Test fun transferInitiated_chipTextContainsDeviceName_loadingIcon() { fun transferInitiated_chipTextContainsDeviceName_loadingIcon_noUndo() { commandRegistry.onShellCommand(pw, getTransferInitiatedCommand()) val chipView = getChipView() assertThat(chipView.getChipText()).contains(DEVICE_NAME) assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.VISIBLE) assertThat(chipView.getUndoButtonVisibility()).isEqualTo(View.GONE) } @Test fun transferSucceeded_chipTextContainsDeviceName_noLoadingIcon() { fun transferSucceeded_chipTextContainsDeviceName_noLoadingIcon_undo() { commandRegistry.onShellCommand(pw, getTransferSucceededCommand()) val chipView = getChipView() assertThat(chipView.getChipText()).contains(DEVICE_NAME) assertThat(chipView.getLoadingIconVisibility()).isEqualTo(View.GONE) assertThat(chipView.getUndoButtonVisibility()).isEqualTo(View.VISIBLE) } @Test Loading @@ -152,6 +155,22 @@ class MediaTttChipControllerTest : SysuiTestCase() { assertThat(getChipView().getLoadingIconVisibility()).isEqualTo(View.GONE) } @Test fun changeFromTransferInitiatedToTransferSucceeded_undoButtonAppears() { commandRegistry.onShellCommand(pw, getTransferInitiatedCommand()) commandRegistry.onShellCommand(pw, getTransferSucceededCommand()) assertThat(getChipView().getUndoButtonVisibility()).isEqualTo(View.VISIBLE) } @Test fun changeFromTransferSucceededToMoveCloser_undoButtonDisappears() { commandRegistry.onShellCommand(pw, getTransferSucceededCommand()) commandRegistry.onShellCommand(pw, getMoveCloserToTransferCommand()) assertThat(getChipView().getUndoButtonVisibility()).isEqualTo(View.GONE) } private fun getMoveCloserToTransferCommand(): Array<String> = arrayOf( MediaTttChipController.ADD_CHIP_COMMAND_TAG, Loading Loading @@ -179,6 +198,9 @@ class MediaTttChipControllerTest : SysuiTestCase() { private fun LinearLayout.getLoadingIconVisibility(): Int = this.requireViewById<View>(R.id.loading).visibility private fun LinearLayout.getUndoButtonVisibility(): Int = this.requireViewById<View>(R.id.undo).visibility private fun getChipView(): LinearLayout { val viewCaptor = ArgumentCaptor.forClass(View::class.java) verify(windowManager).addView(viewCaptor.capture(), any()) Loading