Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt +36 −22 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.google.android.material.math.MathUtils import kotlin.math.abs internal fun View.setRect(rect: Rect) = Loading @@ -59,15 +60,6 @@ class ClockSizeTransition( override fun captureEndValues(transition: TransitionValues) = captureValues(transition) override fun captureStartValues(transition: TransitionValues) = captureValues(transition) override fun getTransitionProperties(): Array<String> = TRANSITION_PROPERTIES open fun mutateBounds( view: View, fromVis: Int, toVis: Int, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) {} private fun captureValues(transition: TransitionValues) { val view = transition.view Loading @@ -81,6 +73,16 @@ class ClockSizeTransition( transition.values[SMARTSPACE_BOUNDS] = Rect(ss.left, ss.top, ss.right, ss.bottom) } open fun mutateBounds( view: View, fromIsVis: Boolean, toIsVis: Boolean, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) {} override fun createAnimator( sceenRoot: ViewGroup, startValues: TransitionValues?, Loading @@ -88,7 +90,6 @@ class ClockSizeTransition( ): Animator? { if (startValues == null || endValues == null) return null val fromView = startValues.view var fromVis = startValues.values[PROP_VISIBILITY] as Int var fromIsVis = fromVis == View.VISIBLE var fromAlpha = startValues.values[PROP_ALPHA] as Float Loading @@ -111,7 +112,7 @@ class ClockSizeTransition( fromVis = View.INVISIBLE } mutateBounds(toView, fromVis, toVis, fromBounds, toBounds, fromSSBounds, toSSBounds) mutateBounds(toView, fromIsVis, toIsVis, fromBounds, toBounds, fromSSBounds, toSSBounds) if (fromIsVis == toIsVis && fromBounds.equals(toBounds)) { if (DEBUG) { Log.w( Loading @@ -127,7 +128,7 @@ class ClockSizeTransition( val sendToBack = fromIsVis && !toIsVis fun lerp(start: Int, end: Int, fract: Float): Int = (start * (1f - fract) + end * fract).toInt() MathUtils.lerp(start.toFloat(), end.toFloat(), fract).toInt() fun computeBounds(fract: Float): Rect = Rect( lerp(fromBounds.left, toBounds.left, fract), Loading @@ -136,9 +137,14 @@ class ClockSizeTransition( lerp(fromBounds.bottom, toBounds.bottom, fract) ) fun assignAnimValues(src: String, alpha: Float, fract: Float, vis: Int? = null) { fun assignAnimValues(src: String, fract: Float, vis: Int? = null) { val bounds = computeBounds(fract) if (DEBUG) Log.i(TAG, "$src: $toView; alpha=$alpha; vis=$vis; bounds=$bounds;") val alpha = MathUtils.lerp(fromAlpha, toAlpha, fract) if (DEBUG) Log.i( TAG, "$src: $toView; fract=$fract; alpha=$alpha; vis=$vis; bounds=$bounds;" ) toView.setVisibility(vis ?: View.VISIBLE) toView.setAlpha(alpha) toView.setRect(bounds) Loading @@ -154,12 +160,12 @@ class ClockSizeTransition( ) } return ValueAnimator.ofFloat(fromAlpha, toAlpha).also { anim -> return ValueAnimator.ofFloat(0f, 1f).also { anim -> // We enforce the animation parameters on the target view every frame using a // predraw listener. This is suboptimal but prevents issues with layout passes // overwriting the animation for individual frames. val predrawCallback = OnPreDrawListener { assignAnimValues("predraw", anim.animatedValue as Float, anim.animatedFraction) assignAnimValues("predraw", anim.animatedFraction) return@OnPreDrawListener true } Loading @@ -169,16 +175,18 @@ class ClockSizeTransition( anim.addListener( object : AnimatorListenerAdapter() { override fun onAnimationStart(anim: Animator) { assignAnimValues("start", fromAlpha, 0f) assignAnimValues("start", 0f, fromVis) } override fun onAnimationEnd(anim: Animator) { assignAnimValues("end", toAlpha, 1f, toVis) assignAnimValues("end", 1f, toVis) if (sendToBack) toView.translationZ = 0f toView.viewTreeObserver.removeOnPreDrawListener(predrawCallback) } } ) assignAnimValues("init", 0f, fromVis) toView.viewTreeObserver.addOnPreDrawListener(predrawCallback) } } Loading Loading @@ -216,13 +224,16 @@ class ClockSizeTransition( override fun mutateBounds( view: View, fromVis: Int, toVis: Int, fromIsVis: Boolean, toIsVis: Boolean, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) { // Move normally if clock is not changing visibility if (fromIsVis == toIsVis) return fromBounds.left = toBounds.left fromBounds.right = toBounds.right if (viewModel.useLargeClock) { Loading Loading @@ -271,13 +282,16 @@ class ClockSizeTransition( override fun mutateBounds( view: View, fromVis: Int, toVis: Int, fromIsVis: Boolean, toIsVis: Boolean, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) { // Move normally if clock is not changing visibility if (fromIsVis == toIsVis) return toBounds.left = fromBounds.left toBounds.right = fromBounds.right if (!viewModel.useLargeClock) { Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt +2 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,8 @@ class DefaultClockSteppingTransition( } companion object { private const val PROP_BOUNDS_LEFT = "splitShadeTransitionAdapter:boundsLeft" private const val PROP_X_IN_WINDOW = "splitShadeTransitionAdapter:xInWindow" private const val PROP_BOUNDS_LEFT = "DefaultClockSteppingTransition:boundsLeft" private const val PROP_X_IN_WINDOW = "DefaultClockSteppingTransition:xInWindow" private val TRANSITION_PROPERTIES = arrayOf(PROP_BOUNDS_LEFT, PROP_X_IN_WINDOW) private const val KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION_MS = 1000L } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/ClockSizeTransition.kt +36 −22 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import com.google.android.material.math.MathUtils import kotlin.math.abs internal fun View.setRect(rect: Rect) = Loading @@ -59,15 +60,6 @@ class ClockSizeTransition( override fun captureEndValues(transition: TransitionValues) = captureValues(transition) override fun captureStartValues(transition: TransitionValues) = captureValues(transition) override fun getTransitionProperties(): Array<String> = TRANSITION_PROPERTIES open fun mutateBounds( view: View, fromVis: Int, toVis: Int, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) {} private fun captureValues(transition: TransitionValues) { val view = transition.view Loading @@ -81,6 +73,16 @@ class ClockSizeTransition( transition.values[SMARTSPACE_BOUNDS] = Rect(ss.left, ss.top, ss.right, ss.bottom) } open fun mutateBounds( view: View, fromIsVis: Boolean, toIsVis: Boolean, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) {} override fun createAnimator( sceenRoot: ViewGroup, startValues: TransitionValues?, Loading @@ -88,7 +90,6 @@ class ClockSizeTransition( ): Animator? { if (startValues == null || endValues == null) return null val fromView = startValues.view var fromVis = startValues.values[PROP_VISIBILITY] as Int var fromIsVis = fromVis == View.VISIBLE var fromAlpha = startValues.values[PROP_ALPHA] as Float Loading @@ -111,7 +112,7 @@ class ClockSizeTransition( fromVis = View.INVISIBLE } mutateBounds(toView, fromVis, toVis, fromBounds, toBounds, fromSSBounds, toSSBounds) mutateBounds(toView, fromIsVis, toIsVis, fromBounds, toBounds, fromSSBounds, toSSBounds) if (fromIsVis == toIsVis && fromBounds.equals(toBounds)) { if (DEBUG) { Log.w( Loading @@ -127,7 +128,7 @@ class ClockSizeTransition( val sendToBack = fromIsVis && !toIsVis fun lerp(start: Int, end: Int, fract: Float): Int = (start * (1f - fract) + end * fract).toInt() MathUtils.lerp(start.toFloat(), end.toFloat(), fract).toInt() fun computeBounds(fract: Float): Rect = Rect( lerp(fromBounds.left, toBounds.left, fract), Loading @@ -136,9 +137,14 @@ class ClockSizeTransition( lerp(fromBounds.bottom, toBounds.bottom, fract) ) fun assignAnimValues(src: String, alpha: Float, fract: Float, vis: Int? = null) { fun assignAnimValues(src: String, fract: Float, vis: Int? = null) { val bounds = computeBounds(fract) if (DEBUG) Log.i(TAG, "$src: $toView; alpha=$alpha; vis=$vis; bounds=$bounds;") val alpha = MathUtils.lerp(fromAlpha, toAlpha, fract) if (DEBUG) Log.i( TAG, "$src: $toView; fract=$fract; alpha=$alpha; vis=$vis; bounds=$bounds;" ) toView.setVisibility(vis ?: View.VISIBLE) toView.setAlpha(alpha) toView.setRect(bounds) Loading @@ -154,12 +160,12 @@ class ClockSizeTransition( ) } return ValueAnimator.ofFloat(fromAlpha, toAlpha).also { anim -> return ValueAnimator.ofFloat(0f, 1f).also { anim -> // We enforce the animation parameters on the target view every frame using a // predraw listener. This is suboptimal but prevents issues with layout passes // overwriting the animation for individual frames. val predrawCallback = OnPreDrawListener { assignAnimValues("predraw", anim.animatedValue as Float, anim.animatedFraction) assignAnimValues("predraw", anim.animatedFraction) return@OnPreDrawListener true } Loading @@ -169,16 +175,18 @@ class ClockSizeTransition( anim.addListener( object : AnimatorListenerAdapter() { override fun onAnimationStart(anim: Animator) { assignAnimValues("start", fromAlpha, 0f) assignAnimValues("start", 0f, fromVis) } override fun onAnimationEnd(anim: Animator) { assignAnimValues("end", toAlpha, 1f, toVis) assignAnimValues("end", 1f, toVis) if (sendToBack) toView.translationZ = 0f toView.viewTreeObserver.removeOnPreDrawListener(predrawCallback) } } ) assignAnimValues("init", 0f, fromVis) toView.viewTreeObserver.addOnPreDrawListener(predrawCallback) } } Loading Loading @@ -216,13 +224,16 @@ class ClockSizeTransition( override fun mutateBounds( view: View, fromVis: Int, toVis: Int, fromIsVis: Boolean, toIsVis: Boolean, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) { // Move normally if clock is not changing visibility if (fromIsVis == toIsVis) return fromBounds.left = toBounds.left fromBounds.right = toBounds.right if (viewModel.useLargeClock) { Loading Loading @@ -271,13 +282,16 @@ class ClockSizeTransition( override fun mutateBounds( view: View, fromVis: Int, toVis: Int, fromIsVis: Boolean, toIsVis: Boolean, fromBounds: Rect, toBounds: Rect, fromSSBounds: Rect?, toSSBounds: Rect? ) { // Move normally if clock is not changing visibility if (fromIsVis == toIsVis) return toBounds.left = fromBounds.left toBounds.right = fromBounds.right if (!viewModel.useLargeClock) { Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/transitions/DefaultClockSteppingTransition.kt +2 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,8 @@ class DefaultClockSteppingTransition( } companion object { private const val PROP_BOUNDS_LEFT = "splitShadeTransitionAdapter:boundsLeft" private const val PROP_X_IN_WINDOW = "splitShadeTransitionAdapter:xInWindow" private const val PROP_BOUNDS_LEFT = "DefaultClockSteppingTransition:boundsLeft" private const val PROP_X_IN_WINDOW = "DefaultClockSteppingTransition:xInWindow" private val TRANSITION_PROPERTIES = arrayOf(PROP_BOUNDS_LEFT, PROP_X_IN_WINDOW) private const val KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION_MS = 1000L } Loading