From a501d49a6a8b684bc83aa6b536f43247d75bacdf Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 3 Nov 2015 18:05:01 -0800 Subject: Add appropriate (tiny) offset to widget drops so they land correctly. Also removed some unused parameters I found on the way. Bug: 25191623 Change-Id: Ib9a30db106467c114cc8b54a5b13ed3e88162d56 --- src/com/android/launcher3/CellLayout.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/com/android/launcher3/CellLayout.java') diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 0a2a01728..94e3e4141 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -902,9 +902,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { ((LayoutParams) mShortcutsAndWidgets.getChildAt(0).getLayoutParams()).isFullscreen; int left = getPaddingLeft(); if (!isFullscreen) { - int offset = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - - (mCountX * mCellWidth); - left += (int) Math.ceil(offset / 2f); + left += (int) Math.ceil(getUnusedHorizontalSpace() / 2f); } int top = getPaddingTop(); @@ -916,6 +914,15 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { top + b - t); } + /** + * Returns the amount of space left over after subtracting padding and cells. This space will be + * very small, a few pixels at most, and is a result of rounding down when calculating the cell + * width in {@link DeviceProfile#calculateCellWidth(int, int)}. + */ + public int getUnusedHorizontalSpace() { + return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth); + } + @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); @@ -1048,8 +1055,8 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { return false; } - void visualizeDropLocation(View v, Bitmap dragOutline, int originX, int originY, int cellX, - int cellY, int spanX, int spanY, boolean resize, DropTarget.DragObject dragObject) { + void visualizeDropLocation(View v, Bitmap dragOutline, int cellX, int cellY, int spanX, + int spanY, boolean resize, DropTarget.DragObject dragObject) { final int oldDragCellX = mDragCell[0]; final int oldDragCellY = mDragCell[1]; -- cgit v1.2.3