Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c0a668d authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Adjust clock switch animation timing" into udc-dev

parents 5a4d1bd9 a8fc6355
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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 -->
+38 −25
Original line number Diff line number Diff line
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();
    }

+5 −4
Original line number Diff line number Diff line
@@ -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
            )