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

Commit 3dafeb2d authored by Schneider Victor-tulias's avatar Schneider Victor-tulias Committed by Android (Google) Code Review
Browse files

Merge "Update KQS overview launch animation" into main

parents 8b9ca27c 1ca66992
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.pm.ActivityInfo;

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

import com.android.launcher3.R;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
@@ -47,7 +48,8 @@ import java.util.stream.Collectors;
public final class KeyboardQuickSwitchController implements
        TaskbarControllers.LoggableTaskbarController {

    static final int MAX_TASKS = 6;
    @VisibleForTesting
    public static final int MAX_TASKS = 6;

    @NonNull private final ControllerCallbacks mControllerCallbacks = new ControllerCallbacks();

+69 −6
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import static android.view.Surface.ROTATION_90;
import static android.widget.Toast.LENGTH_SHORT;

import static com.android.app.animation.Interpolators.ACCELERATE_DECELERATE;
import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.app.animation.Interpolators.DECELERATE;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.app.animation.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.BaseActivity.EVENT_DESTROYED;
import static com.android.launcher3.BaseActivity.EVENT_STARTED;
@@ -134,6 +136,7 @@ import com.android.quickstep.util.SurfaceTransaction;
import com.android.quickstep.util.SurfaceTransactionApplier;
import com.android.quickstep.util.SwipePipToHomeAnimator;
import com.android.quickstep.util.TaskViewSimulator;
import com.android.quickstep.util.TransformParams;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer;
@@ -167,6 +170,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,

    private static final ArrayList<String> STATE_NAMES = new ArrayList<>();

    // Fraction of the scroll and transform animation in which the current task fades out
    private static final float KQS_TASK_FADE_ANIMATION_FRACTION = 0.4f;

    protected final BaseActivityInterface<S, T> mActivityInterface;
    protected final InputConsumerProxy mInputConsumerProxy;
    protected final ActivityInitListener mActivityInitListener;
@@ -900,7 +906,10 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            return;
        }
        mLauncherTransitionController.setProgress(
                Math.max(mCurrentShift.value, getScaleProgressDueToScroll()), mDragLengthFactor);
                // Immediately finish the grid transition
                isKeyboardTaskFocusPending()
                        ? 1f : Math.max(mCurrentShift.value, getScaleProgressDueToScroll()),
                mDragLengthFactor);
    }

    /**
@@ -1349,7 +1358,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        }
        Interpolator interpolator;
        S state = mActivityInterface.stateFromGestureEndTarget(endTarget);
        if (state.displayOverviewTasksAsGrid(mDp)) {
        if (isKeyboardTaskFocusPending()) {
            interpolator = EMPHASIZED;
        } else if (state.displayOverviewTasksAsGrid(mDp)) {
            interpolator = ACCELERATE_DECELERATE;
        } else if (endTarget == RECENTS) {
            interpolator = OVERSHOOT_1_2;
@@ -1653,7 +1664,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            animatorSet.play(windowAnim);
            if (mRecentsView != null) {
                mRecentsView.onPrepareGestureEndAnimation(
                        animatorSet, mGestureState.getEndTarget(),
                        mGestureState.isHandlingAtomicEvent() ? null : animatorSet,
                        mGestureState.getEndTarget(),
                        getRemoteTaskViewSimulators());
            }
            animatorSet.setDuration(duration).setInterpolator(interpolator);
@@ -2225,6 +2237,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        }
    }

    private boolean shouldLinkRecentsViewScroll() {
        return mRecentsViewScrollLinked && !isKeyboardTaskFocusPending();
    }

    private boolean isKeyboardTaskFocusPending() {
        return mRecentsView != null && mRecentsView.isKeyboardTaskFocusPending();
    }

    private void onRecentsViewScroll() {
        if (moveWindowWithRecentsScroll()) {
            onCurrentShiftUpdated();
@@ -2457,6 +2477,44 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        mActivityInitListener.register();
    }

    private boolean shouldFadeOutTargetsForKeyboardQuickSwitch(
            TransformParams transformParams,
            TaskViewSimulator taskViewSimulator,
            float progress) {
        RemoteAnimationTargets targets = transformParams.getTargetSet();
        boolean fadeAppTargets = isKeyboardTaskFocusPending()
                && targets != null
                && targets.apps != null
                && targets.apps.length > 0;
        float fadeProgress = Utilities.mapBoundToRange(
                progress,
                /* lowerBound= */ 0f,
                /* upperBound= */ KQS_TASK_FADE_ANIMATION_FRACTION,
                /* toMin= */ 0f,
                /* toMax= */ 1f,
                LINEAR);
        if (!fadeAppTargets || Float.compare(fadeProgress, 1f) == 0) {
            return false;
        }
        SurfaceTransaction surfaceTransaction =
                transformParams.createSurfaceParams(taskViewSimulator);
        SurfaceControl.Transaction transaction = surfaceTransaction.getTransaction();

        for (RemoteAnimationTarget app : targets.apps) {
            transaction.setAlpha(app.leash, 1f - fadeProgress);
            transaction.setPosition(app.leash,
                    /* x= */ app.startBounds.left
                            + (mActivity.getDeviceProfile().overviewPageSpacing
                            * (mRecentsView.isRtl() ? fadeProgress : -fadeProgress)),
                    /* y= */ 0f);
            transaction.setScale(app.leash, 1f, 1f);
            taskViewSimulator.taskPrimaryTranslation.value =
                    mRecentsView.getScrollOffsetForKeyboardTaskFocus();
            taskViewSimulator.apply(transformParams, surfaceTransaction);
        }
        return true;
    }

    /**
     * Applies the transform on the recents animation
     */
