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

Commit 46728f64 authored by Josh Tsuji's avatar Josh Tsuji Committed by Android (Google) Code Review
Browse files

Merge "Adds Launcher in-window animations, and reworks how the unlock flow works."

parents a42f658a 231c9229
Loading
Loading
Loading
Loading
+43 −12
Original line number Diff line number Diff line
@@ -44,8 +44,9 @@ import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.RemoteTransitionCompat;
import com.android.systemui.shared.system.smartspace.ISmartspaceCallback;
import com.android.systemui.shared.system.smartspace.ISmartspaceTransitionController;
import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceState;
import com.android.wm.shell.onehanded.IOneHanded;
import com.android.wm.shell.pip.IPip;
import com.android.wm.shell.pip.IPipAnimationListener;
@@ -73,7 +74,7 @@ public class SystemUiProxy implements ISystemUiProxy,

    private ISystemUiProxy mSystemUiProxy;
    private IPip mPip;
    private ISmartspaceTransitionController mSmartspaceTransitionController;
    private ISysuiUnlockAnimationController mSysuiUnlockAnimationController;
    private ISplitScreen mSplitScreen;
    private IOneHanded mOneHanded;
    private IShellTransitions mShellTransitions;
@@ -90,7 +91,7 @@ public class SystemUiProxy implements ISystemUiProxy,
    private IPipAnimationListener mPipAnimationListener;
    private ISplitScreenListener mSplitScreenListener;
    private IStartingWindowListener mStartingWindowListener;
    private ISmartspaceCallback mSmartspaceCallback;
    private ILauncherUnlockAnimationController mPendingLauncherUnlockAnimationController;
    private IRecentTasksListener mRecentTasksListener;
    private final ArrayList<RemoteTransitionCompat> mRemoteTransitions = new ArrayList<>();

