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

Commit 636f9239 authored by Matt Pietal's avatar Matt Pietal
Browse files

Transitions - Fix scrim flash as bouncer goes away

When tapping a notification and being prompted by the bouncer, the
animation should start from the notification and not from the
bouncer. Fade the bouncer away quickly to show the animation from the
keyguard. This was most noticeable in user switcher mode.

Fixes: 271823107
Test: atest PrimaryBouncerToGoneTransitionViewModelTest
Change-Id: I97e5883e962a3315f534b4d41d6a16b7ae107889
parent 19f6c52f
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ 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;
@@ -1067,10 +1068,14 @@ public class KeyguardSecurityContainer extends ConstraintLayout {

            int yTranslation = mResources.getDimensionPixelSize(R.dimen.disappear_y_translation);

            AnimatorSet anims = new AnimatorSet();
            ObjectAnimator yAnim = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, yTranslation);
            yAnim.setInterpolator(Interpolators.STANDARD_ACCELERATE);
            yAnim.setDuration(500);
            yAnim.start();
            ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mUserSwitcherViewGroup, View.ALPHA,
                    0f);

            anims.setInterpolator(Interpolators.STANDARD_ACCELERATE);
            anims.playTogether(alphaAnim, yAnim);
            anims.start();
        }

        private void setupUserSwitcher() {
+10 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
    private View.OnKeyListener mOnKeyListener = (v, keyCode, event) -> interceptMediaKey(event);
    private ActivityStarter.OnDismissAction mDismissAction;
    private Runnable mCancelAction;
    private boolean mWillRunDismissFromKeyguard;

    private int mLastOrientation = Configuration.ORIENTATION_UNDEFINED;

@@ -262,8 +263,10 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
            // If there's a pending runnable because the user interacted with a widget
            // and we're leaving keyguard, then run it.
            boolean deferKeyguardDone = false;
            mWillRunDismissFromKeyguard = false;
            if (mDismissAction != null) {
                deferKeyguardDone = mDismissAction.onDismiss();
                mWillRunDismissFromKeyguard = mDismissAction.willRunAnimationOnKeyguard();
                mDismissAction = null;
                mCancelAction = null;
            }
@@ -525,6 +528,13 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        return mDismissAction != null || mCancelAction != null;
    }

    /**
     * @return will the dismissal run from the keyguard layout (instead of from bouncer)
     */
    public boolean willRunDismissFromKeyguard() {
        return mWillRunDismissFromKeyguard;
    }

    /**
     * Remove any dismiss action or cancel action that was set.
     */
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ interface BouncerViewDelegate {
        cancelAction: Runnable?,
    )
    fun willDismissWithActions(): Boolean
    fun willRunDismissFromKeyguard(): Boolean
    /** @return the {@link OnBackAnimationCallback} to animate Bouncer during a back gesture. */
    fun getBackCallback(): OnBackAnimationCallback
}
+5 −0
Original line number Diff line number Diff line
@@ -380,6 +380,11 @@ constructor(
        return primaryBouncerView.delegate?.willDismissWithActions() == true
    }

    /** Will the dismissal run from the keyguard layout (instead of from bouncer) */
    fun willRunDismissFromKeyguard(): Boolean {
        return primaryBouncerView.delegate?.willRunDismissFromKeyguard() == true
    }

    /** Returns whether the bouncer should be full screen. */
    private fun needsFullscreenBouncer(): Boolean {
        val mode: KeyguardSecurityModel.SecurityMode =
+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */
package com.android.systemui.keyguard.shared.model

/** Alpha values for scrim updates */
data class ScrimAlpha(
    val frontAlpha: Float = 0f,
    val behindAlpha: Float = 0f,
    val notificationsAlpha: Float = 0f,
)
Loading