@@ -2466,7 +2524,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        //    swipe-to-icon animation is handled by RectFSpringAnim anim
        boolean notSwipingToHome = mRecentsAnimationTargets != null
                && mGestureState.getEndTarget() != HOME;
        boolean setRecentsScroll = mRecentsViewScrollLinked && mRecentsView != null;
        boolean setRecentsScroll = shouldLinkRecentsViewScroll() && mRecentsView != null;
        float progress = Math.max(mCurrentShift.value, getScaleProgressDueToScroll());
        int scrollOffset = setRecentsScroll ? mRecentsView.getScrollOffset() : 0;
        if (!mStartMovingTasks && (progress > 0 || scrollOffset != 0)) {
@@ -2485,7 +2543,12 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
                if (setRecentsScroll) {
                    taskViewSimulator.setScroll(scrollOffset);
                }
                taskViewSimulator.apply(remoteHandle.getTransformParams());
                TransformParams transformParams = remoteHandle.getTransformParams();
                if (shouldFadeOutTargetsForKeyboardQuickSwitch(
                        transformParams, taskViewSimulator, progress)) {
                    continue;
                }
                taskViewSimulator.apply(transformParams);
            }
        }
    }
@@ -2493,7 +2556,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    // Scaling of RecentsView during quick switch based on amount of recents scroll
    private float getScaleProgressDueToScroll() {
        if (mActivity == null || !mActivity.getDeviceProfile().isTablet || mRecentsView == null
                || !mRecentsViewScrollLinked) {
                || !shouldLinkRecentsViewScroll()) {
            return 0;
        }

+2 −2
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
    public abstract <T extends RecentsView> T getVisibleRecentsView();

    @UiThread
    public abstract boolean switchToRecentsIfVisible(Runnable onCompleteCallback);
    public abstract boolean switchToRecentsIfVisible(Animator.AnimatorListener animatorListener);

    public abstract Rect getOverviewWindowBounds(
            Rect homeBounds, RemoteAnimationTarget target);
@@ -520,7 +520,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
            // Since we are changing the start position of the UI, reapply the state, at the end
            controller.setEndAction(() -> mActivity.getStateManager().goToState(
                    controller.getInterpolatedProgress() > 0.5 ? mTargetState : mBackgroundState,
                    false));
                    /* animated= */ false));

            RecentsView recentsView = mActivity.getOverviewPanel();
            AnimatorControllerWithResistance controllerWithResistance =
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ public final class FallbackActivityInterface extends
    }

    @Override
    public boolean switchToRecentsIfVisible(Runnable onCompleteCallback) {
    public boolean switchToRecentsIfVisible(Animator.AnimatorListener animatorListener) {
        return false;
    }

+2 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.FLOATING_SEARCH_BAR;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE;

@@ -212,7 +211,7 @@ public final class LauncherActivityInterface extends
    }

    @Override
    public boolean switchToRecentsIfVisible(Runnable onCompleteCallback) {
    public boolean switchToRecentsIfVisible(Animator.AnimatorListener animatorListener) {
        Launcher launcher = getVisibleLauncher();
        if (launcher == null) {
            return false;
@@ -227,7 +226,7 @@ public final class LauncherActivityInterface extends
        closeOverlay();
        launcher.getStateManager().goToState(OVERVIEW,
                launcher.getStateManager().shouldAnimateStateChange(),
                onCompleteCallback == null ? null : forEndCallback(onCompleteCallback));
                animatorListener);
        return true;
    }

Loading