diff options
author | Adam Cohen <adamcohen@google.com> | 2012-04-27 18:12:05 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-04-30 12:07:19 -0700 |
commit | a897f397e553826f327d853d5728d0e1d24513a6 (patch) | |
tree | e556011a6aea99fa19cdcf8ee2cae3587d01c037 /src/com/android/launcher2/AppWidgetResizeFrame.java | |
parent | 21fadeaad1f5a662df425085551c6f54e8c28f52 (diff) | |
download | android_packages_apps_Trebuchet-a897f397e553826f327d853d5728d0e1d24513a6.tar.gz android_packages_apps_Trebuchet-a897f397e553826f327d853d5728d0e1d24513a6.tar.bz2 android_packages_apps_Trebuchet-a897f397e553826f327d853d5728d0e1d24513a6.zip |
Making launcher update widgets with min/max extents
Change-Id: Iba9325eeb95a8a8256ef6f59f4010aff09767892
Diffstat (limited to 'src/com/android/launcher2/AppWidgetResizeFrame.java')
-rw-r--r-- | src/com/android/launcher2/AppWidgetResizeFrame.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java index 9df6f3214..7281a6fbb 100644 --- a/src/com/android/launcher2/AppWidgetResizeFrame.java +++ b/src/com/android/launcher2/AppWidgetResizeFrame.java @@ -307,11 +307,38 @@ public class AppWidgetResizeFrame extends FrameLayout { lp.cellVSpan = spanY; mRunningVInc += vSpanDelta; mRunningHInc += hSpanDelta; + if (!onDismiss) { + updateWidgetSizeRanges(mWidgetView, mLauncher, spanX, spanY); + } } - mWidgetView.requestLayout(); } + static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, + int spanX, int spanY) { + Rect landMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.LANDSCAPE); + Rect portMetrics = Workspace.getCellLayoutMetrics(launcher, CellLayout.PORTRAIT); + final float density = launcher.getResources().getDisplayMetrics().density; + + // Compute landscape size + int cellWidth = landMetrics.left; + int cellHeight = landMetrics.top; + int widthGap = landMetrics.right; + int heightGap = landMetrics.bottom; + int landWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density); + int landHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density); + + // Compute portrait size + cellWidth = portMetrics.left; + cellHeight = portMetrics.top; + widthGap = portMetrics.right; + heightGap = portMetrics.bottom; + int portWidth = (int) ((spanX * cellWidth + (spanX - 1) * widthGap) / density); + int portHeight = (int) ((spanY * cellHeight + (spanY - 1) * heightGap) / density); + + widgetView.updateAppWidgetSize(null, portWidth, landHeight, landWidth, portHeight); + } + /** * This is the final step of the resize. Here we save the new widget size and position * to LauncherModel and animate the resize frame. |