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

Commit c00e49dd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fade out UFPS icon when launching an app over it (1/2)"

parents 51959856 83dbe119
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,5 +39,5 @@ android_library {
    ],

    manifest: "AndroidManifest.xml",

    kotlincflags: ["-Xjvm-default=enable"],
}
+33 −5
Original line number Diff line number Diff line
@@ -95,6 +95,9 @@ class ActivityLaunchAnimator(
     */
    var callback: Callback? = null

    /** The set of [Listener] that should be notified of any animation started by this animator. */
    private val listeners = LinkedHashSet<Listener>()

    /**
     * Start an intent and animate the opening window. The intent will be started by running
     * [intentStarter], which should use the provided [RemoteAnimationAdapter] and return the launch
@@ -214,6 +217,16 @@ class ActivityLaunchAnimator(
        }
    }

    /** Add a [Listener] that can listen to launch animations. */
    fun addListener(listener: Listener) {
        listeners.add(listener)
    }

    /** Remove a [Listener]. */
    fun removeListener(listener: Listener) {
        listeners.remove(listener)
    }

    /** Create a new animation [Runner] controlled by [controller]. */
    @VisibleForTesting
    fun createRunner(controller: Controller): Runner = Runner(controller)
@@ -234,13 +247,27 @@ class ActivityLaunchAnimator(
        /** Hide the keyguard and animate using [runner]. */
        fun hideKeyguardWithAnimation(runner: IRemoteAnimationRunner)

        /** Enable/disable window blur so they don't overlap with the window launch animation **/
        fun setBlursDisabledForAppLaunch(disabled: Boolean)

        /* Get the background color of [task]. */
        fun getBackgroundColor(task: TaskInfo): Int
    }

    interface Listener {
        /** Called when an activity launch animation started. */
        @JvmDefault
        fun onLaunchAnimationStart() {}

        /**
         * Called when an activity launch animation is finished. This will be called if and only if
         * [onLaunchAnimationStart] was called earlier.
         */
        @JvmDefault
        fun onLaunchAnimationEnd() {}

        /** Called when an activity launch animation made progress. */
        @JvmDefault
        fun onLaunchAnimationProgress(linearProgress: Float) {}
    }

    /**
     * A controller that takes care of applying the animation to an expanding view.
     *
@@ -396,12 +423,12 @@ class ActivityLaunchAnimator(
            val delegate = this.controller
            val controller = object : LaunchAnimator.Controller by delegate {
                override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) {
                    callback.setBlursDisabledForAppLaunch(true)
                    listeners.forEach { it.onLaunchAnimationStart() }
                    delegate.onLaunchAnimationStart(isExpandingFullyAbove)
                }

                override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) {
                    callback.setBlursDisabledForAppLaunch(false)
                    listeners.forEach { it.onLaunchAnimationEnd() }
                    iCallback?.invoke()
                    delegate.onLaunchAnimationEnd(isExpandingFullyAbove)
                }
@@ -413,6 +440,7 @@ class ActivityLaunchAnimator(
                ) {
                    applyStateToWindow(window, state)
                    navigationBar?.let { applyStateToNavigationBar(it, state, linearProgress) }
                    listeners.forEach { it.onLaunchAnimationProgress(linearProgress) }
                    delegate.onLaunchAnimationProgress(state, progress, linearProgress)
                }
            }
+7 −2
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.view.accessibility.AccessibilityManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.LatencyTracker;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
@@ -130,6 +131,7 @@ public class UdfpsController implements DozeReceiver {
    // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
    // sensors, this, in addition to a lot of the code here, will be updated.
    @VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps;
    @NonNull private final ActivityLaunchAnimator mActivityLaunchAnimator;

    // Tracks the velocity of a touch to help filter out the touches that move too fast.
    @Nullable private VelocityTracker mVelocityTracker;
@@ -198,7 +200,8 @@ public class UdfpsController implements DozeReceiver {
                            mLockscreenShadeTransitionController, mConfigurationController,
                            mSystemClock, mKeyguardStateController,
                            mUnlockedScreenOffAnimationController, mSensorProps, mHbmProvider,
                            reason, callback, UdfpsController.this::onTouch)));
                            reason, callback, UdfpsController.this::onTouch,
                            mActivityLaunchAnimator)));
        }

        @Override
@@ -487,7 +490,8 @@ public class UdfpsController implements DozeReceiver {
            @NonNull SystemClock systemClock,
            @NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            @NonNull SystemUIDialogManager dialogManager,
            @NonNull LatencyTracker latencyTracker) {
            @NonNull LatencyTracker latencyTracker,
            @NonNull ActivityLaunchAnimator activityLaunchAnimator) {
        mContext = context;
        mExecution = execution;
        mVibrator = vibrator;
@@ -516,6 +520,7 @@ public class UdfpsController implements DozeReceiver {
        mSystemClock = systemClock;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mLatencyTracker = latencyTracker;
        mActivityLaunchAnimator = activityLaunchAnimator;

        mSensorProps = findFirstUdfps();
        // At least one UDFPS sensor exists
+5 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.view.accessibility.AccessibilityManager.TouchExplorationStateChan
import androidx.annotation.LayoutRes
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.R
import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.dump.DumpManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.LockscreenShadeTransitionController
@@ -81,7 +82,8 @@ class UdfpsControllerOverlay(
    private var hbmProvider: UdfpsHbmProvider,
    @ShowReason val requestReason: Int,
    private val controllerCallback: IUdfpsOverlayControllerCallback,
    private val onTouch: (View, MotionEvent, Boolean) -> Boolean
    private val onTouch: (View, MotionEvent, Boolean) -> Boolean,
    private val activityLaunchAnimator: ActivityLaunchAnimator
) {
    /** The view, when [isShowing], or null. */
    var overlayView: UdfpsView? = null
@@ -200,7 +202,8 @@ class UdfpsControllerOverlay(
                    keyguardStateController,
                    unlockedScreenOffAnimationController,
                    dialogManager,
                    controller
                    controller,
                    activityLaunchAnimator
                )
            }
            BiometricOverlayConstants.REASON_AUTH_BP -> {
+37 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.MotionEvent;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
@@ -55,6 +56,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
    @NonNull private final UdfpsController mUdfpsController;
    @NonNull private final UnlockedScreenOffAnimationController
            mUnlockedScreenOffAnimationController;
    @NonNull private final ActivityLaunchAnimator mActivityLaunchAnimator;

    private boolean mShowingUdfpsBouncer;
    private boolean mUdfpsRequested;
@@ -66,6 +68,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
    private long mLastUdfpsBouncerShowTime = -1;
    private float mStatusBarExpansion;
    private boolean mLaunchTransitionFadingAway;
    private boolean mIsLaunchingActivity;
    private float mActivityLaunchProgress;

    /**
     * hidden amount of pin/pattern/password bouncer
@@ -88,7 +92,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
            @NonNull KeyguardStateController keyguardStateController,
            @NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
            @NonNull SystemUIDialogManager systemUIDialogManager,
            @NonNull UdfpsController udfpsController) {
            @NonNull UdfpsController udfpsController,
            @NonNull ActivityLaunchAnimator activityLaunchAnimator) {
        super(view, statusBarStateController, panelExpansionStateManager, systemUIDialogManager,
                dumpManager);
        mKeyguardViewManager = statusBarKeyguardViewManager;
@@ -99,6 +104,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
        mKeyguardStateController = keyguardStateController;
        mUdfpsController = udfpsController;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mActivityLaunchAnimator = activityLaunchAnimator;
    }

    @Override
@@ -136,6 +142,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
        mKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
        mLockScreenShadeTransitionController.setUdfpsKeyguardViewController(this);
        mUnlockedScreenOffAnimationController.addCallback(mUnlockedScreenOffCallback);
        mActivityLaunchAnimator.addListener(mActivityLaunchAnimatorListener);
    }

    @Override
@@ -153,6 +160,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
            mLockScreenShadeTransitionController.setUdfpsKeyguardViewController(null);
        }
        mUnlockedScreenOffAnimationController.removeCallback(mUnlockedScreenOffCallback);
        mActivityLaunchAnimator.removeListener(mActivityLaunchAnimatorListener);
    }

    @Override
@@ -294,6 +302,12 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
                    0f, 255f);
        if (!mShowingUdfpsBouncer) {
            alpha *= (1.0f - mTransitionToFullShadeProgress);

            // Fade out the icon if we are animating an activity launch over the lockscreen and the
            // activity didn't request the UDFPS.
            if (mIsLaunchingActivity && !mUdfpsRequested) {
                alpha *= (1.0f - mActivityLaunchProgress);
            }
        }
        mView.setUnpausedAlpha(alpha);
    }
@@ -426,4 +440,26 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud

    private final UnlockedScreenOffAnimationController.Callback mUnlockedScreenOffCallback =
            (linear, eased) -> mStateListener.onDozeAmountChanged(linear, eased);

    private final ActivityLaunchAnimator.Listener mActivityLaunchAnimatorListener =
            new ActivityLaunchAnimator.Listener() {
                @Override
                public void onLaunchAnimationStart() {
                    mIsLaunchingActivity = true;
                    mActivityLaunchProgress = 0f;
                    updateAlpha();
                }

                @Override
                public void onLaunchAnimationEnd() {
                    mIsLaunchingActivity = false;
                    updateAlpha();
                }

                @Override
                public void onLaunchAnimationProgress(float linearProgress) {
                    mActivityLaunchProgress = linearProgress;
                    updateAlpha();
                }
            };
}
Loading