feat: Vertical icon swipe gesture (#6958)
Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
1 parent
5e053164b7
commit
1e240d94e4
7 files changed
+58
-4
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
+9
@@ -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) {
|
||||
|
||||
+12
@@ -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 || (
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1199,8 +1199,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
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<T extends View & PageIndicator> extends PagedView<T>
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in new issue
Block a user