diff options
author | Tony Wickham <twickham@google.com> | 2015-12-04 14:21:19 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-12-04 14:21:19 -0800 |
commit | 11c45f114165330ea9c895ca6fdf83fdaa2e5fad (patch) | |
tree | ad7606d0d7309af50df5bacf10cf404d6c490445 /src/com/android/launcher3/CellLayout.java | |
parent | 92b3397711a05481793ea71b7d90da8813feda7a (diff) | |
parent | 8db5d7ca60e79f007bfce7952c15c74d0ee44bc0 (diff) | |
download | android_packages_apps_Trebuchet-11c45f114165330ea9c895ca6fdf83fdaa2e5fad.tar.gz android_packages_apps_Trebuchet-11c45f114165330ea9c895ca6fdf83fdaa2e5fad.tar.bz2 android_packages_apps_Trebuchet-11c45f114165330ea9c895ca6fdf83fdaa2e5fad.zip |
Merge "Add appropriate (tiny) offset to widget drops so they land correctly." into ub-launcher3-burnaby-polish
am: 8db5d7ca60
* commit '8db5d7ca60e79f007bfce7952c15c74d0ee44bc0':
Add appropriate (tiny) offset to widget drops so they land correctly.
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r-- | src/com/android/launcher3/CellLayout.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index eb70b1362..3d3d57dbd 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -890,9 +890,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(); @@ -904,6 +902,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); @@ -1036,8 +1043,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]; |