Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading @@ -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 Loading packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +19 −3 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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() Loading @@ -496,6 +496,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 Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +8 −2 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading @@ -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 Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt +19 −3 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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() Loading @@ -496,6 +496,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 Loading