feat: add tilt to swipe pages for home screen rearrangement and fix app drawer gap (#7500)

* feat and fix : Add Tilt to swipe pages setting

Replace the multi-level Motion controls with a single Home screen toggle named “Tilt to swipe pages,” positioned below Infinite scrolling. Update the description to explain that tilting the phone moves between pages while rearranging apps or widgets, and make the pan controller use the toggle directly while retaining the existing preference key for compatibility. Fix for "[BUG] Large empty gap between app drawer search bar and app grid when app suggestions are disabled
 #7490"

* EDITS : Coderabbit suggested edits for PR #7500

* Coderabbit suggested changes (2) #7500

* Update gradle-daemon-jvm.properties

* Remove unrelated Gradle toolchain changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add docstrings for pan-to-move and all apps header changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add a tilt sensitivity control

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
B Vishal ChandrakanthandCopilot authored and GitHub committed 2026-11-09 20:59:50 +08:00
1 parent d180feb55f
commit ce82ac1248
9 files changed
+299 -7

No files matched your search

+25
View File
@@ -147,6 +147,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import app.lawnchair.hotseat.HotseatPagedView;
import app.lawnchair.gestures.PanToMoveController;
import app.lawnchair.preferences2.PreferenceCacheExtensionsKt;
import static app.lawnchair.util.LawnchairUtilsKt.toBitmap;
import app.lawnchair.LawnchairApp;
@@ -338,6 +339,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
private DragController.DragListener mAccessibilityDragListener;
PreferenceManager2 mPreferenceManager2;
private PanToMoveController mPanToMoveController;
PreferenceManager mPreferenceManger;
/**
@@ -364,6 +366,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mWallpaperManager = WallpaperManager.getInstance(context);
mAllAppsIconSize = mLauncher.getDeviceProfile().getAllAppsProfile().getIconSizePx();
mPreferenceManager2 = PreferenceManager2.getInstance(context);
mPanToMoveController = new PanToMoveController(context, this);
mPreferenceManger = PreferenceManager.getInstance(context);
mWallpaperOffset = new WallpaperOffsetInterpolator(this);
@@ -509,6 +512,10 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
return r;
}
/**
* Starts workspace drag handling and motion sensing, except for accessibility drags confined
* to a folder.
*/
@Override
public void onDragStart(DragObject dragObject, DragOptions options) {
if (ENFORCE_DRAG_EVENT_ORDER) {
@@ -557,6 +564,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
if (mAccessibilityDragListener != null) {
mAccessibilityDragListener.onDragStart(dragObject, options);
}
if (!(options.isAccessibleDrag && dragObject.dragSource instanceof Folder)) {
mPanToMoveController.onDragStarted();
}
if (!mLauncher.isInState(EDIT_MODE)) {
mLauncher.getStateManager().goToState(SPRING_LOADED);
}
@@ -573,6 +583,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mDeferRemoveExtraEmptyScreen = true;
}
/**
* Ends workspace drag handling and unregisters motion sensors before clearing drag state.
*/
@Override
public void onDragEnd() {
if (ENFORCE_DRAG_EVENT_ORDER) {
@@ -596,6 +609,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
if (mAccessibilityDragListener != null) {
mAccessibilityDragListener.onDragEnd();
}
mPanToMoveController.onDragEnded();
mDragInfo = null;
mDragSourceInternal = null;
}
@@ -1672,8 +1686,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mLauncher.getStateManager().addStateListener(mAccessibilityDropListener);
}
/**
* Detaches the workspace and ensures motion sensors are unregistered with the view.
*/
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mPanToMoveController.onDragEnded();
mWallpaperOffset.setWindowToken(null);
mLauncher.getStateManager().removeStateListener(mAccessibilityDropListener);
}
@@ -2245,8 +2263,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Override
public void prepareAccessibilityDrop() {}
/**
* Stops motion sensing before processing the final drop on the workspace.
*/
@Override
public void onDrop(final DragObject d, DragOptions options) {
mPanToMoveController.onDragEnded();
mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter);
CellLayout dropTargetLayout = mDropToLayout;
@@ -2841,6 +2863,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
if (layout == null) {
// Check visible pages
IntSet visiblePageIndices = getVisiblePageIndices();
if (isPageInTransition()) {
visiblePageIndices.add(getNextPage());
}
for (int visiblePageIndex : visiblePageIndices) {
layout = verifyInsidePage(visiblePageIndex, d.x, d.y);
if (layout != null) break;