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

Commit f2393f1d authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Adding TaskViewSimulator for simulating taskView layout on a remote target

1. Tanslating contents of RecentsView instead of recentsView itself. When
   translating, we keep the current TaskView from moving. This allows
   the remoteTarget to follow an individual taskView.
2. Removing translationY in recentsView and setting the pivot instead
3. Using TaskViewSimulator for swipe handler. This allows using similar
   animation creation as Launcher window animation.

Change-Id: I0b7b16c367d9d8cd8dd0ed59061e46853e2f8c83
parent 0755ac90
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_TRA
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_OFFSET;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -37,7 +38,6 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.util.FloatProperty;
import android.view.View;

import androidx.annotation.NonNull;
@@ -49,7 +49,6 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.SpringAnimationBuilder;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.quickstep.util.AppWindowAnimationHelper;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -199,11 +198,10 @@ public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransiti
                return ObjectAnimator.ofFloat(mLauncher.getOverviewPanel(),
                        RecentsView.CONTENT_ALPHA, values);
            case INDEX_RECENTS_TRANSLATE_X_ANIM:
                PagedOrientationHandler orientationHandler =
                    ((RecentsView)mLauncher.getOverviewPanel()).getPagedViewOrientedState()
                        .getOrientationHandler();
                FloatProperty<View> translate = orientationHandler.getPrimaryViewTranslate();
                return new SpringAnimationBuilder<>(mLauncher.getOverviewPanel(), translate)
                // TODO: Do not assume motion across X axis for adjacent page
                return new SpringAnimationBuilder<>(
                        mLauncher.getOverviewPanel(), ADJACENT_PAGE_OFFSET)
                        .setMinimumVisibleChange(1f / mLauncher.getOverviewPanel().getWidth())
                        .setDampingRatio(0.8f)
                        .setStiffness(250)
                        .setValues(values)
