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

Commit eb1c9ea0 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Simplifying/fixing logic for ignoring touches in quick scrub" into ub-launcher3-master

parents cfb630f8 b4175d89
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -18,20 +18,15 @@ package com.android.launcher3.uioverrides;

import android.view.MotionEvent;

import com.android.launcher3.Launcher;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.QuickScrubController;
import com.android.quickstep.RecentsView;
import com.android.quickstep.TouchInteractionService;

/**
 * Consumes touches when quick scrub is enabled.
 */
public class IgnoreTouchesInQuickScrub implements TouchController {

    private QuickScrubController mQuickScrubController;

    public IgnoreTouchesInQuickScrub(Launcher l) {
        mQuickScrubController = ((RecentsView) l.getOverviewPanel()).getQuickScrubController();
    public IgnoreTouchesInQuickScrub() {
    }

    @Override
@@ -41,6 +36,6 @@ public class IgnoreTouchesInQuickScrub implements TouchController {

    @Override
    public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
        return mQuickScrubController.isQuickScrubEnabled();
        return TouchInteractionService.isQuickScrubEnabled();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -43,13 +43,13 @@ public class UiFactory {
    public static TouchController[] createTouchControllers(Launcher launcher) {
        if (FeatureFlags.ENABLE_TWO_SWIPE_TARGETS) {
            return new TouchController[] {
                    new IgnoreTouchesInQuickScrub(launcher),
                    new IgnoreTouchesInQuickScrub(),
                    new EdgeSwipeController(launcher),
                    new TwoStepSwipeController(launcher),
                    new OverviewSwipeController(launcher)};
        } else {
            return new TouchController[] {
                    new IgnoreTouchesInQuickScrub(launcher),
                    new IgnoreTouchesInQuickScrub(),
                    new TwoStepSwipeController(launcher),
                    new OverviewSwipeController(launcher)};
        }
+0 −8
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ public class QuickScrubController implements OnAlarmListener {

    private int mQuickScrubSection;
    private int mStartPage;
    private boolean mQuickScrubEnabled;

    public QuickScrubController(Launcher launcher) {
        mLauncher = launcher;
@@ -52,13 +51,11 @@ public class QuickScrubController implements OnAlarmListener {
        mRecentsView = mLauncher.getOverviewPanel();
        mStartPage = startingFromHome ? 0 : mRecentsView.getFirstTaskIndex();
        mQuickScrubSection = 0;
        mQuickScrubEnabled = true;
    }

    public void onQuickScrubEnd() {
        mAutoAdvanceAlarm.cancelAlarm();
        if (mRecentsView == null) {
            mQuickScrubEnabled = false;
        } else {
            int page = mRecentsView.getNextPage();
            // Settle on the page then launch it.
@@ -71,15 +68,10 @@ public class QuickScrubController implements OnAlarmListener {
                } else {
                    ((TaskView) mRecentsView.getPageAt(page)).launchTask(true);
                }
                mQuickScrubEnabled = false;
            }, snapDuration);
        }
    }

    public boolean isQuickScrubEnabled() {
        return mQuickScrubEnabled;
    }

    public void onQuickScrubProgress(float progress) {
        int quickScrubSection = Math.round(progress * NUM_QUICK_SCRUB_SECTIONS);
        if (quickScrubSection != mQuickScrubSection) {
+7 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class TouchInteractionService extends Service {
        @Override
        public void onQuickScrubStart() {
            startTouchTracking(INTERACTION_QUICK_SCRUB);
            sQuickScrubEnabled = true;
        }

        @Override
@@ -114,6 +115,7 @@ public class TouchInteractionService extends Service {
                mInteractionHandler.onQuickScrubEnd();
                mInteractionHandler = null;
            }
            sQuickScrubEnabled = false;
        }

        @Override
@@ -129,11 +131,16 @@ public class TouchInteractionService extends Service {
    private final Consumer<MotionEvent> mNoOpTouchConsumer = (ev) -> {};

    private static boolean sConnected = false;
    private static boolean sQuickScrubEnabled = false;

    public static boolean isConnected() {
        return sConnected;
    }

    public static boolean isQuickScrubEnabled() {
        return sQuickScrubEnabled;
    }

    private ActivityManagerWrapper mAM;
    private RunningTaskInfo mRunningTask;
    private RecentsModel mRecentsModel;