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

Commit 93c4de74 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Setting interpolator beforehand, instead of overriding it after the pending

animaiton is created

Change-Id: I7caec2eeb86084591fa627518d064b7ebb895d65
parent 43657340
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.isTouchOverHotseat;

import android.view.MotionEvent;
import android.view.animation.Interpolator;

import com.android.launcher3.Launcher;
import com.android.launcher3.util.PendingAnimation;
@@ -74,12 +75,12 @@ public final class PortraitOverviewStateTouchHelper {
     * @param duration how long the animation should be
     * @return the animation
     */
    PendingAnimation createSwipeDownToTaskAppAnimation(long duration) {
    PendingAnimation createSwipeDownToTaskAppAnimation(long duration, Interpolator interpolator) {
        mRecentsView.setCurrentPage(mRecentsView.getPageNearestToCenterOfScreen());
        TaskView taskView = mRecentsView.getCurrentPageTaskView();
        if (taskView == null) {
            throw new IllegalStateException("There is no task view to animate to.");
        }
        return mRecentsView.createTaskLauncherAnimation(taskView, duration);
        return mRecentsView.createTaskLaunchAnimation(taskView, duration, interpolator);
    }
}
+4 −5
Original line number Diff line number Diff line
@@ -191,9 +191,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>

            mEndDisplacement = -mTaskBeingDragged.getHeight();
        } else {
            mPendingAnimation = mRecentsView.createTaskLauncherAnimation(
                    mTaskBeingDragged, maxDuration);
            mPendingAnimation.anim.setInterpolator(Interpolators.ZOOM_IN);
            mPendingAnimation = mRecentsView.createTaskLaunchAnimation(
                    mTaskBeingDragged, maxDuration, Interpolators.ZOOM_IN);

            mTempCords[1] = mTaskBeingDragged.getHeight();
            dl.getDescendantCoordRelativeToSelf(mTaskBeingDragged, mTempCords);
@@ -203,8 +202,8 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
        if (mCurrentAnimation != null) {
            mCurrentAnimation.setOnCancelRunnable(null);
        }
        mCurrentAnimation = AnimatorPlaybackController
                .wrap(mPendingAnimation.anim, maxDuration, this::clearState);
        mCurrentAnimation = AnimatorPlaybackController.wrap(
                mPendingAnimation.anim, maxDuration, this::clearState);
        onUserControlledAnimationCreated(mCurrentAnimation);
        mCurrentAnimation.getTarget().addListener(this);
        mCurrentAnimation.dispatchOnStart();
+4 −3
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.widget.ListView;

import androidx.annotation.Nullable;
@@ -1599,7 +1600,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        return anim;
    }

    public PendingAnimation createTaskLauncherAnimation(TaskView tv, long duration) {
    public PendingAnimation createTaskLaunchAnimation(
            TaskView tv, long duration, Interpolator interpolator) {
        if (FeatureFlags.IS_STUDIO_BUILD && mPendingAnimation != null) {
            throw new IllegalStateException("Another pending animation is still running");
        }
@@ -1612,7 +1614,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        int targetSysUiFlags = tv.getThumbnail().getSysUiStatusNavFlags();
        final boolean[] passedOverviewThreshold = new boolean[] {false};
        ValueAnimator progressAnim = ValueAnimator.ofFloat(0, 1);
        progressAnim.setInterpolator(LINEAR);
        progressAnim.addUpdateListener(animator -> {
            // Once we pass a certain threshold, update the sysui flags to match the target
            // tasks' flags
@@ -1638,7 +1639,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        appWindowAnimationHelper.prepareAnimation(mActivity.getDeviceProfile(), true /* isOpening */);
        AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv, appWindowAnimationHelper);
        anim.play(progressAnim);
        anim.setDuration(duration);
        anim.setDuration(duration).setInterpolator(interpolator);

        Consumer<Boolean> onTaskLaunchFinish = this::onTaskLaunched;

+5 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.widget.Toast.LENGTH_SHORT;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview;

@@ -280,11 +281,10 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
    }

    public AnimatorPlaybackController createLaunchAnimationForRunningTask() {
        final PendingAnimation pendingAnimation =
                getRecentsView().createTaskLauncherAnimation(this, RECENTS_LAUNCH_DURATION);
        pendingAnimation.anim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
        AnimatorPlaybackController currentAnimation = AnimatorPlaybackController
                .wrap(pendingAnimation.anim, RECENTS_LAUNCH_DURATION, null);
        final PendingAnimation pendingAnimation = getRecentsView().createTaskLaunchAnimation(
                this, RECENTS_LAUNCH_DURATION, TOUCH_RESPONSE_INTERPOLATOR);
        AnimatorPlaybackController currentAnimation = AnimatorPlaybackController.wrap(
                pendingAnimation.anim, RECENTS_LAUNCH_DURATION);
        currentAnimation.setEndAction(() -> {
            pendingAnimation.finish(true, Touch.SWIPE);
            launchTask(false);
+3 −5
Original line number Diff line number Diff line
@@ -228,15 +228,13 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
            // Reset the state manager, when changing the interaction mode
            mLauncher.getStateManager().goToState(OVERVIEW, false /* animate */);
            mPendingAnimation = mOverviewPortraitStateTouchHelper
                    .createSwipeDownToTaskAppAnimation(maxAccuracy);
            mPendingAnimation.anim.setInterpolator(Interpolators.LINEAR);

                    .createSwipeDownToTaskAppAnimation(maxAccuracy, Interpolators.LINEAR);
            Runnable onCancelRunnable = () -> {
                cancelPendingAnim();
                clearState();
            };
            mCurrentAnimation = AnimatorPlaybackController.wrap(mPendingAnimation.anim, maxAccuracy,
                    onCancelRunnable);
            mCurrentAnimation = AnimatorPlaybackController.wrap(
                    mPendingAnimation.anim, maxAccuracy, onCancelRunnable);
            mLauncher.getStateManager().setCurrentUserControlledAnimation(mCurrentAnimation);
            totalShift = LayoutUtils.getShelfTrackingDistance(mLauncher,
                    mLauncher.getDeviceProfile());