+9 −6
Original line number Diff line number Diff line
@@ -61,13 +61,16 @@ public class BackgroundAppState extends OverviewState {
    }

    @Override
    public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
    public float[] getOverviewScaleAndOffset(Launcher launcher) {
        return new float[] {getOverviewScale(launcher), NO_OFFSET};
    }

    private float getOverviewScale(Launcher launcher) {
        // Initialize the recents view scale to what it would be when starting swipe up
        RecentsView recentsView = launcher.getOverviewPanel();
        int taskCount = recentsView.getTaskViewCount();
        if (taskCount == 0) {
            return super.getOverviewScaleAndTranslation(launcher);
        }
        if (taskCount == 0) return 1;

        TaskView dummyTask;
        if (recentsView.getCurrentPage() >= recentsView.getTaskViewStartIndex()) {
            if (recentsView.getCurrentPage() <= taskCount - 1) {
@@ -78,8 +81,8 @@ public class BackgroundAppState extends OverviewState {
        } else {
            dummyTask = recentsView.getTaskViewAt(0);
        }
        return recentsView.getTempAppWindowAnimationHelper().updateForFullscreenOverview(dummyTask)
                .getScaleAndTranslation();
        return recentsView.getTempAppWindowAnimationHelper()
                .updateForFullscreenOverview(dummyTask).getSrcToTargetScale();
    }

    @Override
+4 −10
Original line number Diff line number Diff line
@@ -24,24 +24,18 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TR

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.states.StateAnimationConfig;

public class OverviewPeekState extends OverviewState {
    private static final float OVERVIEW_OFFSET = 0.7f;

    public OverviewPeekState(int id) {
        super(id);
    }

    @Override
    public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
        ScaleAndTranslation result = super.getOverviewScaleAndTranslation(launcher);
        result.translationX = NORMAL.getOverviewScaleAndTranslation(launcher).translationX
                - launcher.getResources().getDimension(R.dimen.overview_peek_distance);
        if (Utilities.isRtl(launcher.getResources())) {
            result.translationX = -result.translationX;
        }
        return result;
    public float[] getOverviewScaleAndOffset(Launcher launcher) {
        return new float[] {NO_SCALE, OVERVIEW_OFFSET};
    }

    @Override
+2 −3
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7;
import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE;
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_TRANSLATE_X;
@@ -123,8 +122,8 @@ public class OverviewState extends LauncherState {
    }

    @Override
    public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
        return new ScaleAndTranslation(1f, 0f, 0f);
    public float[] getOverviewScaleAndOffset(Launcher launcher) {
        return new float[] {NO_SCALE, NO_OFFSET};
    }

    @Override
+15 −42
Original line number Diff line number Diff line
@@ -40,17 +40,15 @@ import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.CANCEL;
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.ADJACENT_PAGE_OFFSET;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.PointF;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;

import com.android.launcher3.BaseQuickstepLauncher;
@@ -59,6 +57,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.states.StateAnimationConfig;
@@ -237,58 +236,32 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
    private void setupOverviewAnimators() {
        final LauncherState fromState = QUICK_SWITCH;
        final LauncherState toState = OVERVIEW;
        LauncherState.ScaleAndTranslation fromScaleAndTranslation = fromState
                .getOverviewScaleAndTranslation(mLauncher);
        LauncherState.ScaleAndTranslation toScaleAndTranslation = toState
                .getOverviewScaleAndTranslation(mLauncher);
        // Update RecentView's translationX to have it start offscreen.
        float startScale = Utilities.mapRange(
                SCALE_DOWN_INTERPOLATOR.getInterpolation(Y_ANIM_MIN_PROGRESS),
                fromScaleAndTranslation.scale,
                toScaleAndTranslation.scale);
        fromScaleAndTranslation.translationX = mRecentsView.getOffscreenTranslationX(startScale);

        // Set RecentView's initial properties.
        mRecentsView.setScaleX(fromScaleAndTranslation.scale);
        mRecentsView.setScaleY(fromScaleAndTranslation.scale);
        mRecentsView.setTranslationX(fromScaleAndTranslation.translationX);
        mRecentsView.setTranslationY(fromScaleAndTranslation.translationY);
        SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
        ADJACENT_PAGE_OFFSET.set(mRecentsView, 1f);
        mRecentsView.setContentAlpha(1);
        mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());

        float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
        // As we drag right, animate the following properties:
        //   - RecentsView translationX
        //   - OverviewScrim
        AnimatorSet xOverviewAnim = new AnimatorSet();
        xOverviewAnim.play(ObjectAnimator.ofFloat(mRecentsView, View.TRANSLATION_X,
                toScaleAndTranslation.translationX));
        xOverviewAnim.play(ObjectAnimator.ofFloat(
                mLauncher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_PROGRESS,
                toState.getOverviewScrimAlpha(mLauncher)));
        long xAccuracy = (long) (mXRange * 2);
        xOverviewAnim.setDuration(xAccuracy);
        mXOverviewAnim = AnimatorPlaybackController.wrap(xOverviewAnim, xAccuracy);
        PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
        xAnim.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1], LINEAR);
        xAnim.setFloat(mLauncher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_PROGRESS,
                toState.getOverviewScrimAlpha(mLauncher), LINEAR);
        mXOverviewAnim = xAnim.createPlaybackController();
        mXOverviewAnim.dispatchOnStart();

        // As we drag up, animate the following properties:
        //   - RecentsView translationY
        //   - RecentsView scale
        //   - RecentsView fullscreenProgress
        AnimatorSet yAnimation = new AnimatorSet();
        Animator translateYAnim = ObjectAnimator.ofFloat(mRecentsView, View.TRANSLATION_Y,
                toScaleAndTranslation.translationY);
        Animator scaleAnim = ObjectAnimator.ofFloat(mRecentsView, SCALE_PROPERTY,
                toScaleAndTranslation.scale);
        Animator fullscreenProgressAnim = ObjectAnimator.ofFloat(mRecentsView, FULLSCREEN_PROGRESS,
                fromState.getOverviewFullscreenProgress(), toState.getOverviewFullscreenProgress());
        scaleAnim.setInterpolator(SCALE_DOWN_INTERPOLATOR);
        fullscreenProgressAnim.setInterpolator(SCALE_DOWN_INTERPOLATOR);
        yAnimation.play(translateYAnim);
        yAnimation.play(scaleAnim);
        yAnimation.play(fullscreenProgressAnim);
        long yAccuracy = (long) (mYRange * 2);
        yAnimation.setDuration(yAccuracy);
        mYOverviewAnim = AnimatorPlaybackController.wrap(yAnimation, yAccuracy);
        PendingAnimation yAnim = new PendingAnimation((long) (mYRange * 2));
        yAnim.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndOffset[0], SCALE_DOWN_INTERPOLATOR);
        yAnim.setFloat(mRecentsView, FULLSCREEN_PROGRESS,
                toState.getOverviewFullscreenProgress(), SCALE_DOWN_INTERPOLATOR);
        mYOverviewAnim = yAnim.createPlaybackController();
        mYOverviewAnim.dispatchOnStart();
    }

Loading