summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-04-27 18:12:05 -0700
committerAdam Cohen <adamcohen@google.com>2012-04-30 12:07:19 -0700
commita897f397e553826f327d853d5728d0e1d24513a6 (patch)
treee556011a6aea99fa19cdcf8ee2cae3587d01c037 /src/com/android/launcher2/Workspace.java
parent21fadeaad1f5a662df425085551c6f54e8c28f52 (diff)
downloadandroid_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/Workspace.java')
-rw-r--r--src/com/android/launcher2/Workspace.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index e9dffc5ec..b6378a740 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();