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

Commit ce8b2b51 authored by Tony Wickham's avatar Tony Wickham
Browse files

Add translation component to swipe up resistance

Now recents view follows your finger all the way to the top of the
screen. Specifically, your finger tracks the bottom of the window
until resistance starts (when RecentsView is at 75% scale), then
we add translation to compensate for the slower rate of scaling
down, such that your finger slips to the top of the window by the
time it reaches the top of the screen.

Also reset this translation back to 0 in the state handlers.

Bug: 149934536
Fixes: 158701272
Change-Id: Iaee58da758d422f0173c29d002f5c451ce0c1809
parent 3f20e33a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -101,7 +101,8 @@ public abstract class SwipeUpAnimationLogic {
        AnimatorPlaybackController normalController = pa.createPlaybackController();
        mWindowTransitionController = AnimatorControllerWithResistance.createForRecents(
                normalController, mContext, mTaskViewSimulator.getOrientationState(),
                mDp, mTaskViewSimulator.recentsViewScale, AnimatedFloat.VALUE);
                mDp, mTaskViewSimulator.recentsViewScale, AnimatedFloat.VALUE,
                mTaskViewSimulator.recentsViewSecondaryTranslation, AnimatedFloat.VALUE);
    }

    @UiThread
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static com.android.launcher3.anim.Interpolators.LINEAR;
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_TRANSLATE_X;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_PEEK;
import static com.android.launcher3.states.StateAnimationConfig.PLAY_ATOMIC_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
@@ -26,6 +27,7 @@ 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.RECENTS_SCALE_PROPERTY;
import static com.android.quickstep.views.RecentsView.TASK_MODALNESS;
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;

import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
@@ -86,6 +88,8 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
                config.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR));
        setter.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1],
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR));
        setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f,
                config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));

        setter.setFloat(mRecentsView, TASK_MODALNESS, state.getOverviewModalness(),
                config.getInterpolator(ANIM_OVERVIEW_MODAL, LINEAR));
+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ public class RecentsState implements BaseState<RecentsState> {
        return new float[] { NO_SCALE, NO_OFFSET };
    }


    private static class ModalState extends RecentsState {

        public ModalState(int id, int flags) {
+4 −1
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
    // RecentsView properties
    public final AnimatedFloat recentsViewScale = new AnimatedFloat();
    public final AnimatedFloat fullScreenProgress = new AnimatedFloat();
    public final AnimatedFloat recentsViewSecondaryTranslation = new AnimatedFloat();
    private final ScrollState mScrollState = new ScrollState();

    // Cached calculations
@@ -274,8 +275,10 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
        mOrientationState.getOrientationHandler().set(
                mMatrix, MATRIX_POST_TRANSLATE, mScrollState.scroll);

        // Apply recensView matrix
        // Apply RecentsView matrix
        mMatrix.postScale(recentsViewScale.value, recentsViewScale.value, mPivot.x, mPivot.y);
        mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
                recentsViewSecondaryTranslation.value);
        applyWindowToHomeRotation(mMatrix);

        // Crop rect is the inverse of thumbnail matrix
+24 −1
Original line number Diff line number Diff line
@@ -210,6 +210,19 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
                }
            };

    public static final FloatProperty<RecentsView> TASK_SECONDARY_TRANSLATION =
            new FloatProperty<RecentsView>("taskSecondaryTranslation") {
                @Override
                public void setValue(RecentsView recentsView, float v) {
                    recentsView.setTaskViewsSecondaryTranslation(v);
                }

                @Override
                public Float get(RecentsView recentsView) {
                    return recentsView.mTaskViewsSecondaryTranslation;
                }
            };

    /** Same as normal SCALE_PROPERTY, but also updates page offsets that depend on this scale. */
    public static final FloatProperty<RecentsView> RECENTS_SCALE_PROPERTY =
            new FloatProperty<RecentsView>("recentsScale") {
@@ -219,6 +232,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
                    view.setScaleY(scale);
                    view.mLastComputedTaskPushOutDistance = null;
                    view.updatePageOffsets();
                    view.setTaskViewsSecondaryTranslation(view.mTaskViewsSecondaryTranslation);
                }

                @Override
@@ -269,6 +283,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
    protected boolean mFreezeViewVisibility;

    private float mAdjacentPageOffset = 0;
    private float mTaskViewsSecondaryTranslation = 0;

    /**
     * TODO: Call reloadIdNeeded in onTaskStackChanged.
@@ -1391,7 +1406,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        FloatProperty<View> secondaryViewTranslate =
            mOrientationHandler.getSecondaryViewTranslate();
        int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView);
        int verticalFactor = mOrientationHandler.getTaskDismissDirectionFactor();
        int verticalFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();

        ResourceProvider rp = DynamicResource.provider(mActivity);
        SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_START)
@@ -1908,6 +1923,14 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        return distanceToOffscreen * offsetProgress;
    }

    private void setTaskViewsSecondaryTranslation(float translation) {
        mTaskViewsSecondaryTranslation = translation;
        for (int i = 0; i < getTaskViewCount(); i++) {
            TaskView task = getTaskViewAt(i);
            mOrientationHandler.getSecondaryViewTranslate().set(task, translation / getScaleY());
        }
    }

    /**
     * TODO: Do not assume motion across X axis for adjacent page
     */
Loading