diff options
author | 2023-05-22 20:11:47 +0000 | |
---|---|---|
committer | 2023-05-22 20:11:47 +0000 | |
commit | 5be656e3e8d305c6a99ff91ac6abd44618957549 (patch) | |
tree | b8e464c67b8e4c36cf13d5c4ff5a12bf99c1ab66 | |
parent | 3baa1d68d03d859e1053006c9ff2bfff16677969 (diff) | |
parent | 6c0a668d51984eec8d718b5169732269e2b7ea99 (diff) |
Merge "Adjust clock switch animation timing" into udc-dev am: 6c0a668d51
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22955246
Change-Id: I78924f1b5c397f09d4e133a4b0bf83d35a53ad05
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
4 files changed, 46 insertions, 31 deletions
diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt index 8dd2c39e7a58..465b73e6de19 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt @@ -272,6 +272,7 @@ class AnimatableClockView @JvmOverloads constructor( color = lockScreenColor, animate = isAnimationEnabled, duration = APPEAR_ANIM_DURATION, + interpolator = Interpolators.EMPHASIZED_DECELERATE, delay = 0, onAnimationEnd = null ) @@ -562,7 +563,7 @@ class AnimatableClockView @JvmOverloads constructor( private const val DOUBLE_LINE_FORMAT_12_HOUR = "hh\nmm" private const val DOUBLE_LINE_FORMAT_24_HOUR = "HH\nmm" private const val DOZE_ANIM_DURATION: Long = 300 - private const val APPEAR_ANIM_DURATION: Long = 350 + private const val APPEAR_ANIM_DURATION: Long = 833 private const val CHARGE_ANIM_DURATION_PHASE_0: Long = 500 private const val CHARGE_ANIM_DURATION_PHASE_1: Long = 1000 private const val COLOR_ANIM_DURATION: Long = 400 diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index a62dead7834b..8d3ba364da06 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -716,7 +716,7 @@ <!-- Minimum margin between clock and status bar --> <dimen name="keyguard_clock_top_margin">18dp</dimen> <!-- The amount to shift the clocks during a small/large transition --> - <dimen name="keyguard_clock_switch_y_shift">10dp</dimen> + <dimen name="keyguard_clock_switch_y_shift">14dp</dimen> <!-- When large clock is showing, offset the smartspace by this amount --> <dimen name="keyguard_smartspace_top_offset">12dp</dimen> <!-- With the large clock, move up slightly from the center --> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index 432153b6726a..d9d64ad5a893 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -1,5 +1,8 @@ package com.android.keyguard; +import static android.view.View.ALPHA; +import static android.view.View.TRANSLATION_Y; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; @@ -35,11 +38,12 @@ public class KeyguardClockSwitch extends RelativeLayout { private static final String TAG = "KeyguardClockSwitch"; - private static final long CLOCK_OUT_MILLIS = 150; - private static final long CLOCK_IN_MILLIS = 200; - public static final long CLOCK_IN_START_DELAY_MILLIS = CLOCK_OUT_MILLIS / 2; - private static final long STATUS_AREA_START_DELAY_MILLIS = 50; - private static final long STATUS_AREA_MOVE_MILLIS = 350; + private static final long CLOCK_OUT_MILLIS = 133; + private static final long CLOCK_IN_MILLIS = 167; + public static final long CLOCK_IN_START_DELAY_MILLIS = 133; + private static final long STATUS_AREA_START_DELAY_MILLIS = 0; + private static final long STATUS_AREA_MOVE_UP_MILLIS = 967; + private static final long STATUS_AREA_MOVE_DOWN_MILLIS = 467; @IntDef({LARGE, SMALL}) @Retention(RetentionPolicy.SOURCE) @@ -101,7 +105,7 @@ public class KeyguardClockSwitch extends RelativeLayout { @VisibleForTesting AnimatorSet mClockInAnim = null; @VisibleForTesting AnimatorSet mClockOutAnim = null; - private ObjectAnimator mStatusAreaAnim = null; + private AnimatorSet mStatusAreaAnim = null; private int mClockSwitchYAmount; @VisibleForTesting boolean mChildrenAreLaidOut = false; @@ -226,39 +230,44 @@ public class KeyguardClockSwitch extends RelativeLayout { mStatusAreaAnim = null; View in, out; - int direction = 1; - float statusAreaYTranslation; + float statusAreaYTranslation, clockInYTranslation, clockOutYTranslation; if (useLargeClock) { out = mSmallClockFrame; in = mLargeClockFrame; if (indexOfChild(in) == -1) addView(in, 0); - direction = -1; statusAreaYTranslation = mSmallClockFrame.getTop() - mStatusArea.getTop() + mSmartspaceTopOffset; + clockInYTranslation = 0; + clockOutYTranslation = 0; // Small clock translation is handled with statusArea } else { in = mSmallClockFrame; out = mLargeClockFrame; statusAreaYTranslation = 0f; + clockInYTranslation = 0f; + clockOutYTranslation = mClockSwitchYAmount * -1f; - // Must remove in order for notifications to appear in the proper place + // Must remove in order for notifications to appear in the proper place, ideally this + // would happen after the out animation runs, but we can't guarantee that the + // nofications won't enter only after the out animation runs. removeView(out); } if (!animate) { out.setAlpha(0f); + out.setTranslationY(clockOutYTranslation); in.setAlpha(1f); - in.setVisibility(VISIBLE); + in.setTranslationY(clockInYTranslation); + in.setVisibility(View.VISIBLE); mStatusArea.setTranslationY(statusAreaYTranslation); return; } mClockOutAnim = new AnimatorSet(); mClockOutAnim.setDuration(CLOCK_OUT_MILLIS); - mClockOutAnim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN); + mClockOutAnim.setInterpolator(Interpolators.LINEAR); mClockOutAnim.playTogether( - ObjectAnimator.ofFloat(out, View.ALPHA, 0f), - ObjectAnimator.ofFloat(out, View.TRANSLATION_Y, 0, - direction * -mClockSwitchYAmount)); + ObjectAnimator.ofFloat(out, ALPHA, 0f), + ObjectAnimator.ofFloat(out, TRANSLATION_Y, clockOutYTranslation)); mClockOutAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { mClockOutAnim = null; @@ -270,8 +279,9 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockInAnim = new AnimatorSet(); mClockInAnim.setDuration(CLOCK_IN_MILLIS); mClockInAnim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); - mClockInAnim.playTogether(ObjectAnimator.ofFloat(in, View.ALPHA, 1f), - ObjectAnimator.ofFloat(in, View.TRANSLATION_Y, direction * mClockSwitchYAmount, 0)); + mClockInAnim.playTogether( + ObjectAnimator.ofFloat(in, ALPHA, 1f), + ObjectAnimator.ofFloat(in, TRANSLATION_Y, clockInYTranslation)); mClockInAnim.setStartDelay(CLOCK_IN_START_DELAY_MILLIS); mClockInAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { @@ -279,19 +289,22 @@ public class KeyguardClockSwitch extends RelativeLayout { } }); - mClockInAnim.start(); - mClockOutAnim.start(); - - mStatusAreaAnim = ObjectAnimator.ofFloat(mStatusArea, View.TRANSLATION_Y, - statusAreaYTranslation); - mStatusAreaAnim.setStartDelay(useLargeClock ? STATUS_AREA_START_DELAY_MILLIS : 0L); - mStatusAreaAnim.setDuration(STATUS_AREA_MOVE_MILLIS); - mStatusAreaAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); + mStatusAreaAnim = new AnimatorSet(); + mStatusAreaAnim.setStartDelay(STATUS_AREA_START_DELAY_MILLIS); + mStatusAreaAnim.setDuration( + useLargeClock ? STATUS_AREA_MOVE_UP_MILLIS : STATUS_AREA_MOVE_DOWN_MILLIS); + mStatusAreaAnim.setInterpolator(Interpolators.EMPHASIZED); + mStatusAreaAnim.playTogether( + ObjectAnimator.ofFloat(mStatusArea, TRANSLATION_Y, statusAreaYTranslation), + ObjectAnimator.ofFloat(mSmallClockFrame, TRANSLATION_Y, statusAreaYTranslation)); mStatusAreaAnim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { mStatusAreaAnim = null; } }); + + mClockInAnim.start(); + mClockOutAnim.start(); mStatusAreaAnim.start(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shared/clocks/AnimatableClockViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shared/clocks/AnimatableClockViewTest.kt index 2eca78a0412b..e92368df8663 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shared/clocks/AnimatableClockViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shared/clocks/AnimatableClockViewTest.kt @@ -19,6 +19,7 @@ package com.android.systemui.shared.clocks import android.testing.AndroidTestingRunner import android.view.LayoutInflater import androidx.test.filters.SmallTest +import com.android.app.animation.Interpolators import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.animation.TextAnimator @@ -64,8 +65,8 @@ class AnimatableClockViewTest : SysuiTestCase() { color = 200, strokeWidth = -1F, animate = false, - duration = 350L, - interpolator = null, + duration = 833L, + interpolator = Interpolators.EMPHASIZED_DECELERATE, delay = 0L, onAnimationEnd = null ) @@ -98,8 +99,8 @@ class AnimatableClockViewTest : SysuiTestCase() { color = 200, strokeWidth = -1F, animate = true, - duration = 350L, - interpolator = null, + duration = 833L, + interpolator = Interpolators.EMPHASIZED_DECELERATE, delay = 0L, onAnimationEnd = null ) |