From daad3fefea0d91a9a7da3bd6f5780e66ae7110d6 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Thu, 20 Oct 2022 00:37:33 -0700 Subject: [PATCH] Support swipe gesture on trackpad to swipe up from app Bug: 254783214 Test: https://recall.googleplex.com/projects/3388b17c-d22f-46f8-b140-a102690377b4/sessions/92d385dd-bad5-49ea-a0b4-b4bf4010aabb Change-Id: I74ba4a9e5c5096aaf6475f9cb8f1dc30de48024d --- .../android/quickstep/RotationTouchHelper.java | 15 +++++++++++++++ .../android/launcher3/config/FeatureFlags.java | 3 +++ 2 files changed, 18 insertions(+) diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java index f8b69666fe..65a1e5697a 100644 --- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java +++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java @@ -16,8 +16,10 @@ package com.android.quickstep; import static android.view.Display.DEFAULT_DISPLAY; +import static android.view.InputDevice.SOURCE_TOUCHSCREEN; import static android.view.Surface.ROTATION_0; +import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE; import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN; import static com.android.launcher3.util.DisplayController.CHANGE_ALL; import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE; @@ -232,6 +234,9 @@ public class RotationTouchHelper implements DisplayInfoChangeListener { * @return whether the coordinates of the {@param event} is in the swipe up gesture region. */ public boolean isInSwipeUpTouchRegion(MotionEvent event) { + if (isTrackpadMotionEvent(event)) { + return true; + } return mOrientationTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()); } @@ -240,10 +245,20 @@ public class RotationTouchHelper implements DisplayInfoChangeListener { * is in the swipe up gesture region. */ public boolean isInSwipeUpTouchRegion(MotionEvent event, int pointerIndex) { + if (isTrackpadMotionEvent(event)) { + return true; + } return mOrientationTouchTransformer.touchInValidSwipeRegions(event.getX(pointerIndex), event.getY(pointerIndex)); } + private boolean isTrackpadMotionEvent(MotionEvent event) { + // TODO: ideally should use event.getClassification(), but currently only the move + // events get assigned the correct classification. + return ENABLE_TRACKPAD_GESTURE.get() + && (event.getSource() & SOURCE_TOUCHSCREEN) != SOURCE_TOUCHSCREEN; + } + @Override public void onDisplayInfoChanged(Context context, Info info, int flags) { onDisplayInfoChangedInternal(info, flags, false); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 05ba32a48c..4170e97c9e 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -308,6 +308,9 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag( "ENABLE_TRANSIENT_TASKBAR", false, "Enables transient taskbar."); + public static final BooleanFlag ENABLE_TRACKPAD_GESTURE = getDebugFlag( + "ENABLE_TRACKPAD_GESTURE", false, "Enables trackpad gesture."); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) {