Loading packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt +17 −11 Original line number Diff line number Diff line Loading @@ -44,30 +44,36 @@ interface SystemStatusAnimationScheduler : */ interface SystemStatusAnimationCallback { /** Implement this method to return an [Animator] or [AnimatorSet] that presents the chip */ fun onSystemEventAnimationBegin(): Animator? { return null } fun onSystemEventAnimationBegin(): Animator? { return null } /** Implement this method to return an [Animator] or [AnimatorSet] that hides the chip */ fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator? { return null } fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator? { return null } // Best method name, change my mind fun onSystemStatusAnimationTransitionToPersistentDot(contentDescription: String?): Animator? { return null } fun onHidePersistentDot(): Animator? { return null } } fun onHidePersistentDot(): Animator? { return null } } /** * Animation state IntDef */ /** Animation state IntDef */ @Retention(AnnotationRetention.SOURCE) @IntDef( value = [ value = [ IDLE, ANIMATION_QUEUED, ANIMATING_IN, RUNNING_CHIP_ANIM, ANIMATING_OUT, SHOWING_PERSISTENT_DOT SHOWING_PERSISTENT_DOT, ] ) annotation class SystemAnimationState Loading packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt +5 −9 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ constructor( dumpManager: DumpManager, private val systemClock: SystemClock, @Application private val coroutineScope: CoroutineScope, private val logger: SystemStatusAnimationSchedulerLogger? private val logger: SystemStatusAnimationSchedulerLogger?, ) : SystemStatusAnimationScheduler { companion object { Loading Loading @@ -122,9 +122,7 @@ constructor( } } coroutineScope.launch { animationState.collect { logger?.logAnimationStateUpdate(it) } } coroutineScope.launch { animationState.collect { logger?.logAnimationStateUpdate(it) } } } @SystemAnimationState override fun getAnimationState(): Int = animationState.value Loading Loading @@ -195,7 +193,7 @@ constructor( return DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_PRIVACY, PROPERTY_ENABLE_IMMERSIVE_INDICATOR, true true, ) } Loading Loading @@ -356,9 +354,7 @@ constructor( logger?.logTransitionToPersistentDotCallbackInvoked() val anims: List<Animator> = listeners.mapNotNull { it.onSystemStatusAnimationTransitionToPersistentDot( event?.contentDescription ) it.onSystemStatusAnimationTransitionToPersistentDot(event?.contentDescription) } if (anims.isNotEmpty()) { val aSet = AnimatorSet() Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/StatusBarSystemEventAnimator.kt +50 −46 Original line number Diff line number Diff line Loading @@ -16,11 +16,11 @@ package com.android.systemui.statusbar.phone.fragment import android.content.res.Resources import android.view.View import androidx.core.animation.Animator import androidx.core.animation.AnimatorSet import androidx.core.animation.ValueAnimator import android.content.res.Resources import android.view.View import com.android.systemui.res.R import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_IN import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_OUT Loading @@ -33,15 +33,14 @@ import com.android.systemui.util.doOnEnd * An implementation of [StatusBarSystemEventDefaultAnimator], applying the onAlphaChanged and * onTranslationXChanged callbacks directly to the provided animatedView. */ class StatusBarSystemEventAnimator @JvmOverloads constructor( val animatedView: View, resources: Resources, isAnimationRunning: Boolean = false ) : StatusBarSystemEventDefaultAnimator( class StatusBarSystemEventAnimator @JvmOverloads constructor(val animatedView: View, resources: Resources, isAnimationRunning: Boolean = false) : StatusBarSystemEventDefaultAnimator( resources = resources, onAlphaChanged = animatedView::setAlpha, onTranslationXChanged = animatedView::setTranslationX, isAnimationRunning = isAnimationRunning isAnimationRunning = isAnimationRunning, ) /** Loading @@ -53,33 +52,38 @@ class StatusBarSystemEventAnimator @JvmOverloads constructor( * this class could be used directly as the animation callback, it's probably best to forward calls * to it so that it can be recreated at any moment without needing to remove/add callback. */ open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( resources: Resources, private val onAlphaChanged: (Float) -> Unit, private val onTranslationXChanged: (Float) -> Unit, var isAnimationRunning: Boolean = false var isAnimationRunning: Boolean = false, ) : SystemStatusAnimationCallback { private val translationXIn: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_in_status_bar_translation_x) private val translationXOut: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_out_status_bar_translation_x) private val translationXIn: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_in_status_bar_translation_x ) private val translationXOut: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_out_status_bar_translation_x ) override fun onSystemEventAnimationBegin(): Animator { isAnimationRunning = true val moveOut = ValueAnimator.ofFloat(0f, 1f).apply { val moveOut = ValueAnimator.ofFloat(0f, 1f).apply { duration = 23.frames interpolator = STATUS_BAR_X_MOVE_OUT addUpdateListener { onTranslationXChanged(-(translationXIn * animatedValue as Float)) } } val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply { val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply { duration = 8.frames interpolator = null addUpdateListener { onAlphaChanged(animatedValue as Float) } addUpdateListener { onAlphaChanged(animatedValue as Float) } } val animSet = AnimatorSet() Loading @@ -89,7 +93,8 @@ open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( override fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator { onTranslationXChanged(translationXOut.toFloat()) val moveIn = ValueAnimator.ofFloat(1f, 0f).apply { val moveIn = ValueAnimator.ofFloat(1f, 0f).apply { duration = 23.frames startDelay = 7.frames interpolator = STATUS_BAR_X_MOVE_IN Loading @@ -97,13 +102,12 @@ open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( onTranslationXChanged(translationXOut * animatedValue as Float) } } val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply { val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply { duration = 5.frames startDelay = 11.frames interpolator = null addUpdateListener { onAlphaChanged(animatedValue as Float) } addUpdateListener { onAlphaChanged(animatedValue as Float) } } val animatorSet = AnimatorSet() Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt +17 −11 Original line number Diff line number Diff line Loading @@ -44,30 +44,36 @@ interface SystemStatusAnimationScheduler : */ interface SystemStatusAnimationCallback { /** Implement this method to return an [Animator] or [AnimatorSet] that presents the chip */ fun onSystemEventAnimationBegin(): Animator? { return null } fun onSystemEventAnimationBegin(): Animator? { return null } /** Implement this method to return an [Animator] or [AnimatorSet] that hides the chip */ fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator? { return null } fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator? { return null } // Best method name, change my mind fun onSystemStatusAnimationTransitionToPersistentDot(contentDescription: String?): Animator? { return null } fun onHidePersistentDot(): Animator? { return null } } fun onHidePersistentDot(): Animator? { return null } } /** * Animation state IntDef */ /** Animation state IntDef */ @Retention(AnnotationRetention.SOURCE) @IntDef( value = [ value = [ IDLE, ANIMATION_QUEUED, ANIMATING_IN, RUNNING_CHIP_ANIM, ANIMATING_OUT, SHOWING_PERSISTENT_DOT SHOWING_PERSISTENT_DOT, ] ) annotation class SystemAnimationState Loading
packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationSchedulerImpl.kt +5 −9 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ constructor( dumpManager: DumpManager, private val systemClock: SystemClock, @Application private val coroutineScope: CoroutineScope, private val logger: SystemStatusAnimationSchedulerLogger? private val logger: SystemStatusAnimationSchedulerLogger?, ) : SystemStatusAnimationScheduler { companion object { Loading Loading @@ -122,9 +122,7 @@ constructor( } } coroutineScope.launch { animationState.collect { logger?.logAnimationStateUpdate(it) } } coroutineScope.launch { animationState.collect { logger?.logAnimationStateUpdate(it) } } } @SystemAnimationState override fun getAnimationState(): Int = animationState.value Loading Loading @@ -195,7 +193,7 @@ constructor( return DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_PRIVACY, PROPERTY_ENABLE_IMMERSIVE_INDICATOR, true true, ) } Loading Loading @@ -356,9 +354,7 @@ constructor( logger?.logTransitionToPersistentDotCallbackInvoked() val anims: List<Animator> = listeners.mapNotNull { it.onSystemStatusAnimationTransitionToPersistentDot( event?.contentDescription ) it.onSystemStatusAnimationTransitionToPersistentDot(event?.contentDescription) } if (anims.isNotEmpty()) { val aSet = AnimatorSet() Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/StatusBarSystemEventAnimator.kt +50 −46 Original line number Diff line number Diff line Loading @@ -16,11 +16,11 @@ package com.android.systemui.statusbar.phone.fragment import android.content.res.Resources import android.view.View import androidx.core.animation.Animator import androidx.core.animation.AnimatorSet import androidx.core.animation.ValueAnimator import android.content.res.Resources import android.view.View import com.android.systemui.res.R import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_IN import com.android.systemui.statusbar.events.STATUS_BAR_X_MOVE_OUT Loading @@ -33,15 +33,14 @@ import com.android.systemui.util.doOnEnd * An implementation of [StatusBarSystemEventDefaultAnimator], applying the onAlphaChanged and * onTranslationXChanged callbacks directly to the provided animatedView. */ class StatusBarSystemEventAnimator @JvmOverloads constructor( val animatedView: View, resources: Resources, isAnimationRunning: Boolean = false ) : StatusBarSystemEventDefaultAnimator( class StatusBarSystemEventAnimator @JvmOverloads constructor(val animatedView: View, resources: Resources, isAnimationRunning: Boolean = false) : StatusBarSystemEventDefaultAnimator( resources = resources, onAlphaChanged = animatedView::setAlpha, onTranslationXChanged = animatedView::setTranslationX, isAnimationRunning = isAnimationRunning isAnimationRunning = isAnimationRunning, ) /** Loading @@ -53,33 +52,38 @@ class StatusBarSystemEventAnimator @JvmOverloads constructor( * this class could be used directly as the animation callback, it's probably best to forward calls * to it so that it can be recreated at any moment without needing to remove/add callback. */ open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( resources: Resources, private val onAlphaChanged: (Float) -> Unit, private val onTranslationXChanged: (Float) -> Unit, var isAnimationRunning: Boolean = false var isAnimationRunning: Boolean = false, ) : SystemStatusAnimationCallback { private val translationXIn: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_in_status_bar_translation_x) private val translationXOut: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_out_status_bar_translation_x) private val translationXIn: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_in_status_bar_translation_x ) private val translationXOut: Int = resources.getDimensionPixelSize( R.dimen.ongoing_appops_chip_animation_out_status_bar_translation_x ) override fun onSystemEventAnimationBegin(): Animator { isAnimationRunning = true val moveOut = ValueAnimator.ofFloat(0f, 1f).apply { val moveOut = ValueAnimator.ofFloat(0f, 1f).apply { duration = 23.frames interpolator = STATUS_BAR_X_MOVE_OUT addUpdateListener { onTranslationXChanged(-(translationXIn * animatedValue as Float)) } } val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply { val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply { duration = 8.frames interpolator = null addUpdateListener { onAlphaChanged(animatedValue as Float) } addUpdateListener { onAlphaChanged(animatedValue as Float) } } val animSet = AnimatorSet() Loading @@ -89,7 +93,8 @@ open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( override fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator { onTranslationXChanged(translationXOut.toFloat()) val moveIn = ValueAnimator.ofFloat(1f, 0f).apply { val moveIn = ValueAnimator.ofFloat(1f, 0f).apply { duration = 23.frames startDelay = 7.frames interpolator = STATUS_BAR_X_MOVE_IN Loading @@ -97,13 +102,12 @@ open class StatusBarSystemEventDefaultAnimator @JvmOverloads constructor( onTranslationXChanged(translationXOut * animatedValue as Float) } } val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply { val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply { duration = 5.frames startDelay = 11.frames interpolator = null addUpdateListener { onAlphaChanged(animatedValue as Float) } addUpdateListener { onAlphaChanged(animatedValue as Float) } } val animatorSet = AnimatorSet() Loading