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

Commit 66430ca2 authored by Aaron Liu's avatar Aaron Liu
Browse files

[Bouncer] refine entry for bouncer user switcher.

Match the animation of the user switcher with the pin view.
Increase the duration of the animation and add a y translation animation
when invoking the appear animation.

Also refine the entry text animation. Ensure that prompt is shown first
by removing animation time. Also ensure that initial text does not
animate in so that the entry animation is better refined. Added tests as
well.

For some of the tests, ktfmt reformatted the tests...these should just
be formatting changes.

Bug: 261571180
Test: Manually open bouncer with a quick swipe up in tablet device.
Test: Added unit tests.

Change-Id: Ic36b1554a7c3c73e0e8805db972e1bd3f0de57fe
parent 71d3dbf2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -260,7 +260,8 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
        if (reason != PROMPT_REASON_NONE) {
            int promtReasonStringRes = mView.getPromptReasonStringRes(reason);
            if (promtReasonStringRes != 0) {
                mMessageAreaController.setMessage(promtReasonStringRes);
                mMessageAreaController.setMessage(
                        mView.getResources().getString(promtReasonStringRes), false);
            }
        }
    }
+3 −1
Original line number Diff line number Diff line
@@ -143,7 +143,9 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>

    public void startAppearAnimation() {
        if (TextUtils.isEmpty(mMessageAreaController.getMessage())) {
            mMessageAreaController.setMessage(getInitialMessageResId());
            mMessageAreaController.setMessage(
                    mView.getResources().getString(getInitialMessageResId()),
                    /* animate= */ false);
        }
        mView.startAppearAnimation();
    }
+2 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    private int mYTransOffset;
    private View mBouncerMessageView;
    @DevicePostureInt private int mLastDevicePosture = DEVICE_POSTURE_UNKNOWN;
    public static final long ANIMATION_DURATION = 650;

    public KeyguardPINView(Context context) {
        this(context, null);
@@ -181,7 +182,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
        if (mAppearAnimator.isRunning()) {
            mAppearAnimator.cancel();
        }
        mAppearAnimator.setDuration(650);
        mAppearAnimator.setDuration(ANIMATION_DURATION);
        mAppearAnimator.addUpdateListener(animation -> animate(animation.getAnimatedFraction()));
        mAppearAnimator.start();
    }
+20 −5
Original line number Diff line number Diff line
@@ -36,8 +36,11 @@ import static com.android.systemui.plugins.FalsingManager.LOW_PENALTY;

import static java.lang.Integer.max;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
@@ -967,11 +970,23 @@ public class KeyguardSecurityContainer extends ConstraintLayout {
            }

            mUserSwitcherViewGroup.setAlpha(0f);
            ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mUserSwitcherViewGroup, View.ALPHA,
                    1f);
            alphaAnim.setInterpolator(Interpolators.ALPHA_IN);
            alphaAnim.setDuration(500);
            alphaAnim.start();
            ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
            int yTrans = mView.getResources().getDimensionPixelSize(R.dimen.pin_view_trans_y_entry);
            animator.setInterpolator(Interpolators.STANDARD_DECELERATE);
            animator.setDuration(650);
            animator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mUserSwitcherViewGroup.setAlpha(1f);
                    mUserSwitcherViewGroup.setTranslationY(0f);
                }
            });
            animator.addUpdateListener(animation -> {
                float value = (float) animation.getAnimatedValue();
                mUserSwitcherViewGroup.setAlpha(value);
                mUserSwitcherViewGroup.setTranslationY(yTrans - yTrans * value);
            });
            animator.start();
        }

        @Override
+20 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.keyguard;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
@@ -87,6 +88,7 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
        when(mAbsKeyInputView.isAttachedToWindow()).thenReturn(true);
        when(mAbsKeyInputView.requireViewById(R.id.bouncer_message_area))
                .thenReturn(mKeyguardMessageArea);
        when(mAbsKeyInputView.getResources()).thenReturn(getContext().getResources());
        mKeyguardAbsKeyInputViewController = new KeyguardAbsKeyInputViewController(mAbsKeyInputView,
                mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
                mKeyguardMessageAreaControllerFactory, mLatencyTracker, mFalsingCollector,
@@ -125,4 +127,22 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
        verifyZeroInteractions(mKeyguardSecurityCallback);
        verifyZeroInteractions(mKeyguardMessageAreaController);
    }

    @Test
    public void onPromptReasonNone_doesNotSetMessage() {
        mKeyguardAbsKeyInputViewController.showPromptReason(0);
        verify(mKeyguardMessageAreaController, never()).setMessage(
                getContext().getResources().getString(R.string.kg_prompt_reason_restart_password),
                false);
    }

    @Test
    public void onPromptReason_setsMessage() {
        when(mAbsKeyInputView.getPromptReasonStringRes(1)).thenReturn(
                R.string.kg_prompt_reason_restart_password);
        mKeyguardAbsKeyInputViewController.showPromptReason(1);
        verify(mKeyguardMessageAreaController).setMessage(
                getContext().getResources().getString(R.string.kg_prompt_reason_restart_password),
                false);
    }
}
Loading