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

Commit b7a781b5 authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

Merge "Update animations for TM-QPR: OverviewSplitSelect > Home transition" into tm-qpr-dev

parents fe5bccbf e5ba8fa7
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -23,16 +23,22 @@ import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_MODAL;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
import static com.android.launcher3.testing.shared.TestProtocol.BAD_STATE;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
import static com.android.quickstep.views.RecentsView.FIRST_FLOATING_TASK_TRANSLATE_OFFSCREEN;
import static com.android.quickstep.views.RecentsView.OVERVIEW_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS;
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.SPLIT_INSTRUCTIONS_FADE;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;

import android.graphics.Rect;
import android.graphics.RectF;
import android.util.FloatProperty;
import android.util.Log;

@@ -40,9 +46,12 @@ import androidx.annotation.NonNull;

import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.quickstep.views.FloatingTaskView;
import com.android.quickstep.views.RecentsView;

/**
@@ -106,6 +115,49 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
        setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f,
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));

        if (mRecentsView.isSplitSelectionActive()) {
            // TODO (b/238651489): Refactor state management to avoid need for double check
            FloatingTaskView floatingTask = mRecentsView.getFirstFloatingTaskView();
            if (floatingTask != null) {
                DragLayer dragLayer = mLauncher.getDragLayer();
                RectF onScreenRectF = new RectF();
                Utilities.getBoundsForViewInDragLayer(mLauncher.getDragLayer(), floatingTask,
                        new Rect(0, 0, floatingTask.getWidth(), floatingTask.getHeight()),
                        false, null, onScreenRectF);
                // Get the part of the floatingTask that intersects with the DragLayer (i.e. the
                // on-screen portion)
                onScreenRectF.intersect(
                        dragLayer.getLeft(),
                        dragLayer.getTop(),
                        dragLayer.getRight(),
                        dragLayer.getBottom()
                );

                setter.setFloat(
                        mRecentsView,
                        FIRST_FLOATING_TASK_TRANSLATE_OFFSCREEN,
                        mRecentsView.getPagedOrientationHandler()
                                .getFloatingTaskOffscreenTranslationTarget(
                                        floatingTask,
                                        onScreenRectF,
                                        floatingTask.getStagePosition(),
                                        mLauncher.getDeviceProfile()
                                ),
                        config.getInterpolator(
                                ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN,
                                LINEAR
                        ));
                setter.setFloat(
                        mRecentsView,
                        SPLIT_INSTRUCTIONS_FADE,
                        1,
                        config.getInterpolator(
                                ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE,
                                LINEAR
                        ));
            }
        }

        float recentsAlpha = toState.overviewUi ? 1 : 0;
        Log.d(BAD_STATE, "BaseRecentsViewStateController setStateWithAnimationInternal toState="
                + toState + ", alpha=" + recentsAlpha);
+13 −2
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ import com.android.quickstep.views.TaskView;
 */
public class OverviewState extends LauncherState {

    private static final int OVERVIEW_SLIDE_IN_DURATION = 380;
    private static final int OVERVIEW_POP_IN_DURATION = 250;
    private static final int OVERVIEW_EXIT_DURATION = 250;

    protected static final Rect sTempRect = new Rect();

