feat : initial implementation icon gesture support (#5266)

- closes : #2787
- closes : #5259
This commit is contained in:
John Andrew Camu
2025-02-17 11:45:04 +08:00
committed by GitHub
parent 0ab1dee1c6
commit 2623e42dad
10 changed files with 297 additions and 35 deletions
+39
View File
@@ -146,6 +146,7 @@ import app.lawnchair.LawnchairApp;
import app.lawnchair.LawnchairAppKt;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.preferences2.PreferenceManager2;
import app.lawnchair.smartspace.DoubleShadowTextView;
import app.lawnchair.smartspace.SmartspaceAppWidgetProvider;
import app.lawnchair.smartspace.model.LawnchairSmartspace;
import app.lawnchair.smartspace.model.SmartspaceMode;
@@ -1205,12 +1206,50 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
View touchedView = findViewAtPosition(ev.getX(), ev.getY());
if (touchedView instanceof ShortcutAndWidgetContainer container) {
container.onTouchEvent(ev);
return false;
}
}
if (isTrackpadMultiFingerSwipe(ev)) {
return false;
}
return super.onInterceptTouchEvent(ev);
}
private View findViewAtPosition(float x, float y) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child instanceof CellLayout) {
CellLayout cellLayout = (CellLayout) child;
View foundView = findViewInCellLayout(cellLayout, x - child.getLeft(), y - child.getTop());
if (foundView != null) {
return foundView;
}
}
}
return null;
}
private View findViewInCellLayout(CellLayout cellLayout, float x, float y) {
final int count = cellLayout.getChildCount();
for (int i = count - 1; i >= 0; i--) {
View child = cellLayout.getChildAt(i);
if (child.getVisibility() == VISIBLE && isPointInsideView(x, y, child)) {
return child;
}
}
return null;
}
private boolean isPointInsideView(float x, float y, View view) {
return x >= view.getLeft() && x <= view.getRight() &&
y >= view.getTop() && y <= view.getBottom();
}
/**
* Needed here because launcher has a fullscreen exclusion rect and doesn't
* pilfer the pointers.