Fix issue where folder can open offscreen (issue 5291408)
Change-Id: I359dc2188c50ab1c4e42c448ecce04530ba45734
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 6f09ab5..6956044 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -728,11 +728,17 @@
int centeredLeft = centerX - width / 2;
int centeredTop = centerY - height / 2;
+ int currentPage = mLauncher.getWorkspace().getCurrentPage();
+ // In case the workspace is scrolling, we need to use the final scroll to compute
+ // the folders bounds.
+ mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage);
// We first fetch the currently visible CellLayoutChildren
- CellLayout currentPage = mLauncher.getWorkspace().getCurrentDropLayout();
- CellLayoutChildren boundingLayout = currentPage.getChildrenLayout();
+ CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage);
+ CellLayoutChildren boundingLayout = currentLayout.getChildrenLayout();
Rect bounds = new Rect();
parent.getDescendantRectRelativeToSelf(boundingLayout, bounds);
+ // We reset the workspaces scroll
+ mLauncher.getWorkspace().resetFinalScrollForPageChange(currentPage);
// We need to bound the folder to the currently visible CellLayoutChildren
int left = Math.min(Math.max(bounds.left, centeredLeft),