diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 16 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedViewCellLayout.java | 13 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 9000049d1..6667f7cc1 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -207,6 +207,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Dimens private int mContentWidth; private int mAppIconSize; + private int mMaxAppCellCountX, mMaxAppCellCountY; private int mWidgetCountX, mWidgetCountY; private int mWidgetWidthGap, mWidgetHeightGap; private final int mWidgetPreviewIconPaddedDimension; @@ -247,12 +248,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size); mDragViewMultiplyColor = resources.getColor(R.color.drag_view_multiply_color); - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, 0, 0); - // TODO-APPS_CUSTOMIZE: remove these unnecessary attrs after - mCellCountX = a.getInt(R.styleable.PagedView_cellCountX, 6); - mCellCountY = a.getInt(R.styleable.PagedView_cellCountY, 4); - a.recycle(); - a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0); + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0); + mMaxAppCellCountX = a.getInt(R.styleable.AppsCustomizePagedView_maxAppCellCountX, -1); + mMaxAppCellCountY = a.getInt(R.styleable.AppsCustomizePagedView_maxAppCellCountY, -1); mWidgetWidthGap = a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 0); mWidgetHeightGap = @@ -373,6 +371,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen maxCellCountY = (isLandscape ? LauncherModel.getCellCountY() : LauncherModel.getCellCountX()); } + if (mMaxAppCellCountX > -1) { + maxCellCountX = Math.min(maxCellCountX, mMaxAppCellCountX); + } + if (mMaxAppCellCountY > -1) { + maxCellCountY = Math.min(maxCellCountY, mMaxAppCellCountY); + } // Now that the data is ready, we can calculate the content width, the number of cells to // use for each page diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java index 2ef7e296a..6266ca26f 100644 --- a/src/com/android/launcher2/PagedViewCellLayout.java +++ b/src/com/android/launcher2/PagedViewCellLayout.java @@ -69,7 +69,7 @@ public class PagedViewCellLayout extends ViewGroup implements Page { resources.getDimensionPixelSize(R.dimen.apps_customize_cell_height); mCellCountX = LauncherModel.getCellCountX(); mCellCountY = LauncherModel.getCellCountY(); - mOriginalHeightGap = mOriginalHeightGap = mWidthGap = mHeightGap = -1; + mOriginalWidthGap = mOriginalHeightGap = mWidthGap = mHeightGap = -1; mMaxGap = resources.getDimensionPixelSize(R.dimen.apps_customize_max_gap); mChildren = new PagedViewCellLayoutChildren(context); @@ -294,8 +294,8 @@ public class PagedViewCellLayout extends ViewGroup implements Page { } public void setGap(int widthGap, int heightGap) { - mWidthGap = widthGap; - mHeightGap = heightGap; + mOriginalWidthGap = mWidthGap = widthGap; + mOriginalHeightGap = mHeightGap = heightGap; mChildren.setGap(widthGap, heightGap); } @@ -325,10 +325,9 @@ public class PagedViewCellLayout extends ViewGroup implements Page { * Estimates the number of cells that the specified width would take up. */ public int estimateCellHSpan(int width) { - // The space for a page assuming that we want to show half of a column of the previous and - // next pages is the width - left padding (current & next page) - right padding (previous & - // current page) - half cell width (for previous and next pages) - int availWidth = (int) (width - (2 * mPaddingLeft + 2 * mPaddingRight)); + // We don't show the next/previous pages any more, so we use the full width, minus the + // padding + int availWidth = width - (mPaddingLeft + mPaddingRight); // We know that we have to fit N cells with N-1 width gaps, so we just juggle to solve for N int n = Math.max(1, (availWidth + mWidthGap) / (mCellWidth + mWidthGap)); |