summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index c45ff7b0c..54faca355 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -354,19 +354,18 @@ public class AppWidgetResizeFrame extends FrameLayout
}
public void snapToWidget(boolean animate) {
- final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
DeviceProfile profile = mLauncher.getDeviceProfile();
- int newWidth = (int) (mWidgetView.getWidth() * profile.appWidgetScale.x)
- + 2 * mBackgroundPadding - mWidgetPadding.left - mWidgetPadding.right;
- int newHeight = (int) (mWidgetView.getHeight() * profile.appWidgetScale.y)
- + 2 * mBackgroundPadding - mWidgetPadding.top - mWidgetPadding.bottom;
+ float scale = Math.min(profile.appWidgetScale.x, profile.appWidgetScale.y);
+
+ mDragLayer.getViewRectRelativeToSelf(mWidgetView, sTmpRect);
- mTmpPt[0] = mWidgetView.getLeft();
- mTmpPt[1] = mWidgetView.getTop();
- mDragLayer.getDescendantCoordRelativeToSelf(mCellLayout.getShortcutsAndWidgets(), mTmpPt);
+ int newWidth = 2 * mBackgroundPadding
+ + (int) (scale * (sTmpRect.width() - mWidgetPadding.left - mWidgetPadding.right));
+ int newHeight = 2 * mBackgroundPadding
+ + (int) (scale * (sTmpRect.height() - mWidgetPadding.top - mWidgetPadding.bottom));
- int newX = mTmpPt[0] - mBackgroundPadding + mWidgetPadding.left;
- int newY = mTmpPt[1] - mBackgroundPadding + mWidgetPadding.top;
+ int newX = (int) (sTmpRect.left - mBackgroundPadding + scale * mWidgetPadding.left);
+ int newY = (int) (sTmpRect.top - mBackgroundPadding + scale * mWidgetPadding.top);
// We need to make sure the frame's touchable regions lie fully within the bounds of the
// DragLayer. We allow the actual handles to be clipped, but we shift the touch regions
@@ -384,6 +383,7 @@ public class AppWidgetResizeFrame extends FrameLayout
mBottomTouchRegionAdjustment = 0;
}
+ final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
if (!animate) {
lp.width = newWidth;
lp.height = newHeight;