diff --git a/lawnchair/src/app/lawnchair/gestures/IconGestureListener.kt b/lawnchair/src/app/lawnchair/gestures/IconGestureListener.kt index df4852cdab..129ec7bf31 100644 --- a/lawnchair/src/app/lawnchair/gestures/IconGestureListener.kt +++ b/lawnchair/src/app/lawnchair/gestures/IconGestureListener.kt @@ -33,6 +33,12 @@ class IconGestureListener( hasGestureConfigured(GestureType.SWIPE_RIGHT) } + /** Check if there's a vertical gesture configured for this entry. (Swipe up/down) */ + fun hasVerticalGestureConfigured(): Boolean { + return hasGestureConfigured(GestureType.SWIPE_UP) || + hasGestureConfigured(GestureType.SWIPE_DOWN) + } + /** Check if there's a specific gesture configured for this entry * @param gestureType The type of gesture to check */ private fun hasGestureConfigured(gestureType: GestureType): Boolean { diff --git a/lawnchair/src/app/lawnchair/gestures/VerticalSwipeTouchController.kt b/lawnchair/src/app/lawnchair/gestures/VerticalSwipeTouchController.kt index c71927cf10..50eefe838c 100644 --- a/lawnchair/src/app/lawnchair/gestures/VerticalSwipeTouchController.kt +++ b/lawnchair/src/app/lawnchair/gestures/VerticalSwipeTouchController.kt @@ -81,6 +81,15 @@ class VerticalSwipeTouchController( if ((ev.edgeFlags and Utilities.EDGE_NAV_BAR) != 0) { return false } + // LC: Icon Swipe Gestures (For vertical gestures) + val isIconSwipe = launcher.workspace?.let { + val coord = floatArrayOf(ev.x, ev.y) + launcher.dragLayer.mapCoordInSelfToDescendant(it, coord) + it.isTouchOnIconWithSwipeGesture(coord[0], coord[1], true) + } ?: false + if (isIconSwipe) { + return false + } return AbstractFloatingView.getTopOpenView(launcher) == null && launcher.isInState(LauncherState.NORMAL) } diff --git a/lawnchair/src/app/lawnchair/override/CustomizeDialog.kt b/lawnchair/src/app/lawnchair/override/CustomizeDialog.kt index 6c5098a128..7fe71b7b08 100644 --- a/lawnchair/src/app/lawnchair/override/CustomizeDialog.kt +++ b/lawnchair/src/app/lawnchair/override/CustomizeDialog.kt @@ -196,6 +196,8 @@ fun CustomizeAppDialog( if (context.launcher.stateManager.state != LauncherState.ALL_APPS) { PreferenceGroup(heading = stringResource(R.string.gestures_label)) { listOf( + GestureType.SWIPE_UP, + GestureType.SWIPE_DOWN, GestureType.SWIPE_LEFT, GestureType.SWIPE_RIGHT, ).map { gestureType -> diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index 22055821fa..60ce3fdd60 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -58,6 +58,15 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr @Override protected boolean canInterceptTouch(MotionEvent ev) { + // Lawnchair: Icon Swipe Gestures (For vertical up gestures) + if (mLauncher.getWorkspace() != null && mLauncher.getDragLayer() != null) { + float[] coord = new float[]{ev.getX(), ev.getY()}; + mLauncher.getDragLayer().mapCoordInSelfToDescendant(mLauncher.getWorkspace(), coord); + if (mLauncher.getWorkspace() + .isTouchOnIconWithSwipeGesture(coord[0], coord[1], true)) { + return false; + } + } // If we are swiping to all apps instead of overview, allow it from anywhere. boolean interceptAnywhere = mLauncher.isInState(NORMAL); if (mCurrentAnimation != null) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java index e07e27d148..f9532b3711 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java @@ -39,6 +39,7 @@ import android.view.WindowManager; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Launcher; import com.android.launcher3.Utilities; import com.android.launcher3.util.MSDLPlayerWrapper; import com.android.launcher3.util.TouchController; @@ -209,6 +210,17 @@ public class StatusBarTouchController implements TouchController { } private boolean canInterceptTouch(MotionEvent ev) { + // Lawnchair: Icon Swipe Gestures (For vertical down gestures) + if (mLauncher instanceof Launcher launcher) { + if (launcher.getWorkspace() != null && launcher.getDragLayer() != null) { + float[] coord = new float[]{ev.getX(), ev.getY()}; + launcher.getDragLayer().mapCoordInSelfToDescendant(launcher.getWorkspace(), coord); + if (launcher.getWorkspace() + .isTouchOnIconWithSwipeGesture(coord[0], coord[1], true)) { + return false; + } + } + } if (isTrackpadScroll(ev) || !mIsEnabledCheck.get() || AbstractFloatingView.getTopOpenViewWithType(mLauncher, AbstractFloatingView.TYPE_STATUS_BAR_SWIPE_DOWN_DISALLOW) != null || ( diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 97b4d6b0c6..d8a14fabdb 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -785,6 +785,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, && mGestureListener.hasHorizontalGestureConfigured(); } + /** Lawnchair: Check if icon swipe feature is enabled, + * and has a vertical gesture configured for it */ + public boolean hasConfiguredVerticalIconSwipeGesture() { + return mGestureListener != null + && isIconSwipeGestureEnabledForCurrentState() + && mGestureListener.hasVerticalGestureConfigured(); + } + /** Lawnchair: Get supported swipe target which are within workspace or within folder */ private boolean shouldSupportIconSwipeGestures() { return mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 1635c9ea05..b587d4d57e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1199,8 +1199,8 @@ public class Workspace extends PagedView private boolean shouldSkipPagedViewInterceptionForIconSwipe(MotionEvent ev) { switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: - mDisallowPagedViewInterceptForIconSwipe = isTouchOnIconWithHorizontalSwipeGesture( - ev.getX(), ev.getY()); + mDisallowPagedViewInterceptForIconSwipe = isTouchOnIconWithSwipeGesture( + ev.getX(), ev.getY(), false); if (mDisallowPagedViewInterceptForIconSwipe) { resetTouchState(); return true; @@ -1225,9 +1225,17 @@ public class Workspace extends PagedView } // Lawnchair: Icon swipe gesture feature - private boolean isTouchOnIconWithHorizontalSwipeGesture(float x, float y) { + public boolean isTouchOnIconWithSwipeGesture(float x, float y, boolean vertical) { + boolean hasConfiguredIconSwipeGesture = false; BubbleTextView touchedIcon = findIconAtPosition(x, y); - return touchedIcon != null && touchedIcon.hasConfiguredHorizontalIconSwipeGesture(); + if (touchedIcon != null) { + if (vertical) { + hasConfiguredIconSwipeGesture = touchedIcon.hasConfiguredVerticalIconSwipeGesture(); + } else { + hasConfiguredIconSwipeGesture = touchedIcon.hasConfiguredHorizontalIconSwipeGesture(); + } + } + return hasConfiguredIconSwipeGesture; } // Lawnchair: Icon swipe gesture feature