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

Commit 6e173752 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Adding TouchController for quickswitching on homescreen in transposed layout

Bug: 130689544
Change-Id: I6126fbf29d9b4099d59dd8ad2ba4b4b9673bc46b
parent 2d49d1de
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchCon
import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.QuickSwitchTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController;
import com.android.launcher3.uioverrides.touchcontrollers.TransposedQuickSwitchTouchController;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.util.UiThreadHelper;
import com.android.launcher3.util.UiThreadHelper.AsyncCommand;
@@ -148,6 +149,9 @@ public abstract class RecentsUiFactory {
            if (launcher.getDeviceProfile().isVerticalBarLayout()) {
                list.add(new OverviewToAllAppsTouchController(launcher));
                list.add(new LandscapeEdgeSwipeController(launcher));
                if (mode.hasGestures) {
                    list.add(new TransposedQuickSwitchTouchController(launcher));
                }
            } else {
                list.add(new PortraitStatesTouchController(launcher,
                        mode.hasGestures /* allowDragToOverview */));
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.MotionEvent;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.views.RecentsView;
@@ -52,7 +53,7 @@ public class OverviewToAllAppsTouchController extends PortraitStatesTouchControl
            // In all-apps only listen if the container cannot scroll itself
            return mLauncher.getAppsView().shouldContainerScroll(ev);
        } else if (mLauncher.isInState(NORMAL)) {
            return true;
            return (ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) == 0;
        } else if (mLauncher.isInState(OVERVIEW)) {
            RecentsView rv = mLauncher.getOverviewPanel();
            return ev.getY() > (rv.getBottom() - rv.getPaddingBottom());
+5 −1
Original line number Diff line number Diff line
@@ -57,7 +57,11 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll
    private @Nullable TaskView mTaskToLaunch;

    public QuickSwitchTouchController(Launcher launcher) {
        super(launcher, SwipeDetector.HORIZONTAL);
        this(launcher, SwipeDetector.HORIZONTAL);
    }

    protected QuickSwitchTouchController(Launcher l, SwipeDetector.Direction dir) {
        super(l, dir);
    }

    @Override
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.touchcontrollers;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.touch.SwipeDetector;

public class TransposedQuickSwitchTouchController extends QuickSwitchTouchController {

    public TransposedQuickSwitchTouchController(Launcher launcher) {
        super(launcher, SwipeDetector.VERTICAL);
    }

    @Override
    protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
        return super.getTargetState(fromState,
                isDragTowardPositive ^ mLauncher.getDeviceProfile().isSeascape());
    }

    @Override
    protected float initCurrentAnimation(int animComponents) {
        float multiplier = super.initCurrentAnimation(animComponents);
        return mLauncher.getDeviceProfile().isSeascape() ? multiplier : -multiplier;
    }

    @Override
    protected float getShiftRange() {
        return mLauncher.getDeviceProfile().heightPx / 2f;
    }
}