diff options
author | Winson <winsonc@google.com> | 2016-07-22 16:35:37 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2016-07-23 01:15:08 +0000 |
commit | fadbe8ffbd90eb36c782a76a8b1a76a26dba288e (patch) | |
tree | c614e187e4b29b1466688d58d5ac17e999d1b34e /src/com/android/launcher3/folder | |
parent | 68f98ac102a2719203883d87add6483797b516da (diff) | |
download | android_packages_apps_Trebuchet-fadbe8ffbd90eb36c782a76a8b1a76a26dba288e.tar.gz android_packages_apps_Trebuchet-fadbe8ffbd90eb36c782a76a8b1a76a26dba288e.tar.bz2 android_packages_apps_Trebuchet-fadbe8ffbd90eb36c782a76a8b1a76a26dba288e.zip |
Fixing regression in folder positioning.
- When we had the search bar, the workspace padding always
accounted for the search bar (and therefor drop target bar) height
when the folder opened. Now that there is no padding on the top, we
should offset the bar whenever possible to ensure that the drop target
bar is visible.
Bug: 30110595
Change-Id: Ia9a8581981c777f2507b6bd880994a3dcfd52c39
Diffstat (limited to 'src/com/android/launcher3/folder')
-rw-r--r-- | src/com/android/launcher3/folder/Folder.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 2fbbad56d..fdbb21430 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -1030,27 +1030,25 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } private void centerAboutIcon() { - DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); + DeviceProfile grid = mLauncher.getDeviceProfile(); + DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getFolderHeight(); float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, sTempRect); - - DeviceProfile grid = mLauncher.getDeviceProfile(); - - int centerX = (int) (sTempRect.left + sTempRect.width() * scale / 2); - int centerY = (int) (sTempRect.top + sTempRect.height() * scale / 2); + int centerX = sTempRect.centerX(); + int centerY = sTempRect.centerY(); int centeredLeft = centerX - width / 2; int centeredTop = centerY - height / 2; // We need to bound the folder to the currently visible workspace area mLauncher.getWorkspace().getPageAreaRelativeToDragLayer(sTempRect); int left = Math.min(Math.max(sTempRect.left, centeredLeft), - sTempRect.left + sTempRect.width() - width); + sTempRect.right- width); int top = Math.min(Math.max(sTempRect.top, centeredTop), - sTempRect.top + sTempRect.height() - height); + sTempRect.bottom - height); int distFromEdgeOfScreen = mLauncher.getWorkspace().getPaddingLeft() + getPaddingLeft(); @@ -1064,7 +1062,14 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList left = sTempRect.left + (sTempRect.width() - width) / 2; } if (height >= sTempRect.height()) { + // Folder height is greater than page height, center on page top = sTempRect.top + (sTempRect.height() - height) / 2; + } else { + // Folder height is less than page height, so bound it to the absolute open folder + // bounds if necessary + Rect folderBounds = grid.getAbsoluteOpenFolderBounds(); + left = Math.max(folderBounds.left, Math.min(left, folderBounds.right - width)); + top = Math.max(folderBounds.top, Math.min(top, folderBounds.bottom - height)); } int folderPivotX = width / 2 + (centeredLeft - left); |