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

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

Merge "Move shelf peeking anim code to ShelfPeekAnim class" into ub-launcher3-qt-future-dev

parents 4744701f 42a9ef0e
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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;

/** Empty class, only exists so that l3goWithQuickstepIconRecentsDebug compiles. */
public class ShelfPeekAnim {
    public ShelfPeekAnim(Launcher launcher) {
    }

    public enum ShelfAnimState {
    }
}
+7 −26
Original line number Diff line number Diff line
@@ -54,14 +54,16 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListenerEx;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.QuickstepAppTransitionManagerImpl;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.util.ShelfPeekAnim;
import com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState;
import com.android.quickstep.util.StaggeredWorkspaceAnim;
import com.android.quickstep.views.LauncherRecentsView;
import com.android.quickstep.views.RecentsView;
@@ -201,7 +203,9 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
        activity.getAppsView().reset(false /* animate */);

        return new AnimationFactory() {
            private ShelfAnimState mShelfState;
            private final ShelfPeekAnim mShelfAnim =
                    ((QuickstepAppTransitionManagerImpl) activity.getAppTransitionManager())
                            .getShelfPeekAnim();
            private boolean mIsAttachedToWindow;

            @Override
@@ -230,30 +234,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
            @Override
            public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator,
                    long duration) {
                if (mShelfState == shelfState) {
                    return;
                }
                mShelfState = shelfState;
                activity.getStateManager().cancelStateElementAnimation(INDEX_SHELF_ANIM);
                if (mShelfState == ShelfAnimState.CANCEL) {
                    return;
                }
                float shelfHiddenProgress = BACKGROUND_APP.getVerticalProgress(activity);
                float shelfOverviewProgress = OVERVIEW.getVerticalProgress(activity);
                // Peek based on default overview progress so we can see hotseat if we're showing
                // that instead of predictions in overview.
                float defaultOverviewProgress = OverviewState.getDefaultVerticalProgress(activity);
                float shelfPeekingProgress = shelfHiddenProgress
                        - (shelfHiddenProgress - defaultOverviewProgress) * 0.25f;
                float toProgress = mShelfState == ShelfAnimState.HIDE
                        ? shelfHiddenProgress
                        : mShelfState == ShelfAnimState.PEEK
                                ? shelfPeekingProgress
                                : shelfOverviewProgress;
                Animator shelfAnim = activity.getStateManager()
                        .createStateElementAnimation(INDEX_SHELF_ANIM, toProgress);
                shelfAnim.setInterpolator(interpolator);
                shelfAnim.setDuration(duration).start();
                mShelfAnim.setShelfState(shelfState, interpolator, duration);
            }

            @Override
+5 −5
Original line number Diff line number Diff line
@@ -26,14 +26,14 @@ import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs;
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
import static com.android.launcher3.util.RaceConditionTracker.EXIT;
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.HIDE;
import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.PEEK;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG;
import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.HOME;
import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.LAST_TASK;
import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.NEW_TASK;
import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.RECENTS;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.HIDE;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.PEEK;
import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;

@@ -74,13 +74,14 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.RaceConditionTracker;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.ActivityControlHelper.AnimationFactory;
import com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState;
import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.inputconsumers.InputConsumer;
import com.android.quickstep.inputconsumers.OverviewInputConsumer;
import com.android.quickstep.util.ClipAnimationHelper.TargetAlphaProvider;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.util.ShelfPeekAnim;
import com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState;
import com.android.quickstep.util.SwipeAnimationTargetSet;
import com.android.quickstep.views.LiveTileOverlay;
import com.android.quickstep.views.RecentsView;
@@ -192,7 +193,6 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
            Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
    private static final String SCREENSHOT_CAPTURED_EVT = "ScreenshotCaptured";

    private static final long SHELF_ANIM_DURATION = 240;
    public static final long RECENTS_ATTACH_DURATION = 300;

    /**
@@ -442,7 +442,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    @Override
    public void onMotionPauseChanged(boolean isPaused) {
        setShelfState(isPaused ? PEEK : HIDE, OVERSHOOT_1_2, SHELF_ANIM_DURATION);
        setShelfState(isPaused ? PEEK : HIDE, ShelfPeekAnim.INTERPOLATOR, ShelfPeekAnim.DURATION);
    }

    public void maybeUpdateRecentsAttachedState() {
+104 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 static com.android.launcher3.LauncherAppTransitionManagerImpl.INDEX_SHELF_ANIM;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.animation.Interpolator;

import com.android.launcher3.Launcher;
import com.android.launcher3.uioverrides.states.OverviewState;

/**
 * Animates the shelf between states HIDE, PEEK, and OVERVIEW.
 */
