From d82b5817d49f0abb841a4a2c9562b6c9f9f8ebe8 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Tue, 5 Apr 2011 16:52:32 -0700 Subject: [PATCH] Setting min width of content in customize tray automatically Change-Id: Idb307dcf21422472ef098702c1bc12e99f138228 --- res/values-xlarge-land/dimens.xml | 2 -- res/values-xlarge-port/dimens.xml | 2 -- src/com/android/launcher2/CustomizePagedView.java | 2 +- src/com/android/launcher2/PagedViewCellLayout.java | 9 ++++++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/res/values-xlarge-land/dimens.xml b/res/values-xlarge-land/dimens.xml index b44a94a0d5..8d255557ed 100644 --- a/res/values-xlarge-land/dimens.xml +++ b/res/values-xlarge-land/dimens.xml @@ -27,8 +27,6 @@ 480dp 420dp - 952dp - 952dp 7 5 diff --git a/res/values-xlarge-port/dimens.xml b/res/values-xlarge-port/dimens.xml index bb410b1998..e696e3449b 100644 --- a/res/values-xlarge-port/dimens.xml +++ b/res/values-xlarge-port/dimens.xml @@ -27,8 +27,6 @@ 800dp 420dp - 640dp - 700dp 5 7 diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index 36a638bc5e..92b73a0f74 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -172,12 +172,12 @@ public class CustomizePagedView extends PagedViewWithDraggableItems final Resources r = context.getResources(); setDragSlopeThreshold( r.getInteger(R.integer.config_customizationDrawerDragSlopeThreshold) / 100.0f); - mMinPageWidth = r.getDimensionPixelSize(R.dimen.customization_drawer_content_min_width); // Create a dummy page and set it up to find out the content width (used by our parent) PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); setupPage(layout); mPageContentWidth = layout.getContentWidth(); + mMinPageWidth = layout.getWidthBeforeFirstLayout(); setVisibility(View.GONE); setSoundEffectsEnabled(false); diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java index 53657e5cbc..762ec58a56 100644 --- a/src/com/android/launcher2/PagedViewCellLayout.java +++ b/src/com/android/launcher2/PagedViewCellLayout.java @@ -247,9 +247,12 @@ public class PagedViewCellLayout extends ViewGroup implements Page { // Return the distance from the left edge of the content of the leftmost icon to // the right edge of the content of the rightmost icon - // icons are centered within cells, find out how much offset that accounts for - int iconHorizontalOffset = (mCellWidth - Utilities.getIconContentSize()); - return mCellCountX * mCellWidth + (mCellCountX - 1) * mWidthGap - iconHorizontalOffset; + // icons are centered within cells, find out how much padding that accounts for + return getWidthBeforeFirstLayout() - (mCellWidth - Utilities.getIconContentSize()); + } + + int getWidthBeforeFirstLayout() { + return mCellCountX * mCellWidth + (mCellCountX - 1) * mWidthGap; } @Override