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

Commit 0d9752c6 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "15/ Move some more logic into gesture/device state" into ub-launcher3-master

parents ac04c5fd 4998b193
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import static com.android.quickstep.util.NavBarPosition.ROTATION_LANDSCAPE;
import static com.android.quickstep.util.NavBarPosition.ROTATION_SEASCAPE;

import android.content.Context;
import android.content.res.Configuration;
+4 −12
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.quickstep;

import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.ACCEL_1_5;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
@@ -32,8 +31,6 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;
@@ -51,7 +48,6 @@ import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.util.VibratorWrapper;
import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.BaseActivityInterface.HomeAnimationFactory;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.AppWindowAnimationHelper;
@@ -92,9 +88,8 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
    protected final Context mContext;
    protected final RecentsAnimationDeviceState mDeviceState;
    protected final GestureState mGestureState;
    protected final OverviewComponentObserver mOverviewComponentObserver;
    protected final BaseActivityInterface<T> mActivityInterface;
    protected final RecentsModel mRecentsModel;
    protected final InputConsumerController mInputConsumer;

    protected final AppWindowAnimationHelper mAppWindowAnimationHelper;
    protected final TransformParams mTransformParams = new TransformParams();
@@ -106,7 +101,6 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
    protected final AnimatedFloat mCurrentShift = new AnimatedFloat(this::updateFinalShift);

    protected final ActivityInitListener mActivityInitListener;
    protected final InputConsumerController mInputConsumer;

    protected RecentsAnimationController mRecentsAnimationController;
    protected RecentsAnimationTargets mRecentsAnimationTargets;
@@ -127,20 +121,18 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
    protected int mFinishingRecentsAnimationForNewTaskId = -1;

    protected BaseSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState,
            GestureState gestureState, OverviewComponentObserver overviewComponentObserver,
            RecentsModel recentsModel, InputConsumerController inputConsumer) {
            GestureState gestureState, InputConsumerController inputConsumer) {
        mContext = context;
        mDeviceState = deviceState;
        mGestureState = gestureState;
        mOverviewComponentObserver = overviewComponentObserver;
        mActivityInterface = gestureState.getActivityInterface();
        mRecentsModel = recentsModel;
        mActivityInitListener =
                mActivityInterface.createActivityInitListener(this::onActivityInit);
        mInputConsumer = inputConsumer;

        mAppWindowAnimationHelper = new AppWindowAnimationHelper(context);
        mPageSpacing = context.getResources().getDimensionPixelSize(R.dimen.recents_page_spacing);

        initTransitionEndpoints(InvariantDeviceProfile.INSTANCE.get(mContext)
                .getDeviceProfile(mContext));
    }
@@ -371,7 +363,7 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten

    public void initWhenReady() {
        // Preload the plan
        mRecentsModel.getTasks(null);
        RecentsModel.INSTANCE.get(mContext).getTasks(null);

        mActivityInitListener.register();
    }
+4 −9
Original line number Diff line number Diff line
@@ -248,7 +248,6 @@ public class TouchInteractionService extends Service implements PluginListener<O
            this::createFallbackNoButtonSwipeHandler;

    private ActivityManagerWrapper mAM;
    private RecentsModel mRecentsModel;
    private OverviewCommandHelper mOverviewCommandHelper;
    private OverviewComponentObserver mOverviewComponentObserver;
    private InputConsumerController mInputConsumer;
@@ -327,7 +326,6 @@ public class TouchInteractionService extends Service implements PluginListener<O
    @UiThread
    public void onUserUnlocked() {
        mTaskAnimationManager = new TaskAnimationManager();
        mRecentsModel = RecentsModel.INSTANCE.get(this);
        mOverviewComponentObserver = new OverviewComponentObserver(this, mDeviceState);
        mOverviewCommandHelper = new OverviewCommandHelper(this, mDeviceState,
                mOverviewComponentObserver);
@@ -431,8 +429,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
                TraceHelper.FLAG_ALLOW_BINDER_TRACKING);
        MotionEvent event = (MotionEvent) ev;
        if (event.getAction() == ACTION_DOWN) {
            GestureState newGestureState = new GestureState(
                    mOverviewComponentObserver.getActivityInterface(),
            GestureState newGestureState = new GestureState(mOverviewComponentObserver,
                    ActiveGestureLog.INSTANCE.generateAndSetLogId());
            newGestureState.updateRunningTask(TraceHelper.whitelistIpcs("getRunningTask.0",
                    () -> mAM.getRunningTask(0)));
@@ -607,7 +604,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
                    false /* startingInActivityBounds */);
        } else {
            final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event);
            return new OverviewWithoutFocusInputConsumer(activity, gestureState,
            return new OverviewWithoutFocusInputConsumer(activity, mDeviceState, gestureState,
                    mInputMonitorCompat, disableHorizontalSwipe);
        }
    }
