[Media TTT] Show an undo button when a transfer has succeeded.
Screenshot of chip in light and dark mode in all states are linked in the bug. Bug: 203800327 Bug: 203800665 Test: `adb shell cmd statusbar media-ttt-chip-add Tablet TRANSFER_SUCCEEDED` shows an undo button and no other commands show an undo button. Test: atest MediaTttControllerTest Change-Id: I6f4343126688801f9866deed71271d55bd6bdbda
This commit is contained in:
22
packages/SystemUI/res/drawable/media_ttt_undo_background.xml
Normal file
22
packages/SystemUI/res/drawable/media_ttt_undo_background.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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,
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user