    private static final int STATE_FLAGS = FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED
@@ -57,8 +61,15 @@ public class OverviewState extends LauncherState {

    @Override
    public int getTransitionDuration(Context context, boolean isToState) {
        if (isToState) {
            // In gesture modes, overview comes in all the way from the side, so give it more time.
        return DisplayController.getNavigationMode(context).hasGestures ? 380 : 250;
            return DisplayController.getNavigationMode(context).hasGestures
                    ? OVERVIEW_SLIDE_IN_DURATION
                    : OVERVIEW_POP_IN_DURATION;
        } else {
            // When exiting Overview, exit quickly.
            return OVERVIEW_EXIT_DURATION;
        }
    }

    @Override
+15 −5
Original line number Diff line number Diff line
@@ -22,13 +22,15 @@ import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.HINT_STATE_TWO_BUTTON;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT;
import static com.android.launcher3.WorkspaceStateTransitionAnimation.getWorkspaceSpringScaleAnimator;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED_ACCELERATE;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED_DECELERATE;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -39,6 +41,8 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_ACTIONS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE;
@@ -87,9 +91,16 @@ public class QuickstepAtomicAnimationFactory extends
    public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState,
            StateAnimationConfig config) {
        RecentsView overview = mActivity.getOverviewPanel();
        if (toState == NORMAL && fromState == OVERVIEW) {
        if ((fromState == OVERVIEW || fromState == OVERVIEW_SPLIT_SELECT) && toState == NORMAL) {
            if (fromState == OVERVIEW_SPLIT_SELECT) {
                config.setInterpolator(ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN,
                        clampToProgress(EMPHASIZED_ACCELERATE, 0, 0.4f));
                config.setInterpolator(ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE,
                        clampToProgress(LINEAR, 0, 0.33f));
            }

            config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR, 0, 0.25f));
            config.setInterpolator(ANIM_SCRIM_FADE, LINEAR);
            config.setInterpolator(ANIM_SCRIM_FADE, clampToProgress(LINEAR, 0.33f, 1));
            config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
            config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);

@@ -98,8 +109,7 @@ public class QuickstepAtomicAnimationFactory extends
                // Overview is going offscreen, so keep it at its current scale and opacity.
                config.setInterpolator(ANIM_OVERVIEW_SCALE, FINAL_FRAME);
                config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
                config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X,
                        clampToProgress(FAST_OUT_SLOW_IN, 0, 0.75f));
                config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, EMPHASIZED_DECELERATE);
                config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, FINAL_FRAME);
            } else {
                config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
+4 −0
Original line number Diff line number Diff line
@@ -260,6 +260,10 @@ public class FloatingTaskView extends FrameLayout {
                mActivity.getDeviceProfile(), mStagePosition);
    }

    public int getStagePosition() {
        return mStagePosition;
    }

    private static class SplitOverlayProperties {

        private final float finalTaskViewScaleX;
+38 −0
Original line number Diff line number Diff line
@@ -397,6 +397,39 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                }
            };

    public static final FloatProperty<RecentsView> FIRST_FLOATING_TASK_TRANSLATE_OFFSCREEN =
            new FloatProperty<RecentsView>("firstFloatingTaskTranslateOffscreen") {
                @Override
                public void setValue(RecentsView view, float translation) {
                    view.getPagedOrientationHandler().setFloatingTaskPrimaryTranslation(
                            view.mFirstFloatingTaskView,
                            translation,
                            view.mActivity.getDeviceProfile()
                    );
                }

                @Override
                public Float get(RecentsView view) {
                    return view.getPagedOrientationHandler().getFloatingTaskPrimaryTranslation(
                            view.mFirstFloatingTaskView,
                            view.mActivity.getDeviceProfile()
                    );
                }
            };

    public static final FloatProperty<RecentsView> SPLIT_INSTRUCTIONS_FADE =
            new FloatProperty<RecentsView>("splitInstructionsFade") {
                @Override
                public void setValue(RecentsView view, float fade) {
                    view.mSplitInstructionsView.setAlpha(1 - fade);
                }

                @Override
                public Float get(RecentsView view) {
                    return 1 - view.mSplitInstructionsView.getAlpha();
                }
            };

    // OverScroll constants
    private static final int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;

@@ -5291,6 +5324,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        return mRecentsAnimationController;
    }

    @Nullable
    public FloatingTaskView getFirstFloatingTaskView() {
        return mFirstFloatingTaskView;
    }

    /** Update the current activity locus id to show the enabled state of Overview */
    public void updateLocusId() {
        String locusId = "Overview";
Loading