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

Commit fdd6b883 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "Removing the padding for launch animation for dialog transitions." into main

parents b7db0cc8 3e6d5c2f
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -93,6 +93,7 @@ constructor(
        @VisibleForTesting internal const val TILE_STATE_RES_PREFIX = "tile_states_"
        @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_WIDTH_SCALE = 1.1f
        @VisibleForTesting internal const val LONG_PRESS_EFFECT_HEIGHT_SCALE = 1.2f
        @VisibleForTesting internal const val LONG_PRESS_EFFECT_HEIGHT_SCALE = 1.2f
        internal val EMPTY_RECT = Rect()
    }
    }


    private val icon: QSIconViewImpl = QSIconViewImpl(context)
    private val icon: QSIconViewImpl = QSIconViewImpl(context)
@@ -916,7 +917,7 @@ constructor(
        }
        }
    }
    }


    fun prepareForLaunch() {
    private fun prepareForLaunch() {
        val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0
        val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0
        val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0
        val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0
        val deltaH = finalLongPressProperties?.height?.minus(startingHeight)?.toInt() ?: 0
        val deltaH = finalLongPressProperties?.height?.minus(startingHeight)?.toInt() ?: 0
@@ -927,7 +928,12 @@ constructor(
        paddingForLaunch.bottom = deltaH / 2
        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) {
    fun updateLongPressEffectProperties(effectProgress: Float) {
        if (!isLongClickable || longPressEffect == null) return
        if (!isLongClickable || longPressEffect == null) return
+19 −3
Original line number Original line Diff line number Diff line
@@ -471,7 +471,7 @@ class QSTileViewImplTest : SysuiTestCase() {
    }
    }


    @Test
    @Test
    fun onPrepareForLaunch_paddingForLaunchAnimationIsConfigured() {
    fun getPaddingForLaunchAnimation_onLongClickedState_paddingForLaunchAnimationIsConfigured() {
        val startingWidth = 100
        val startingWidth = 100
        val startingHeight = 50
        val startingHeight = 50
        val deltaWidth = (QSTileViewImpl.LONG_PRESS_EFFECT_WIDTH_SCALE - 1f) * startingWidth
        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
        // GIVEN that long-press effect properties are initialized
        tileView.initializeLongPressProperties(startingHeight, startingWidth)
        tileView.initializeLongPressProperties(startingHeight, startingWidth)


        // WHEN the tile is preparing for the launch animation
        // WHEN the long-press effect has ended in the long-click state
        tileView.prepareForLaunch()
        kosmos.qsLongPressEffect.setState(QSLongPressEffect.State.LONG_CLICKED)


        // THE animation padding corresponds to the tile's growth due to the effect
        // THE animation padding corresponds to the tile's growth due to the effect
        val padding = tileView.getPaddingForLaunchAnimation()
        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
    @Test
    fun onActivityLaunchAnimationEnd_onFreshTile_longPressPropertiesAreReset() {
    fun onActivityLaunchAnimationEnd_onFreshTile_longPressPropertiesAreReset() {
        // WHEN an activity launch animation ends on a fresh tile
        // WHEN an activity launch animation ends on a fresh tile