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

Commit 339d1957 authored by Tony Wickham's avatar Tony Wickham
Browse files

Ignore touches on launcher while quick scrub is enabled

Bug: 72189689
Change-Id: Ic4564719a35442670226a021ae2c8799a884b201
parent 23608f7c
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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;

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

    private QuickScrubController mQuickScrubController;

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

    @Override
    public boolean onControllerTouchEvent(MotionEvent ev) {
        return true;
    }

    @Override
    public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
        return mQuickScrubController.isQuickScrubEnabled();
    }
}
+4 −3
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.launcher3.util.TouchController;
import com.android.launcher3.widget.WidgetsFullSheet;
import com.android.quickstep.RecentsView;
import com.android.systemui.shared.recents.view.RecentsTransition;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;

public class UiFactory {

@@ -44,11 +43,13 @@ public class UiFactory {
    public static TouchController[] createTouchControllers(Launcher launcher) {
        if (FeatureFlags.ENABLE_TWO_SWIPE_TARGETS) {
            return new TouchController[] {
                    new IgnoreTouchesInQuickScrub(launcher),
                    new EdgeSwipeController(launcher),
                    new TwoStepSwipeController(launcher),
                    new OverviewSwipeController(launcher)};
        } else {
            return new TouchController[] {
                    new IgnoreTouchesInQuickScrub(launcher),
                    new TwoStepSwipeController(launcher),
                    new OverviewSwipeController(launcher)};
        }
+10 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class QuickScrubController implements OnAlarmListener {

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

    public QuickScrubController(Launcher launcher) {
        mLauncher = launcher;
@@ -51,11 +52,14 @@ 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) {
        if (mRecentsView == null) {
            mQuickScrubEnabled = false;
        } else {
            int page = mRecentsView.getNextPage();
            // Settle on the page then launch it.
            int snapDuration = Math.abs(page - mRecentsView.getPageNearestToCenterOfScreen())
@@ -67,10 +71,15 @@ 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) {