1 package com.android.systemui.statusbar.notification 2 3 import android.util.MathUtils 4 import com.android.internal.annotations.VisibleForTesting 5 import com.android.systemui.animation.ActivityLaunchAnimator 6 import com.android.systemui.animation.Interpolators 7 import kotlin.math.min 8 9 /** Parameters for the notifications expand animations. */ 10 class ExpandAnimationParameters( 11 top: Int, 12 bottom: Int, 13 left: Int, 14 right: Int, 15 16 topCornerRadius: Float = 0f, 17 bottomCornerRadius: Float = 0f 18 ) : ActivityLaunchAnimator.State(top, bottom, left, right, topCornerRadius, bottomCornerRadius) { 19 @VisibleForTesting 20 constructor() : this( 21 top = 0, bottom = 0, left = 0, right = 0, topCornerRadius = 0f, bottomCornerRadius = 0f 22 ) 23 24 var startTranslationZ = 0f 25 26 /** 27 * The top position of the notification at the start of the animation. This is needed in order 28 * to keep the notification at its place when launching a notification that is clipped rounded. 29 */ 30 var startNotificationTop = 0f 31 var startClipTopAmount = 0 32 var parentStartClipTopAmount = 0 33 var progress = 0f 34 var linearProgress = 0f 35 36 /** 37 * The rounded top clipping at the beginning. 38 */ 39 var startRoundedTopClipping = 0 40 41 /** 42 * The rounded top clipping of the parent notification at the start. 43 */ 44 var parentStartRoundedTopClipping = 0 45 46 override val topChange: Int 47 get() { 48 // We need this compensation to ensure that the QS moves in sync. 49 var clipTopAmountCompensation = 0 50 if (startClipTopAmount.toFloat() != 0.0f) { 51 clipTopAmountCompensation = MathUtils.lerp(0f, startClipTopAmount.toFloat(), 52 Interpolators.FAST_OUT_SLOW_IN.getInterpolation(linearProgress)).toInt() 53 } 54 return min(super.topChange - clipTopAmountCompensation, 0) 55 } 56 getProgressnull57 fun getProgress(delay: Long, duration: Long): Float { 58 return ActivityLaunchAnimator.getProgress(linearProgress, delay, duration) 59 } 60 }