Scale the expanding view content towards the center.
This CL scales the content of the view that is expanding during an animated activity launch. The content also now moves towards the center of the final window position. Bug: 184726377 Test: Manual Change-Id: Ibca1c4f5f56d99878d6c79dab033a2e7d7a4928b
This commit is contained in:
@@ -223,8 +223,13 @@ class ActivityLaunchAnimator(context: Context) {
|
||||
var backgroundAlpha: Float = 1f
|
||||
) {
|
||||
private val startTop = top
|
||||
private val startBottom = bottom
|
||||
private val startLeft = left
|
||||
private val startRight = right
|
||||
private val startWidth = width
|
||||
private val startHeight = height
|
||||
val startCenterX = centerX
|
||||
val startCenterY = centerY
|
||||
|
||||
val width: Int
|
||||
get() = right - left
|
||||
@@ -235,11 +240,26 @@ class ActivityLaunchAnimator(context: Context) {
|
||||
open val topChange: Int
|
||||
get() = top - startTop
|
||||
|
||||
open val bottomChange: Int
|
||||
get() = bottom - startBottom
|
||||
|
||||
val leftChange: Int
|
||||
get() = left - startLeft
|
||||
|
||||
val rightChange: Int
|
||||
get() = right - startRight
|
||||
|
||||
val widthRatio: Float
|
||||
get() = width.toFloat() / startWidth
|
||||
|
||||
val heightRatio: Float
|
||||
get() = height.toFloat() / startHeight
|
||||
|
||||
val centerX: Float
|
||||
get() = left + width / 2f
|
||||
|
||||
val centerY: Float
|
||||
get() = top + height / 2f
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.android.systemui.animation
|
||||
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.ColorFilter
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.PixelFormat
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffXfermode
|
||||
@@ -13,6 +14,7 @@ import android.view.GhostView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* A base implementation of [ActivityLaunchAnimator.Controller] which creates a [ghost][GhostView]
|
||||
@@ -34,7 +36,9 @@ open class GhostedViewLaunchAnimatorController(
|
||||
private val rootViewOverlay = rootView.overlay
|
||||
|
||||
/** The ghost view that is drawn and animated instead of the ghosted view. */
|
||||
private var ghostView: View? = null
|
||||
private var ghostView: GhostView? = null
|
||||
private val initialGhostViewMatrixValues = FloatArray(9) { 0f }
|
||||
private val ghostViewMatrix = Matrix()
|
||||
|
||||
/**
|
||||
* The expanding background view that will be added to [rootView] (below [ghostView]) and
|
||||
@@ -125,6 +129,9 @@ open class GhostedViewLaunchAnimatorController(
|
||||
ghostView = GhostView.addGhost(ghostedView, rootView).apply {
|
||||
setLayerType(View.LAYER_TYPE_HARDWARE, null)
|
||||
}
|
||||
|
||||
val matrix = ghostView?.animationMatrix ?: Matrix.IDENTITY_MATRIX
|
||||
matrix.getValues(initialGhostViewMatrixValues)
|
||||
}
|
||||
|
||||
override fun onLaunchAnimationProgress(
|
||||
@@ -133,10 +140,17 @@ open class GhostedViewLaunchAnimatorController(
|
||||
linearProgress: Float
|
||||
) {
|
||||
val ghostView = this.ghostView!!
|
||||
ghostView.translationX = (state.leftChange + state.rightChange) / 2.toFloat()
|
||||
ghostView.translationY = state.topChange.toFloat()
|
||||
ghostView.alpha = state.contentAlpha
|
||||
|
||||
val scale = min(state.widthRatio, state.heightRatio)
|
||||
ghostViewMatrix.setValues(initialGhostViewMatrixValues)
|
||||
ghostViewMatrix.postScale(scale, scale, state.startCenterX, state.startCenterY)
|
||||
ghostViewMatrix.postTranslate(
|
||||
(state.leftChange + state.rightChange) / 2f,
|
||||
(state.topChange + state.bottomChange) / 2f
|
||||
)
|
||||
ghostView.animationMatrix = ghostViewMatrix
|
||||
|
||||
val backgroundView = this.backgroundView!!
|
||||
backgroundView.top = state.top
|
||||
backgroundView.bottom = state.bottom
|
||||
|
||||
Reference in New Issue
Block a user