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

Commit 1f2b23dd authored by Alex Chau's avatar Alex Chau
Browse files

Remove extra grid interpolator in TaskView

- Currently in App -> Overview animation, current task is undergo ACCELERATE_DECELERATE interpolator twice, one via interpolating GRID_PROGRESS in AbsSwipeUpHandler, one via TaskView.getGridTrans
- I got rid of TaskView.getGridTrans's interpolator, and completely rely on AbsSwipeUpHandler or BaseRecentsViewStateController to apply the interpolator
- Refactored BaseRecentsViewStateController to consistenly apply ACCELERATE_DECELERATE for QUICK_SWITCH_FROM_HOME -> Overview animation, and otherwise it should use INSTNAT/FINAL_FRAME

Bug: 318352235
Flag: None
Test: Default/3P Launcher X home/qs_from_home/app -> Overview and Overview to home
Change-Id: I21ca903897f8c374e136c0ac27cec76dd3f5c1f3
parent 82d88d3f
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.uioverrides;

import static com.android.app.animation.Interpolators.ACCELERATE_DECELERATE;
import static com.android.app.animation.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.app.animation.Interpolators.FINAL_FRAME;
import static com.android.app.animation.Interpolators.INSTANT;
@@ -132,15 +133,17 @@ public abstract class BaseRecentsViewStateController<T extends RecentsView>
        LauncherState fromState = mLauncher.getStateManager().getState();
        setter.setFloat(mRecentsView, TASK_THUMBNAIL_SPLASH_ALPHA,
                toState.showTaskThumbnailSplash() ? 1f : 0f,
                !toState.showTaskThumbnailSplash() && fromState == QUICK_SWITCH_FROM_HOME
                        ? LINEAR : INSTANT);

        boolean showAsGrid = toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile());
        Interpolator gridProgressInterpolator = showAsGrid
                ? fromState == QUICK_SWITCH_FROM_HOME ? LINEAR : INSTANT
                : FINAL_FRAME;
        setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, showAsGrid ? 1f : 0f,
                gridProgressInterpolator);
                getOverviewInterpolator(fromState, toState));

        setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS,
                toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile()) ? 1f : 0f,
                getOverviewInterpolator(fromState, toState));
    }

    private Interpolator getOverviewInterpolator(LauncherState fromState, LauncherState toState) {
        return fromState == QUICK_SWITCH_FROM_HOME
                ? ACCELERATE_DECELERATE
                : toState.overviewUi ? INSTANT : FINAL_FRAME;
    }

    abstract FloatProperty getTaskModalnessProperty();
+7 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import static com.android.quickstep.views.TaskView.FLAG_UPDATE_ALL;

import android.util.FloatProperty;
import android.util.Pair;
import android.view.animation.Interpolator;

import androidx.annotation.NonNull;

@@ -110,9 +111,9 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
        setter.setFloat(mRecentsView, FULLSCREEN_PROGRESS, state.isFullScreen() ? 1 : 0, LINEAR);
        boolean showAsGrid = state.displayOverviewTasksAsGrid(mActivity.getDeviceProfile());
        setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS, showAsGrid ? 1f : 0f,
                showAsGrid ? INSTANT : FINAL_FRAME);
                getOverviewInterpolator(state));
        setter.setFloat(mRecentsView, TASK_THUMBNAIL_SPLASH_ALPHA,
                state.showTaskThumbnailSplash() ? 1f : 0f, INSTANT);
                state.showTaskThumbnailSplash() ? 1f : 0f, getOverviewInterpolator(state));

        setter.setViewBackgroundColor(mActivity.getScrimView(), state.getScrimColor(mActivity),
                config.getInterpolator(ANIM_SCRIM_FADE, LINEAR));
@@ -135,6 +136,10 @@ public class FallbackRecentsStateController implements StateHandler<RecentsState
        setter.setFloat(mRecentsView, taskViewsFloat.second, 0, LINEAR);
    }

    private Interpolator getOverviewInterpolator(RecentsState toState) {
        return toState.overviewUi() ? INSTANT : FINAL_FRAME;
    }

    /**
     * @return true if {@param toState} is {@link RecentsState#OVERVIEW_SPLIT_SELECT}
     */
+2 −8
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.widget.Toast.LENGTH_SHORT;

import static com.android.app.animation.Interpolators.ACCELERATE_DECELERATE;
import static com.android.app.animation.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.launcher3.Flags.enableCursorHoverStates;
@@ -69,7 +68,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.Toast;

@@ -174,8 +172,6 @@ public class TaskView extends FrameLayout implements Reusable {
    public static final long SCALE_ICON_DURATION = 120;
    private static final long DIM_ANIM_DURATION = 700;

    private static final Interpolator GRID_INTERPOLATOR = ACCELERATE_DECELERATE;

    /**
     * This technically can be a vanilla {@link TouchDelegate} class, however that class requires
     * setting the touch bounds at construction, so we'd repeatedly be created many instances
@@ -1403,8 +1399,7 @@ public class TaskView extends FrameLayout implements Reusable {
     */
    public float getPersistentScale() {
        float scale = 1;
        float gridProgress = GRID_INTERPOLATOR.getInterpolation(mGridProgress);
        scale *= Utilities.mapRange(gridProgress, mNonGridScale, 1f);
        scale *= Utilities.mapRange(mGridProgress, mNonGridScale, 1f);
        return scale;
    }

@@ -1804,8 +1799,7 @@ public class TaskView extends FrameLayout implements Reusable {
    }

    private float getGridTrans(float endTranslation) {
        float progress = GRID_INTERPOLATOR.getInterpolation(mGridProgress);
        return Utilities.mapRange(progress, 0, endTranslation);
        return Utilities.mapRange(mGridProgress, 0, endTranslation);
    }

    private float getNonGridTrans(float endTranslation) {