Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e6d5c2f authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Removing the padding for launch animation for dialog transitions.

The padding for launch animation only applies if the animation is an
activity launch animation due to a long-press. The extra padding was
also being applied to dialog launchs after clicks, making the tile
containers "jump" or flicker as the transition started and ended. This
is now avoided by only providing padding when the long-press effect ends
with a long-click state.

Test: atest SystemUITests:QSTileViewImplTest
Flag: com.android.systemui.quick_settings_visual_haptics_longpress
Bug: 350028416
Change-Id: If7cd76165b4b2eb4fdd0880b45b7ce299a7cc8ff
parent 1209d966
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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
+19 −3
Original line number Diff line number Diff line
@@ -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()
@@ -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