@@ -724,15 +721,13 @@ public class TouchInteractionService extends Service implements PluginListener<O
    private BaseSwipeUpHandler createWindowTransformSwipeHandler(GestureState gestureState,
            long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
        return  new WindowTransformSwipeHandler(this, mDeviceState, mTaskAnimationManager,
                gestureState, touchTimeMs, mOverviewComponentObserver, continuingLastGesture,
                mInputConsumer, mRecentsModel);
                gestureState, touchTimeMs, continuingLastGesture, mInputConsumer);
    }

    private BaseSwipeUpHandler createFallbackNoButtonSwipeHandler(GestureState gestureState,
            long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
        return new FallbackNoButtonInputConsumer(this, mDeviceState, gestureState,
                mOverviewComponentObserver, mRecentsModel, mInputConsumer, isLikelyToStartNewTask,
                continuingLastGesture);
                mInputConsumer, isLikelyToStartNewTask, continuingLastGesture);
    }

    protected boolean shouldNotifyBackGesture() {
+5 −7
Original line number Diff line number Diff line
@@ -191,11 +191,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    public WindowTransformSwipeHandler(Context context, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
            long touchTimeMs, OverviewComponentObserver overviewComponentObserver,
            boolean continuingLastGesture, InputConsumerController inputConsumer,
            RecentsModel recentsModel) {
        super(context, deviceState, gestureState, overviewComponentObserver, recentsModel,
                inputConsumer);
            long touchTimeMs, boolean continuingLastGesture,
            InputConsumerController inputConsumer) {
        super(context, deviceState, gestureState, inputConsumer);
        mTaskAnimationManager = taskAnimationManager;
        mTouchTimeMs = touchTimeMs;
        mContinuingLastGesture = continuingLastGesture;
@@ -379,7 +377,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    private void onDeferredActivityLaunch() {
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            mOverviewComponentObserver.getActivityInterface().switchRunningTaskViewToScreenshot(
            mActivityInterface.switchRunningTaskViewToScreenshot(
                    null, () -> {
                        mTaskAnimationManager.finishRunningRecentsAnimation(true /* toHome */);
                    });
@@ -521,7 +519,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    @Override
    public Intent getLaunchIntent() {
        return mOverviewComponentObserver.getOverviewIntent();
        return mGestureState.getOverviewIntent();
    }

    @Override
+6 −10
Original line number Diff line number Diff line
@@ -46,11 +46,9 @@ import com.android.quickstep.GestureState;
import com.android.quickstep.GestureState.GestureEndTarget;
import com.android.quickstep.InputConsumer;
import com.android.quickstep.MultiStateCallback;
import com.android.quickstep.OverviewComponentObserver;
import com.android.quickstep.RecentsActivity;
import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.fallback.FallbackRecentsView;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.RecentsAnimationTargets;
@@ -111,11 +109,9 @@ public class FallbackNoButtonInputConsumer extends
    private RunningWindowAnim mFinishAnimation;

    public FallbackNoButtonInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
            GestureState gestureState, OverviewComponentObserver overviewComponentObserver,
            RecentsModel recentsModel, InputConsumerController inputConsumer,
            GestureState gestureState, InputConsumerController inputConsumer,
            boolean isLikelyToStartNewTask, boolean continuingLastGesture) {
        super(context, deviceState, gestureState, overviewComponentObserver, recentsModel,
                inputConsumer);
        super(context, deviceState, gestureState, inputConsumer);
        mLauncherAlpha.value = 1;

        mInQuickSwitchMode = isLikelyToStartNewTask || continuingLastGesture;
@@ -225,9 +221,9 @@ public class FallbackNoButtonInputConsumer extends
    @Override
    public Intent getLaunchIntent() {
        if (mInQuickSwitchMode || mSwipeUpOverHome) {
            return mOverviewComponentObserver.getOverviewIntent();
            return mGestureState.getOverviewIntent();
        } else {
            return mOverviewComponentObserver.getHomeIntent();
            return mGestureState.getHomeIntent();
        }
    }

@@ -324,7 +320,7 @@ public class FallbackNoButtonInputConsumer extends
                if (mSwipeUpOverHome) {
                    mRecentsAnimationController.finish(false, null, false);
                    // Send a home intent to clear the task stack
                    mContext.startActivity(mOverviewComponentObserver.getHomeIntent());
                    mContext.startActivity(mGestureState.getHomeIntent());
                } else {
                    mRecentsAnimationController.finish(true, null, true);
                }
@@ -351,7 +347,7 @@ public class FallbackNoButtonInputConsumer extends
                extras.putBinder(EXTRA_THUMBNAIL, new ObjectWrapper<>(thumbnail));
                extras.putInt(EXTRA_TASK_ID, runningTaskId);

                Intent intent = new Intent(mOverviewComponentObserver.getOverviewIntent())
                Intent intent = new Intent(mGestureState.getOverviewIntent())
                        .putExtras(extras);
                mContext.startActivity(intent, options.toBundle());
                mRecentsAnimationController.cleanupScreenshot();
Loading