Merge "Adding TouchController for quickswitching on homescreen in transposed layout" into ub-launcher3-qt-dev

This commit is contained in:
Sunny Goyal
2019-05-15 17:50:32 +00:00
committed by Android (Google) Code Review
4 changed files with 55 additions and 2 deletions
@@ -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 */));
@@ -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());
@@ -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
@@ -0,0 +1,44 @@
/*
* 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;
}
}