feat: Promote icon swipe gesture to stable (#6821)

* fix: Reimplement and only handle touch target on configured app

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>

* feat: Promote to stable

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>

* fix: Prevent app icons from conflicting with edit mode state

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>

* fix: Address reviewer

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>

* refactor: Make icon swipe settings enable by mandatory default

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>

---------

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
Pun Butrach authored and GitHub committed 2026-06-09 12:26:14 +07:00
1 parent b9da6f57c8
commit 8e75b4bd73
9 files changed
+290 -69

No files matched your search

@@ -254,6 +254,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
private final PreferenceManager2 pref2;
private IconGestureListener mGestureListener;
private boolean mShouldHandleIconSwipeTouch; // Lawnchair: Icon swipe gesture feature
public BubbleTextView(Context context) {
this(context, null, 0);
@@ -379,6 +380,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
setTranslationY(0);
setMaxLines(1);
setVisibility(VISIBLE);
// Lawnchair: Icon swipe gesture feature
mGestureListener = null;
mShouldHandleIconSwipeTouch = false;
}
private void cancelDotScaleAnim() {
@@ -498,6 +503,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
protected void setItemInfo(ItemInfoWithIcon itemInfo) {
setTag(itemInfo);
// Lawnchair: Icon swipe gesture feature
mGestureListener = shouldSupportIconSwipeGestures()
? new IconGestureListener(getContext(), pref2, itemInfo.getComponentKey())
: null;
}
@VisibleForTesting
@@ -687,6 +696,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
&& shouldIgnoreTouchDown(event.getX(), event.getY())) {
return false;
}
// Lawnchair: Icon swipe gesture feature
if (handleIconSwipeTouchEvent(event)) {
return true;
}
if (isLongClickable()) {
super.onTouchEvent(event);
mLongPressHelper.onTouchEvent(event);
@@ -711,6 +724,72 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|| x > getWidth() - getPaddingRight();
}
/** Lawnchair: Handle icon swipe gesture feature, self-explanatory.
* Only do horizontal gesture at the moment
* @param event The type of MotionEvent to handle */
private boolean handleIconSwipeTouchEvent(MotionEvent event) {
if (!shouldSupportIconSwipeGestures()) {
return false;
}
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
mShouldHandleIconSwipeTouch = hasConfiguredIconSwipeGesture();
}
if (!mShouldHandleIconSwipeTouch || mGestureListener == null) {
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
mShouldHandleIconSwipeTouch = false;
}
return false;
}
boolean handled = mGestureListener.onTouchEvent(event);
if (handled) {
cancelLongPress();
MotionEvent cancelEvent = MotionEvent.obtain(event);
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
super.onTouchEvent(cancelEvent);
mLongPressHelper.onTouchEvent(cancelEvent);
cancelEvent.recycle();
setPressed(false);
refreshDrawableState();
mShouldHandleIconSwipeTouch = false;
return true;
}
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
mShouldHandleIconSwipeTouch = false;
}
return false;
}
/** Lawnchair: Check eligibility for icon swipe gesture to be greenlit */
private boolean isIconSwipeGestureEnabledForCurrentState() {
return !(mActivity instanceof Launcher launcher
&& launcher.isInState(LauncherState.EDIT_MODE));
}
/** Lawnchair: Check if icon swipe feature is enabled, and has a gesture configured for it */
public boolean hasConfiguredIconSwipeGesture() {
return mGestureListener != null
&& isIconSwipeGestureEnabledForCurrentState()
&& mGestureListener.hasAnyGestureConfigured();
}
/** Lawnchair: Check if icon swipe feature is enabled,
* and has a horizontal gesture configured for it */
public boolean hasConfiguredHorizontalIconSwipeGesture() {
return mGestureListener != null
&& isIconSwipeGestureEnabledForCurrentState()
&& mGestureListener.hasHorizontalGestureConfigured();
}
/** Lawnchair: Get supported swipe target which are within workspace or within folder */
private boolean shouldSupportIconSwipeGestures() {
return mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER;
}
void setStayPressed(boolean stayPressed) {
mStayPressed = stayPressed;
refreshDrawableState();