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