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 Original line 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.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator;
import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator;
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_OFFSET;


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


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


    @Override
    @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
        // Initialize the recents view scale to what it would be when starting swipe up
        RecentsView recentsView = launcher.getOverviewPanel();
        RecentsView recentsView = launcher.getOverviewPanel();
        int taskCount = recentsView.getTaskViewCount();
        int taskCount = recentsView.getTaskViewCount();
        if (taskCount == 0) {
        if (taskCount == 0) return 1;
            return super.getOverviewScaleAndTranslation(launcher);

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


    @Override
    @Override
+4 −10
Original line number Original line 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.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.states.StateAnimationConfig;


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

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


    @Override
    @Override
    public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
    public float[] getOverviewScaleAndOffset(Launcher launcher) {
        ScaleAndTranslation result = super.getOverviewScaleAndTranslation(launcher);
        return new float[] {NO_SCALE, OVERVIEW_OFFSET};
        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;
    }
    }


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


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


    @Override
    @Override
+15 −42
Original line number Original line 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.CANCEL;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.HIDE;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.HIDE;
import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.PEEK;
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.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;


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


import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.BaseQuickstepLauncher;
@@ -59,6 +57,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.states.StateAnimationConfig;
@@ -237,58 +236,32 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
    private void setupOverviewAnimators() {
    private void setupOverviewAnimators() {
        final LauncherState fromState = QUICK_SWITCH;
        final LauncherState fromState = QUICK_SWITCH;
        final LauncherState toState = OVERVIEW;
        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.
        // Set RecentView's initial properties.
        mRecentsView.setScaleX(fromScaleAndTranslation.scale);
        SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
        mRecentsView.setScaleY(fromScaleAndTranslation.scale);
        ADJACENT_PAGE_OFFSET.set(mRecentsView, 1f);
        mRecentsView.setTranslationX(fromScaleAndTranslation.translationX);
        mRecentsView.setTranslationY(fromScaleAndTranslation.translationY);
        mRecentsView.setContentAlpha(1);
        mRecentsView.setContentAlpha(1);
        mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
        mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());


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


        // As we drag up, animate the following properties:
        // As we drag up, animate the following properties:
        //   - RecentsView translationY
        //   - RecentsView scale
        //   - RecentsView scale
        //   - RecentsView fullscreenProgress
        //   - RecentsView fullscreenProgress
        AnimatorSet yAnimation = new AnimatorSet();
        PendingAnimation yAnim = new PendingAnimation((long) (mYRange * 2));
        Animator translateYAnim = ObjectAnimator.ofFloat(mRecentsView, View.TRANSLATION_Y,
        yAnim.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndOffset[0], SCALE_DOWN_INTERPOLATOR);
                toScaleAndTranslation.translationY);
        yAnim.setFloat(mRecentsView, FULLSCREEN_PROGRESS,
        Animator scaleAnim = ObjectAnimator.ofFloat(mRecentsView, SCALE_PROPERTY,
                toState.getOverviewFullscreenProgress(), SCALE_DOWN_INTERPOLATOR);
                toScaleAndTranslation.scale);
        mYOverviewAnim = yAnim.createPlaybackController();
        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);
        mYOverviewAnim.dispatchOnStart();
        mYOverviewAnim.dispatchOnStart();
    }
    }


Loading