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

Commit 2c3fffaf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update num pad button font and font scale animation to match spec" into main

parents 5324debd 81187100
Loading
Loading
Loading
Loading
+41 −4
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.keyguard;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
@@ -33,6 +34,9 @@ import com.android.systemui.Flags;
import com.android.systemui.bouncer.shared.constants.PinBouncerConstants.Animation;
import com.android.systemui.bouncer.shared.constants.PinBouncerConstants.Color;

import java.util.ArrayList;
import java.util.List;

/**
 * Provides background color and radius animations for key pad buttons.
 */
@@ -141,6 +145,7 @@ class NumPadAnimator {
        mExpandAnimator.addUpdateListener(
                anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue()));

        List<Animator> expandAnimators = new ArrayList<>();
        ValueAnimator expandBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(),
                mNormalBackgroundColor, mPressedBackgroundColor);
        expandBackgroundColorAnimator.setDuration(Animation.expansionColorDuration);
@@ -162,10 +167,27 @@ class NumPadAnimator {
            }
        });

        expandAnimators.add(mExpandAnimator);
        expandAnimators.add(expandBackgroundColorAnimator);
        expandAnimators.add(expandTextColorAnimator);

        if (Flags.bouncerUiRevamp2()) {
            ValueAnimator expandTextScaleAnimator = ValueAnimator.ofFloat(
                    Animation.normalTextScaleX, Animation.pressedTextScaleX);
            expandTextScaleAnimator.setInterpolator(Animation.expansionInterpolator);
            expandTextScaleAnimator.setDuration(Animation.expansionDuration);
            expandTextScaleAnimator.addUpdateListener(valueAnimator -> {
                if (mDigitTextView != null) {
                    mDigitTextView.setTextScaleX((Float) valueAnimator.getAnimatedValue());
                }
            });
            expandAnimators.add(expandTextScaleAnimator);
        }

        mExpandAnimatorSet = new AnimatorSet();
        mExpandAnimatorSet.playTogether(mExpandAnimator,
                expandBackgroundColorAnimator, expandTextColorAnimator);
        mExpandAnimatorSet.playTogether(expandAnimators);

        List<Animator> contractAnimators = new ArrayList<>();
        mContractAnimator = ValueAnimator.ofFloat(1f, 0f);
        mContractAnimator.setStartDelay(Animation.contractionStartDelay);
        mContractAnimator.setDuration(Animation.contractionDuration);
@@ -195,9 +217,24 @@ class NumPadAnimator {
            }
        });

        contractAnimators.add(mContractAnimator);
        contractAnimators.add(contractBackgroundColorAnimator);
        contractAnimators.add(contractTextColorAnimator);

        if (Flags.bouncerUiRevamp2()) {
            ValueAnimator contractTextScaleAnimator = ValueAnimator.ofFloat(
                    Animation.pressedTextScaleX, Animation.normalTextScaleX);
            contractTextScaleAnimator.setInterpolator(Animation.contractionRadiusInterpolator);
            contractTextScaleAnimator.setDuration(Animation.contractionDuration);
            contractTextScaleAnimator.addUpdateListener(valueAnimator -> {
                if (mDigitTextView != null) {
                    mDigitTextView.setTextScaleX((Float) valueAnimator.getAnimatedValue());
                }
            });
            contractAnimators.add(contractTextScaleAnimator);
        }
        mContractAnimatorSet = new AnimatorSet();
        mContractAnimatorSet.playTogether(mContractAnimator,
                contractBackgroundColorAnimator, contractTextColorAnimator);
        mContractAnimatorSet.playTogether(contractAnimators);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ public class NumPadKey extends ViewGroup implements NumPadAnimationListener {

        if (bouncerUiRevamp2()) {
            mDigitText.setTypeface(
                    Typeface.create(FontStyles.GSF_LABEL_LARGE_EMPHASIZED, Typeface.NORMAL));
                    Typeface.create(FontStyles.GSF_LABEL_SMALL_EMPHASIZED, Typeface.NORMAL));
        }
    }

+3 −0
Original line number Diff line number Diff line
@@ -126,5 +126,8 @@ object PinBouncerConstants {
        @JvmField
        val contractionColorInterpolator =
            c(old = Interpolators.LINEAR, new = Interpolators.STANDARD)!!

        const val pressedTextScaleX = 1.35f
        const val normalTextScaleX = 1.0f
    }
}