public class ShelfPeekAnim {

    public static final Interpolator INTERPOLATOR = OVERSHOOT_1_2;
    public static final long DURATION = 240;

    private final Launcher mLauncher;

    private ShelfAnimState mShelfState;
    private boolean mIsPeeking;

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

    /**
     * Animates to the given state, canceling the previous animation if it was still running.
     */
    public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator, long duration) {
        if (mShelfState == shelfState) {
            return;
        }
        mLauncher.getStateManager().cancelStateElementAnimation(INDEX_SHELF_ANIM);
        mShelfState = shelfState;
        mIsPeeking = mShelfState == ShelfAnimState.PEEK || mShelfState == ShelfAnimState.HIDE;
        if (mShelfState == ShelfAnimState.CANCEL) {
            return;
        }
        float shelfHiddenProgress = BACKGROUND_APP.getVerticalProgress(mLauncher);
        float shelfOverviewProgress = OVERVIEW.getVerticalProgress(mLauncher);
        // Peek based on default overview progress so we can see hotseat if we're showing
        // that instead of predictions in overview.
        float defaultOverviewProgress = OverviewState.getDefaultVerticalProgress(mLauncher);
        float shelfPeekingProgress = shelfHiddenProgress
                - (shelfHiddenProgress - defaultOverviewProgress) * 0.25f;
        float toProgress = mShelfState == ShelfAnimState.HIDE
                ? shelfHiddenProgress
                : mShelfState == ShelfAnimState.PEEK
                        ? shelfPeekingProgress
                        : shelfOverviewProgress;
        Animator shelfAnim = mLauncher.getStateManager()
                .createStateElementAnimation(INDEX_SHELF_ANIM, toProgress);
        shelfAnim.setInterpolator(interpolator);
        shelfAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                mShelfState = ShelfAnimState.CANCEL;
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                mIsPeeking = mShelfState == ShelfAnimState.PEEK;
            }
        });
        shelfAnim.setDuration(duration).start();
    }

    /** @return Whether the shelf is currently peeking or animating to or from peeking. */
    public boolean isPeeking() {
        return mIsPeeking;
    }

    /** The various shelf states we can animate to. */
    public enum ShelfAnimState {
        HIDE(true), PEEK(true), OVERVIEW(false), CANCEL(false);

        ShelfAnimState(boolean shouldPreformHaptic) {
            this.shouldPreformHaptic = shouldPreformHaptic;
        }

        public final boolean shouldPreformHaptic;
    }
}
+12 −3
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@ import android.os.Looper;
import android.util.Pair;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.Interpolators;
@@ -69,6 +72,7 @@ import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.util.ShelfPeekAnim;
import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.QuickStepContract;
@@ -80,9 +84,6 @@ import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
import com.android.systemui.shared.system.WindowManagerWrapper;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * {@link LauncherAppTransitionManager} with Quickstep-specific app transitions for launching from
 * home and/or all-apps.
@@ -150,6 +151,8 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans

    private RemoteAnimationProvider mRemoteAnimationProvider;

    private final ShelfPeekAnim mShelfPeekAnim;

    private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
@@ -177,6 +180,12 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans

        mLauncher.addOnDeviceProfileChangeListener(this);
        registerRemoteAnimations();

        mShelfPeekAnim = new ShelfPeekAnim(mLauncher);
    }

    public ShelfPeekAnim getShelfPeekAnim() {
        return mShelfPeekAnim;
    }

    @Override
Loading