Making launcher update widgets with min/max extents

Change-Id: Iba9325eeb95a8a8256ef6f59f4010aff09767892
This commit is contained in:
Adam Cohen
2012-04-27 18:12:05 -07:00
parent 21fadeaad1
commit a897f397e5
4 changed files with 83 additions and 13 deletions

View File

@@ -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.