summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CellLayout.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/CellLayout.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/CellLayout.java')
-rw-r--r--src/com/android/launcher2/CellLayout.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 24e4047eb..2772d5c66 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -146,6 +146,9 @@ public class CellLayout extends ViewGroup {
private static final boolean DESTRUCTIVE_REORDER = false;
private static final boolean DEBUG_VISUALIZE_OCCUPIED = false;
+ static final int LANDSCAPE = 0;
+ static final int PORTRAIT = 1;
+
private static final float REORDER_HINT_MAGNITUDE = 0.27f;
private static final int REORDER_ANIMATION_DURATION = 150;
private float mReorderHintAnimationMagnitude;
@@ -910,11 +913,10 @@ public class CellLayout extends ViewGroup {
return r;
}
- final int LANDSCAPE = 0;
- final int PORTRAIT = 1;
- void getCellLayoutMetrics(int measureWidth, int measureHeight, int orientation, Rect metrics) {
- int numWidthGaps = mCountX - 1;
- int numHeightGaps = mCountY - 1;
+ static void getMetrics(Rect metrics, Resources res, int measureWidth, int measureHeight,
+ int countX, int countY, int orientation) {
+ int numWidthGaps = countX - 1;
+ int numHeightGaps = countY - 1;
int widthGap;
int heightGap;
@@ -925,7 +927,7 @@ public class CellLayout extends ViewGroup {
int paddingTop;
int paddingBottom;
- Resources res = getContext().getResources();
+ int maxGap = res.getDimensionPixelSize(R.dimen.workspace_max_gap);
if (orientation == LANDSCAPE) {
cellWidth = res.getDimensionPixelSize(R.dimen.workspace_cell_width_land);
cellHeight = res.getDimensionPixelSize(R.dimen.workspace_cell_height_land);
@@ -950,18 +952,16 @@ public class CellLayout extends ViewGroup {
if (widthGap < 0 || heightGap < 0) {
int hSpace = measureWidth - paddingLeft - paddingRight;
int vSpace = measureHeight - paddingTop - paddingBottom;
- int hFreeSpace = hSpace - (mCountX * cellWidth);
- int vFreeSpace = vSpace - (mCountY * cellHeight);
- widthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
- heightGap = Math.min(mMaxGap, numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
+ int hFreeSpace = hSpace - (countX * cellWidth);
+ int vFreeSpace = vSpace - (countY * cellHeight);
+ widthGap = Math.min(maxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
+ heightGap = Math.min(maxGap, numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
}
metrics.set(cellWidth, cellHeight, widthGap, heightGap);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- // TODO: currently ignoring padding
-
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);