From 26e4d17a73bc4857d3ae5ddb9858cbea6ed9782a Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 12 Dec 2016 15:43:18 -0800 Subject: Resize widget frame now wraps the scaled widget view. Previous implementation had space between the frame and the widget ie. letterboxing. Bug: 32176631 Change-Id: Ie50279f4edb94812120dea492aefa4f18218162f --- src/com/android/launcher3/AppWidgetResizeFrame.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') 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; -- cgit v1.2.3