diff options
| author | 2024-07-12 17:12:53 +0000 | |
|---|---|---|
| committer | 2024-07-12 17:12:53 +0000 | |
| commit | fdd6b883d3520e8f61f32e29be7b7425dba877e1 (patch) | |
| tree | 529af1b083d893dfe8e2ddd4ec4843019af6ddce | |
| parent | b7db0cc8d44d6cf2ef3a840c13eccb2c8e25e0d2 (diff) | |
| parent | 3e6d5c2f9cad47ce64bf19aacfe8dd3b7aad2347 (diff) | |
Merge "Removing the padding for launch animation for dialog transitions." into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt | 10 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt | 22 |
2 files changed, 27 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt index 787fd1ab7170..6b3dfe1b90ad 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt @@ -93,6 +93,7 @@ constructor( @VisibleForTesting internal const val TILE_STATE_RES_PREFIX = "tile_states_" @VisibleForTesting internal const val LONG_PRESS_EFFECT_WIDTH_SCALE = 1.1f @VisibleForTesting internal const val LONG_PRESS_EFFECT_HEIGHT_SCALE = 1.2f + internal val EMPTY_RECT = Rect() } private val icon: QSIconViewImpl = QSIconViewImpl(context) @@ -916,7 +917,7 @@ constructor( } } - fun prepareForLaunch() { + private fun prepareForLaunch() { val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0 val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0 val deltaH = finalLongPressProperties?.height?.minus(startingHeight)?.toInt() ?: 0 @@ -927,7 +928,12 @@ constructor( paddingForLaunch.bottom = deltaH / 2 } - override fun getPaddingForLaunchAnimation(): Rect = paddingForLaunch + override fun getPaddingForLaunchAnimation(): Rect = + if (longPressEffect?.state == QSLongPressEffect.State.LONG_CLICKED) { + paddingForLaunch + } else { + EMPTY_RECT + } fun updateLongPressEffectProperties(effectProgress: Float) { if (!isLongClickable || longPressEffect == null) return diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt index 415cc7c99b2c..988769fe6660 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt @@ -471,7 +471,7 @@ class QSTileViewImplTest : SysuiTestCase() { } @Test - fun onPrepareForLaunch_paddingForLaunchAnimationIsConfigured() { + fun getPaddingForLaunchAnimation_onLongClickedState_paddingForLaunchAnimationIsConfigured() { val startingWidth = 100 val startingHeight = 50 val deltaWidth = (QSTileViewImpl.LONG_PRESS_EFFECT_WIDTH_SCALE - 1f) * startingWidth @@ -480,8 +480,8 @@ class QSTileViewImplTest : SysuiTestCase() { // GIVEN that long-press effect properties are initialized tileView.initializeLongPressProperties(startingHeight, startingWidth) - // WHEN the tile is preparing for the launch animation - tileView.prepareForLaunch() + // WHEN the long-press effect has ended in the long-click state + kosmos.qsLongPressEffect.setState(QSLongPressEffect.State.LONG_CLICKED) // THE animation padding corresponds to the tile's growth due to the effect val padding = tileView.getPaddingForLaunchAnimation() @@ -497,6 +497,22 @@ class QSTileViewImplTest : SysuiTestCase() { } @Test + fun getPaddingForLaunchAnimation_notInLongClickState_paddingForLaunchAnimationIsEmpty() { + val startingWidth = 100 + val startingHeight = 50 + + // GIVEN that long-press effect properties are initialized + tileView.initializeLongPressProperties(startingHeight, startingWidth) + + // WHEN the long-press effect has ended in the click state + kosmos.qsLongPressEffect.setState(QSLongPressEffect.State.CLICKED) + + // THE animation padding is empty + val padding = tileView.getPaddingForLaunchAnimation() + assertThat(padding.isEmpty).isTrue() + } + + @Test fun onActivityLaunchAnimationEnd_onFreshTile_longPressPropertiesAreReset() { // WHEN an activity launch animation ends on a fresh tile tileView.onActivityLaunchAnimationEnd() |