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

Commit 3dd7c951 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Support Views that are scaled in GhostedViewLaunchAnimatorController

This CL ensures that we take the current scale of a View when computing
the start position of a launch animated View.

Bug: 265280100
Test: Launch an activity from a keyguard shortcut
Change-Id: I1f733283098af119fd403f106c15d39b4950fc88
parent 3d5c9f00
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.widget.FrameLayout
import com.android.internal.jank.InteractionJankMonitor
import java.util.LinkedList
import kotlin.math.min
import kotlin.math.roundToInt

private const val TAG = "GhostedViewLaunchAnimatorController"

@@ -50,7 +51,9 @@ private const val TAG = "GhostedViewLaunchAnimatorController"
 * Note: Avoid instantiating this directly and call [ActivityLaunchAnimator.Controller.fromView]
 * whenever possible instead.
 */
open class GhostedViewLaunchAnimatorController @JvmOverloads constructor(
open class GhostedViewLaunchAnimatorController
@JvmOverloads
constructor(
    /** The view that will be ghosted and from which the background will be extracted. */
    private val ghostedView: View,

@@ -146,7 +149,8 @@ open class GhostedViewLaunchAnimatorController @JvmOverloads constructor(
        val gradient = findGradientDrawable(drawable) ?: return 0f

        // TODO(b/184121838): Support more than symmetric top & bottom radius.
        return gradient.cornerRadii?.get(CORNER_RADIUS_TOP_INDEX) ?: gradient.cornerRadius
        val radius = gradient.cornerRadii?.get(CORNER_RADIUS_TOP_INDEX) ?: gradient.cornerRadius
        return radius * ghostedView.scaleX
    }

    /** Return the current bottom corner radius of the background. */
@@ -155,7 +159,8 @@ open class GhostedViewLaunchAnimatorController @JvmOverloads constructor(
        val gradient = findGradientDrawable(drawable) ?: return 0f

        // TODO(b/184121838): Support more than symmetric top & bottom radius.
        return gradient.cornerRadii?.get(CORNER_RADIUS_BOTTOM_INDEX) ?: gradient.cornerRadius
        val radius = gradient.cornerRadii?.get(CORNER_RADIUS_BOTTOM_INDEX) ?: gradient.cornerRadius
        return radius * ghostedView.scaleX
    }

    override fun createAnimatorState(): LaunchAnimator.State {
@@ -174,9 +179,13 @@ open class GhostedViewLaunchAnimatorController @JvmOverloads constructor(
        ghostedView.getLocationOnScreen(ghostedViewLocation)
        val insets = backgroundInsets
        state.top = ghostedViewLocation[1] + insets.top
        state.bottom = ghostedViewLocation[1] + ghostedView.height - insets.bottom
        state.bottom =
            ghostedViewLocation[1] + (ghostedView.height * ghostedView.scaleY).roundToInt() -
                insets.bottom
        state.left = ghostedViewLocation[0] + insets.left
        state.right = ghostedViewLocation[0] + ghostedView.width - insets.right
        state.right =
            ghostedViewLocation[0] + (ghostedView.width * ghostedView.scaleX).roundToInt() -
                insets.right
    }

    override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) {
+0 −1
Original line number Diff line number Diff line
+packages/SystemUI
-packages/SystemUI/animation/src/com/android/systemui/animation/FontInterpolator.kt
-packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewLaunchAnimatorController.kt
-packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt
-packages/SystemUI/animation/src/com/android/systemui/animation/TextInterpolator.kt
-packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt