Merge "Making launcher update widgets with min/max extents" into jb-dev

This commit is contained in:
Adam Cohen
2012-04-30 13:21:52 -07:00
committed by Android (Google) Code Review
4 changed files with 83 additions and 13 deletions
+41
View File
@@ -122,6 +122,9 @@ public class Workspace extends SmoothPagedView
private int mDragOverX = -1;
private int mDragOverY = -1;
static Rect mLandscapeCellLayoutMetrics = null;
static Rect mPortraitCellLayoutMetrics = null;
/**
* The CellLayout that is currently being dragged over
*/
@@ -2389,6 +2392,44 @@ public class Workspace extends SmoothPagedView
}
}
static Rect getCellLayoutMetrics(Launcher launcher, int orientation) {
Resources res = launcher.getResources();
Display display = launcher.getWindowManager().getDefaultDisplay();
Point smallestSize = new Point();
Point largestSize = new Point();
display.getCurrentSizeRange(smallestSize, largestSize);
if (orientation == CellLayout.LANDSCAPE) {
if (mLandscapeCellLayoutMetrics == null) {
int paddingLeft = res.getDimensionPixelSize(R.dimen.workspace_left_padding_land);
int paddingRight = res.getDimensionPixelSize(R.dimen.workspace_right_padding_land);
int paddingTop = res.getDimensionPixelSize(R.dimen.workspace_top_padding_land);
int paddingBottom = res.getDimensionPixelSize(R.dimen.workspace_bottom_padding_land);
int width = largestSize.x - paddingLeft - paddingRight;
int height = smallestSize.y - paddingTop - paddingBottom;
mLandscapeCellLayoutMetrics = new Rect();
CellLayout.getMetrics(mLandscapeCellLayoutMetrics, res,
width, height, LauncherModel.getCellCountX(), LauncherModel.getCellCountY(),
orientation);
}
return mLandscapeCellLayoutMetrics;
} else if (orientation == CellLayout.PORTRAIT) {
if (mPortraitCellLayoutMetrics == null) {
int paddingLeft = res.getDimensionPixelSize(R.dimen.workspace_left_padding_land);
int paddingRight = res.getDimensionPixelSize(R.dimen.workspace_right_padding_land);
int paddingTop = res.getDimensionPixelSize(R.dimen.workspace_top_padding_land);
int paddingBottom = res.getDimensionPixelSize(R.dimen.workspace_bottom_padding_land);
int width = smallestSize.x - paddingLeft - paddingRight;
int height = largestSize.y - paddingTop - paddingBottom;
mPortraitCellLayoutMetrics = new Rect();
CellLayout.getMetrics(mPortraitCellLayoutMetrics, res,
width, height, LauncherModel.getCellCountX(), LauncherModel.getCellCountY(),
orientation);
}
return mPortraitCellLayoutMetrics;
}
return null;
}
public void onDragExit(DragObject d) {
mDragEnforcer.onDragExit();