diff options
author | Adam Cohen <adamcohen@google.com> | 2012-04-30 13:21:52 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-30 13:21:52 -0700 |
commit | 7d2d6b5f0972354df05249082d4179dcdc442723 (patch) | |
tree | 74369c13d4125be6420bc25396a86d555d573ffa /src/com/android/launcher2/Workspace.java | |
parent | 5347324d24936c90a1395499b4420854021e4291 (diff) | |
parent | a897f397e553826f327d853d5728d0e1d24513a6 (diff) | |
download | android_packages_apps_Trebuchet-7d2d6b5f0972354df05249082d4179dcdc442723.tar.gz android_packages_apps_Trebuchet-7d2d6b5f0972354df05249082d4179dcdc442723.tar.bz2 android_packages_apps_Trebuchet-7d2d6b5f0972354df05249082d4179dcdc442723.zip |
Merge "Making launcher update widgets with min/max extents" into jb-dev
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 84787a251..404efc2ee 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -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(); |