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

Commit 38d2bf35 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Making QuickScrub work, when the fallback activity is on top" into ub-launcher3-master

parents a4e8763d df336cf6
Loading
Loading
Loading
Loading
+39 −9
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppTransitionManagerImpl;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.allapps.AllAppsTransitionController;
@@ -62,7 +61,13 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {

    void onQuickstepGestureStarted(T activity, boolean activityVisible);

    void onQuickInteractionStart(T activity, boolean activityVisible);
    /**
     * Updates the UI to indicate quick interaction.
     * @return true if there any any UI change as a result of this
     */
    boolean onQuickInteractionStart(T activity, boolean activityVisible);

    void executeOnWindowAvailable(T activity, Runnable action);

    void executeOnNextDraw(T activity, TaskView targetView, Runnable action);

@@ -83,6 +88,9 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
    void startRecentsFromSwipe(Intent intent, AssistDataReceiver assistDataReceiver,
            final RecentsAnimationListener remoteAnimationListener);

    @Nullable
    T getCreatedActivity();

    @UiThread
    @Nullable
    RecentsView getVisibleRecentsView();
@@ -103,8 +111,18 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
        }

        @Override
        public void onQuickInteractionStart(Launcher activity, boolean activityVisible) {
        public boolean onQuickInteractionStart(Launcher activity, boolean activityVisible) {
            LauncherState fromState = activity.getStateManager().getState();
            activity.getStateManager().goToState(FAST_OVERVIEW, activityVisible);
            return !fromState.overviewUi;
        }

        @Override
        public void executeOnWindowAvailable(Launcher activity, Runnable action) {
            if (activity.getWorkspace().runOnOverlayHidden(action)) {
                // Notify the activity that qiuckscrub has started
                onQuickstepGestureStarted(activity, true);
            }
        }

        @Override
@@ -210,8 +228,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
        }

        @Nullable
        @UiThread
        private Launcher getLauncher() {
        @Override
        public Launcher getCreatedActivity() {
            LauncherAppState app = LauncherAppState.getInstanceNoCreate();
            if (app == null) {
                return null;
@@ -222,7 +240,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
        @Nullable
        @UiThread
        private Launcher getVisibleLaucher() {
            Launcher launcher = getLauncher();
            Launcher launcher = getCreatedActivity();
            return (launcher != null) && launcher.isStarted() && launcher.hasWindowFocus() ?
                    launcher : null;
        }
@@ -254,8 +272,14 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
        }

        @Override
        public void onQuickInteractionStart(RecentsActivity activity, boolean activityVisible) {
            // TODO:
        public boolean onQuickInteractionStart(RecentsActivity activity, boolean activityVisible) {
            // Activity does not need any UI change for quickscrub.
            return false;
        }

        @Override
        public void executeOnWindowAvailable(RecentsActivity activity, Runnable action) {
            action.run();
        }

        @Override
@@ -337,10 +361,16 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
                    intent, assistDataReceiver, remoteAnimationListener, null, null);
        }

        @Nullable
        @Override
        public RecentsActivity getCreatedActivity() {
            return RecentsActivityTracker.getCurrentActivity();
        }

        @Nullable
        @Override
        public RecentsView getVisibleRecentsView() {
            RecentsActivity activity = RecentsActivityTracker.getCurrentActivity();
            RecentsActivity activity = getCreatedActivity();
            if (activity != null && activity.hasWindowFocus()) {
                return activity.getOverviewPanel();
            }
+42 −27
Original line number Diff line number Diff line
@@ -21,8 +21,7 @@ import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
import static com.android.launcher3.LauncherState.FAST_OVERVIEW;
import static com.android.launcher3.LauncherState.NORMAL;

import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_NONE;

import android.annotation.TargetApi;
@@ -43,9 +42,7 @@ import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.R;
import com.android.launcher3.util.TraceHelper;
@@ -220,13 +217,13 @@ public class TouchInteractionService extends Service {

    private TouchConsumer getCurrentTouchConsumer(
            @HitTarget int downHitTarget, boolean forceToLauncher, VelocityTracker tracker) {
        RunningTaskInfo runningTaskInfo = mAM.getRunningTask();
        RunningTaskInfo runningTaskInfo = mAM.getRunningTask(0);

        if (runningTaskInfo == null && !forceToLauncher) {
            return mNoOpTouchConsumer;
        } else if (forceToLauncher ||
                runningTaskInfo.topActivity.equals(mOverviewCommandHelper.launcher)) {
            return getLauncherConsumer();
            return getOverviewConsumer();
        } else {
            if (tracker == null) {
                tracker = VelocityTracker.obtain();
@@ -238,18 +235,20 @@ public class TouchInteractionService extends Service {
        }
    }

    private TouchConsumer getLauncherConsumer() {
        Launcher launcher = (Launcher) LauncherAppState.getInstance(this).getModel().getCallback();
        if (launcher == null) {
    private TouchConsumer getOverviewConsumer() {
        ActivityControlHelper activityHelper = mOverviewCommandHelper.getActivityControlHelper();
        BaseDraggingActivity activity = activityHelper.getCreatedActivity();
        if (activity == null) {
            return mNoOpTouchConsumer;
        }
        View target = launcher.getDragLayer();
        return new LauncherTouchConsumer(launcher, target);
        return new OverviewTouchConsumer(activityHelper, activity);
    }

    private static class LauncherTouchConsumer implements TouchConsumer {
    private static class OverviewTouchConsumer<T extends BaseDraggingActivity>
            implements TouchConsumer {

        private final Launcher mLauncher;
        private final ActivityControlHelper<T> mActivityHelper;
        private final T mActivity;
        private final View mTarget;
        private final int[] mLocationOnScreen = new int[2];
        private final PointF mDownPos = new PointF();
@@ -260,12 +259,17 @@ public class TouchInteractionService extends Service {
        private boolean mInvalidated = false;
        private boolean mHadWindowFocusOnDown;

        LauncherTouchConsumer(Launcher launcher, View target) {
            mLauncher = launcher;
            mTarget = target;
        private float mLastProgress = 0;
        private boolean mStartPending = false;
        private boolean mEndPending = false;

        OverviewTouchConsumer(ActivityControlHelper<T> activityHelper, T activity) {
            mActivityHelper = activityHelper;
            mActivity = activity;
            mTarget = activity.getDragLayer();
            mTouchSlop = ViewConfiguration.get(mTarget.getContext()).getScaledTouchSlop();

            mQuickScrubController = mLauncher.<RecentsView>getOverviewPanel()
            mQuickScrubController = mActivity.<RecentsView>getOverviewPanel()
                    .getQuickScrubController();
        }

@@ -327,16 +331,22 @@ public class TouchInteractionService extends Service {
                return;
            }
            if (interactionType == INTERACTION_QUICK_SCRUB) {
                mStartPending = true;

                Runnable action = () -> {
                    LauncherState fromState = mLauncher.getStateManager().getState();
                    mLauncher.getStateManager().goToState(FAST_OVERVIEW, true);
                    mQuickScrubController.onQuickScrubStart(fromState == NORMAL);
                };
                    mQuickScrubController.onQuickScrubStart(
                            mActivityHelper.onQuickInteractionStart(mActivity, true));
                    mQuickScrubController.onQuickScrubProgress(mLastProgress);
                    mStartPending = false;

                if (mLauncher.getWorkspace().runOnOverlayHidden(action)) {
                    // Hide the minus one overlay so launcher can get window focus.
                    mLauncher.onQuickstepGestureStarted(true);
                    if (mEndPending) {
                        mQuickScrubController.onQuickScrubEnd();
                        mEndPending = false;
                    }

                };

                mActivityHelper.executeOnWindowAvailable(mActivity, action);
            }
        }

@@ -345,12 +355,17 @@ public class TouchInteractionService extends Service {
            if (mInvalidated) {
                return;
            }
            if (mStartPending) {
                mEndPending = true;
            } else {
                mQuickScrubController.onQuickScrubEnd();
            }
        }

        @Override
        public void onQuickScrubProgress(float progress) {
            if (mInvalidated) {
            mLastProgress = progress;
            if (mInvalidated || mEndPending) {
                return;
            }
            mQuickScrubController.onQuickScrubProgress(progress);