@@ -157,7 +158,8 @@ public class SystemUiProxy implements ISystemUiProxy,
    public void setProxy(ISystemUiProxy proxy, IPip pip, ISplitScreen splitScreen,
            IOneHanded oneHanded, IShellTransitions shellTransitions,
            IStartingWindow startingWindow, IRecentTasks recentTasks,
            ISmartspaceTransitionController smartSpaceTransitionController) {
            ISysuiUnlockAnimationController sysuiUnlockAnimationController) {

        unlinkToDeath();
        mSystemUiProxy = proxy;
        mPip = pip;
@@ -165,7 +167,7 @@ public class SystemUiProxy implements ISystemUiProxy,
        mOneHanded = oneHanded;
        mShellTransitions = shellTransitions;
        mStartingWindow = startingWindow;
        mSmartspaceTransitionController = smartSpaceTransitionController;
        mSysuiUnlockAnimationController = sysuiUnlockAnimationController;
        mRecentTasks = recentTasks;
        linkToDeath();
        // re-attach the listeners once missing due to setProxy has not been initialized yet.
@@ -178,8 +180,10 @@ public class SystemUiProxy implements ISystemUiProxy,
        if (mStartingWindowListener != null && mStartingWindow != null) {
            setStartingWindowListener(mStartingWindowListener);
        }
        if (mSmartspaceCallback != null && mSmartspaceTransitionController != null) {
            setSmartspaceCallback(mSmartspaceCallback);
        if (mPendingLauncherUnlockAnimationController != null
                && mSysuiUnlockAnimationController != null) {
            setLauncherUnlockAnimationController(mPendingLauncherUnlockAnimationController);
            mPendingLauncherUnlockAnimationController = null;
        }
        for (int i = mRemoteTransitions.size() - 1; i >= 0; --i) {
            registerRemoteTransition(mRemoteTransitions.get(i));
@@ -731,15 +735,42 @@ public class SystemUiProxy implements ISystemUiProxy,
    // SmartSpace transitions
    //

    public void setSmartspaceCallback(ISmartspaceCallback callback) {
        if (mSmartspaceTransitionController != null) {
    /**
     * Sets the instance of {@link ILauncherUnlockAnimationController} that System UI should use to
     * control the launcher side of the unlock animation. This will also cause us to dispatch the
     * current state of the smartspace to System UI (this will subsequently happen if the state
     * changes).
     */
    public void setLauncherUnlockAnimationController(
            ILauncherUnlockAnimationController controller) {
        if (mSysuiUnlockAnimationController != null) {
            try {
                mSmartspaceTransitionController.setSmartspace(callback);
                mSysuiUnlockAnimationController.setLauncherUnlockController(controller);

                if (controller != null) {
                    controller.dispatchSmartspaceStateToSysui();
                }
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call setStartingWindowListener", e);
            }
        } else {
            mPendingLauncherUnlockAnimationController = controller;
        }
    }

    /**
     * Tells System UI that the Launcher's smartspace state has been updated, so that it can prepare
     * the unlock animation accordingly.
     */
    public void notifySysuiSmartspaceStateUpdated(SmartspaceState state) {
        if (mSysuiUnlockAnimationController != null) {
            try {
                mSysuiUnlockAnimationController.onLauncherSmartspaceStateUpdated(state);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call notifySysuiSmartspaceStateUpdated", e);
                e.printStackTrace();
            }
        }
        mSmartspaceCallback = callback;
    }

    //
+6 −6
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHE
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_SHELL_TRANSITIONS;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_SPLIT_SCREEN;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SHELL_STARTING_WINDOW;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SMARTSPACE_TRANSITION_CONTROLLER;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SYSUI_PROXY;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_UNLOCK_ANIMATION_CONTROLLER;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TRACING_ENABLED;

@@ -105,7 +105,7 @@ import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.InputMonitorCompat;
import com.android.systemui.shared.system.smartspace.ISmartspaceTransitionController;
import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController;
import com.android.systemui.shared.tracing.ProtoTraceable;
import com.android.wm.shell.onehanded.IOneHanded;
import com.android.wm.shell.pip.IPip;
@@ -162,15 +162,15 @@ public class TouchInteractionService extends Service
                    bundle.getBinder(KEY_EXTRA_SHELL_SHELL_TRANSITIONS));
            IStartingWindow startingWindow = IStartingWindow.Stub.asInterface(
                    bundle.getBinder(KEY_EXTRA_SHELL_STARTING_WINDOW));
            ISmartspaceTransitionController smartspaceTransitionController =
                    ISmartspaceTransitionController.Stub.asInterface(
                            bundle.getBinder(KEY_EXTRA_SMARTSPACE_TRANSITION_CONTROLLER));
            ISysuiUnlockAnimationController launcherUnlockAnimationController =
                    ISysuiUnlockAnimationController.Stub.asInterface(
                            bundle.getBinder(KEY_EXTRA_UNLOCK_ANIMATION_CONTROLLER));
            IRecentTasks recentTasks = IRecentTasks.Stub.asInterface(
                    bundle.getBinder(KEY_EXTRA_RECENT_TASKS));
            MAIN_EXECUTOR.execute(() -> {
                SystemUiProxy.INSTANCE.get(TouchInteractionService.this).setProxy(proxy, pip,
                        splitscreen, onehanded, shellTransitions, startingWindow, recentTasks,
                        smartspaceTransitionController);
                        launcherUnlockAnimationController);
                TouchInteractionService.this.initInputMonitor();
                preloadOverview(true /* fromInit */);
            });
+82 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.quickstep.util;

import com.android.launcher3.Launcher;
import com.android.launcher3.Utilities;

/**
 * Animation to animate in a workspace during the unlock transition.
 */
public class WorkspaceUnlockAnim {
    /** Scale for the workspace icons at the beginning of the animation. */
    private static final float START_SCALE = 0.9f;

    /**
     * Starting translation Y values for the animation. We use a larger value if we're animating in
     * from a swipe, since there is more perceived upward movement when we unlock from a swipe.
     */
    private static final int START_TRANSLATION_DP = 15;
    private static final int START_TRANSLATION_SWIPE_DP = 60;

    private Launcher mLauncher;
    private float mUnlockAmount = 0f;

    public WorkspaceUnlockAnim(Launcher launcher) {
        mLauncher = launcher;
    }

    /**
     * Called when we're about to make the Launcher window visible and play the unlock animation.
     *
     * This is a blocking call so that System UI knows it's safe to show the Launcher window without
     * causing the Launcher contents to flicker on screen. Do not do anything expensive here.
     */
    public void prepareForUnlock() {
        mLauncher.getWorkspace().setAlpha(0f);
        mLauncher.getHotseat().setAlpha(0f);

        mUnlockAmount = 0f;
    }

    public void setUnlockAmount(float amount, boolean fromSwipe) {
        mUnlockAmount = amount;

        final float amountInverse = 1f - amount;
        final float scale = START_SCALE + (1f - START_SCALE) * amount;

        mLauncher.getWorkspace().setScaleX(scale);
        mLauncher.getWorkspace().setScaleY(scale);
        mLauncher.getWorkspace().setAlpha(amount);
        mLauncher.getWorkspace().setPivotToScaleWithSelf(mLauncher.getHotseat());

        mLauncher.getHotseat().setScaleX(scale);
        mLauncher.getHotseat().setScaleY(scale);
        mLauncher.getHotseat().setAlpha(amount);

        if (fromSwipe) {
            mLauncher.getWorkspace().setTranslationY(
                    Utilities.dpToPx(START_TRANSLATION_SWIPE_DP) * amountInverse);
            mLauncher.getHotseat().setTranslationY(
                    Utilities.dpToPx(START_TRANSLATION_SWIPE_DP) * amountInverse);
        } else {
            mLauncher.getWorkspace().setTranslationY(
                    Utilities.dpToPx(START_TRANSLATION_DP) * amountInverse);
            mLauncher.getHotseat().setTranslationY(
                    Utilities.dpToPx(START_TRANSLATION_DP) * amountInverse);
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -2789,6 +2789,17 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        getDragLayer().announceForAccessibility(getString(stringResId));
    }

    /**
     * Informs us that the overlay (-1 screen, typically), has either become visible or invisible.
     */
    public void onOverlayVisibilityChanged(boolean visible) {}

    /**
     * Informs us that the page transition has ended, so that we can react to the newly selected
     * page if we want to.
     */
    public void onPageEndTransition() {}

    /**
     * Add the icons for all apps.
     *
+12 −0
Original line number Diff line number Diff line
@@ -1135,6 +1135,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
            stripEmptyScreens();
            mStripScreensOnPageStopMoving = false;
        }

        // Inform the Launcher activity that the page transition ended so that it can react to the
        // newly visible page if it wants to.
        mLauncher.onPageEndTransition();
    }

    public void setLauncherOverlay(LauncherOverlay overlay) {
@@ -1211,6 +1215,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
                        .log(LAUNCHER_SWIPELEFT);
            }
            mOverlayShown = true;

            // Let the Launcher activity know that the overlay is now visible.
            mLauncher.onOverlayVisibilityChanged(mOverlayShown);

            // Not announcing the overlay page for accessibility since it announces itself.
        } else if (Float.compare(scroll, 0f) == 0) {
            if (mOverlayShown) {
@@ -1234,6 +1242,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
                announcePageForAccessibility();
            }
            mOverlayShown = false;

            // Let the Launcher activity know that the overlay is no longer visible.
            mLauncher.onOverlayVisibilityChanged(mOverlayShown);

            tryRunOverlayCallback();
        }

Loading