Setting tab bar widths automatically

- will make launcher adapt better to different screen sizes
- also, moved customization tray tab setup code from Launcher to CustomizeTrayTabHost

Change-Id: I27a1acdacd231150bf191548d155c0e94d855796
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index b9b38c3..87d255e 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -65,6 +65,7 @@
     private final LayoutInflater mInflater;
     private boolean mAllowHardwareLayerCreation;
 
+    private int mPageContentWidth;
 
     public AllAppsPagedView(Context context) {
         this(context, null);
@@ -88,6 +89,11 @@
         Resources r = context.getResources();
         setDragSlopeThreshold(
                 r.getInteger(R.integer.config_allAppsDrawerDragSlopeThreshold) / 100.0f);
+
+        // 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();
     }
 
     @Override
@@ -318,6 +324,10 @@
         mLauncher.unlockScreenOrientation();
     }
 
+    int getPageContentWidth() {
+        return mPageContentWidth;
+    }
+
     @Override
     public boolean isVisible() {
         return mZoom > 0.001f;
@@ -440,6 +450,13 @@
         // do nothing?
     }
 
+    private void setupPage(PagedViewCellLayout layout) {
+        layout.setCellCount(mCellCountX, mCellCountY);
+        layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, mPageLayoutPaddingRight,
+                mPageLayoutPaddingBottom);
+        layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
+    }
+
     @Override
     public void syncPages() {
         // ensure that we have the right number of pages (min of 1, since we have placeholders)
@@ -449,7 +466,6 @@
         // remove any extra pages after the "last" page
         int extraPageDiff = curNumPages - numPages;
         for (int i = 0; i < extraPageDiff; ++i) {
-            PagedViewCellLayout page = (PagedViewCellLayout) getChildAt(numPages);
             removeViewAt(numPages);
         }
         // add any necessary pages
@@ -458,10 +474,7 @@
             if (mAllowHardwareLayerCreation) {
                 layout.allowHardwareLayerCreation();
             }
-            layout.setCellCount(mCellCountX, mCellCountY);
-            layout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop,
-                    mPageLayoutPaddingRight, mPageLayoutPaddingBottom);
-            layout.setGap(mPageLayoutWidthGap, mPageLayoutHeightGap);
+            setupPage(layout);
             addView(layout);
         }