summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon Miranda <jonmiranda@google.com>2016-12-12 15:43:18 -0800
committerJon Miranda <jonmiranda@google.com>2016-12-13 08:53:57 -0800
commit26e4d17a73bc4857d3ae5ddb9858cbea6ed9782a (patch)
treefb10afe7a89c44bdd02fc794ffb0259efb57dae7 /src
parent824c540f1911101321ebe7f05cb0885a4922e363 (diff)
downloadandroid_packages_apps_Trebuchet-26e4d17a73bc4857d3ae5ddb9858cbea6ed9782a.tar.gz
android_packages_apps_Trebuchet-26e4d17a73bc4857d3ae5ddb9858cbea6ed9782a.tar.bz2
android_packages_apps_Trebuchet-26e4d17a73bc4857d3ae5ddb9858cbea6ed9782a.zip
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
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;