diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt index f25928418cbdb..6a8d5c1fca9a4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.events -import android.animation.Animator +import androidx.core.animation.Animator import android.annotation.UiThread import android.graphics.Point import android.graphics.Rect diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt index b498107752e00..52def065ecc23 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemEventChipAnimationController.kt @@ -16,10 +16,6 @@ package com.android.systemui.statusbar.events -import android.animation.Animator -import android.animation.AnimatorListenerAdapter -import android.animation.AnimatorSet -import android.animation.ValueAnimator import android.content.Context import android.graphics.Rect import android.view.ContextThemeWrapper @@ -30,6 +26,10 @@ import android.view.View.MeasureSpec.AT_MOST import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.widget.FrameLayout +import androidx.core.animation.Animator +import androidx.core.animation.AnimatorListenerAdapter +import androidx.core.animation.AnimatorSet +import androidx.core.animation.ValueAnimator import com.android.systemui.R import com.android.systemui.statusbar.phone.StatusBarContentInsetsProvider import com.android.systemui.statusbar.window.StatusBarWindowController @@ -144,7 +144,7 @@ class SystemEventChipAnimationController @Inject constructor( } finish.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animationWindowView.removeView(currentAnimatedView!!.view) } }) @@ -157,7 +157,7 @@ class SystemEventChipAnimationController @Inject constructor( duration = 9.frames interpolator = STATUS_CHIP_WIDTH_TO_DOT_KEYFRAME_1 addUpdateListener { - updateAnimatedViewBoundsWidth(it.animatedValue as Int) + updateAnimatedViewBoundsWidth(animatedValue as Int) } } @@ -166,7 +166,7 @@ class SystemEventChipAnimationController @Inject constructor( duration = 20.frames interpolator = STATUS_CHIP_WIDTH_TO_DOT_KEYFRAME_2 addUpdateListener { - updateAnimatedViewBoundsWidth(it.animatedValue as Int) + updateAnimatedViewBoundsWidth(animatedValue as Int) } } @@ -179,7 +179,7 @@ class SystemEventChipAnimationController @Inject constructor( duration = 6.frames interpolator = STATUS_CHIP_HEIGHT_TO_DOT_KEYFRAME_1 addUpdateListener { - updateAnimatedViewBoundsHeight(it.animatedValue as Int, chipVerticalCenter) + updateAnimatedViewBoundsHeight(animatedValue as Int, chipVerticalCenter) } } @@ -188,7 +188,7 @@ class SystemEventChipAnimationController @Inject constructor( duration = 15.frames interpolator = STATUS_CHIP_HEIGHT_TO_DOT_KEYFRAME_2 addUpdateListener { - updateAnimatedViewBoundsHeight(it.animatedValue as Int, chipVerticalCenter) + updateAnimatedViewBoundsHeight(animatedValue as Int, chipVerticalCenter) } } @@ -233,7 +233,7 @@ class SystemEventChipAnimationController @Inject constructor( interpolator = STATUS_BAR_X_MOVE_OUT addUpdateListener { currentAnimatedView?.apply { - updateAnimatedViewBoundsWidth(it.animatedValue as Int) + updateAnimatedViewBoundsWidth(animatedValue as Int) } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt index 3c35e4bbc8410..13a70d6e22b5e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/SystemStatusAnimationScheduler.kt @@ -16,14 +16,14 @@ package com.android.systemui.statusbar.events -import android.animation.Animator -import android.animation.AnimatorListenerAdapter -import android.animation.AnimatorSet +import androidx.core.animation.Animator +import androidx.core.animation.AnimatorSet import android.annotation.IntDef import android.os.Process import android.provider.DeviceConfig import android.util.Log -import android.view.animation.PathInterpolator +import androidx.core.animation.AnimatorListenerAdapter +import androidx.core.animation.PathInterpolator import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main @@ -185,7 +185,7 @@ open class SystemStatusAnimationScheduler @Inject constructor( "Expected: 500, actual: ${animSet.totalDuration}") } animSet.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animationState = RUNNING_CHIP_ANIM } }) @@ -195,7 +195,7 @@ open class SystemStatusAnimationScheduler @Inject constructor( val animSet2 = collectFinishAnimations() animationState = ANIMATING_OUT animSet2.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animationState = if (hasPersistentDot) { SHOWING_PERSISTENT_DOT } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java index cba0897408ddf..753032c2ee017 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java @@ -21,9 +21,6 @@ import static android.app.StatusBarManager.DISABLE_SYSTEM_INFO; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ValueAnimator; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; @@ -36,13 +33,16 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; +import androidx.core.animation.Animator; +import androidx.core.animation.AnimatorListenerAdapter; +import androidx.core.animation.ValueAnimator; import com.android.keyguard.CarrierTextController; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.logging.KeyguardLogger; import com.android.systemui.R; -import com.android.systemui.animation.Interpolators; +import com.android.systemui.animation.InterpolatorsAndroidX; import com.android.systemui.battery.BatteryMeterViewController; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.log.LogLevel; @@ -166,7 +166,8 @@ public class KeyguardStatusBarViewController extends ViewController { - mKeyguardStatusBarAnimateAlpha = (float) animation.getAnimatedValue(); + mKeyguardStatusBarAnimateAlpha = + (float) ((ValueAnimator) animation).getAnimatedValue(); updateViewState(); }; @@ -434,7 +435,7 @@ public class KeyguardStatusBarViewController extends ViewController - animatedView.translationX = -(translationXIn * animation.animatedValue as Float) + val moveOut = ValueAnimator.ofFloat(0f, 1f).apply { + duration = 23.frames + interpolator = STATUS_BAR_X_MOVE_OUT + addUpdateListener { + animatedView.translationX = -(translationXIn * animatedValue as Float) + } } - val alphaOut = ValueAnimator.ofFloat(1f, 0f).setDuration(8.frames) - alphaOut.interpolator = null - alphaOut.addUpdateListener { animation: ValueAnimator -> - animatedView.alpha = animation.animatedValue as Float + val alphaOut = ValueAnimator.ofFloat(1f, 0f).apply { + duration = 8.frames + interpolator = null + addUpdateListener { + animatedView.alpha = animatedValue as Float + } } val animSet = AnimatorSet() @@ -64,17 +68,21 @@ class StatusBarSystemEventAnimator( override fun onSystemEventAnimationFinish(hasPersistentDot: Boolean): Animator { animatedView.translationX = translationXOut.toFloat() - val moveIn = ValueAnimator.ofFloat(1f, 0f).setDuration(23.frames) - moveIn.startDelay = 7.frames - moveIn.interpolator = STATUS_BAR_X_MOVE_IN - moveIn.addUpdateListener { animation: ValueAnimator -> - animatedView.translationX = translationXOut * animation.animatedValue as Float + val moveIn = ValueAnimator.ofFloat(1f, 0f).apply { + duration = 23.frames + startDelay = 7.frames + interpolator = STATUS_BAR_X_MOVE_IN + addUpdateListener { + animatedView.translationX = translationXOut * animatedValue as Float + } } - val alphaIn = ValueAnimator.ofFloat(0f, 1f).setDuration(5.frames) - alphaIn.startDelay = 11.frames - alphaIn.interpolator = null - alphaIn.addUpdateListener { animation: ValueAnimator -> - animatedView.alpha = animation.animatedValue as Float + val alphaIn = ValueAnimator.ofFloat(0f, 1f).apply { + duration = 5.frames + startDelay = 11.frames + interpolator = null + addUpdateListener { + animatedView.alpha = animatedValue as Float + } } val animatorSet = AnimatorSet() diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java index 07e8d3c195182..1e5782b91be8e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java @@ -32,7 +32,6 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import android.animation.Animator; import android.app.Fragment; import android.app.StatusBarManager; import android.content.Context; @@ -45,6 +44,7 @@ import android.view.View; import android.view.ViewPropertyAnimator; import android.widget.FrameLayout; +import androidx.core.animation.Animator; import androidx.test.filters.SmallTest; import com.android.keyguard.KeyguardUpdateMonitor;