Differentiating max widget cell count and max wallpaper cell count in customization drawer.

Change-Id: Ic649f185f9a294af38ed224e9dbb7530e7cbf29a
diff --git a/res/layout-xlarge-land/customization_drawer.xml b/res/layout-xlarge-land/customization_drawer.xml
index 3fff2b0..9d088f2 100644
--- a/res/layout-xlarge-land/customization_drawer.xml
+++ b/res/layout-xlarge-land/customization_drawer.xml
@@ -20,6 +20,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     launcher:wallpaperCellSpanX="3"
+    launcher:wallpaperCellCountX="12"
     launcher:widgetCellCountX="16"
     launcher:cellCountX="8"
     launcher:cellCountY="3"
diff --git a/res/layout-xlarge-port/customization_drawer.xml b/res/layout-xlarge-port/customization_drawer.xml
index d90f3ca..a1bc7cc 100644
--- a/res/layout-xlarge-port/customization_drawer.xml
+++ b/res/layout-xlarge-port/customization_drawer.xml
@@ -20,7 +20,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     launcher:wallpaperCellSpanX="3"
-    launcher:widgetCellCountX="9"
+    launcher:wallpaperCellCountX="9"
+    launcher:widgetCellCountX="10"
     launcher:cellCountX="5"
     launcher:cellCountY="3"
     launcher:pageLayoutWidthGap="36dp"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 853d49e..3373869 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -107,6 +107,8 @@
     <declare-styleable name="CustomizePagedView">
         <!-- The cell span of an item in the wallpapers tab -->
         <attr name="wallpaperCellSpanX" format="integer" />
+        <!-- The max cell span of all items in a particular wallpaper tab page -->
+        <attr name="wallpaperCellCountX" format="integer" />
         <!-- The number of horizontal cells for the widget tab -->
         <attr name="widgetCellCountX" format="integer" />
     </declare-styleable>
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 342974a..799e017 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -103,6 +103,9 @@
     // The size of the items on the wallpaper tab
     private int mWallpaperCellHSpan;
 
+    // The max number of wallpaper cells to take a "page" of wallpaper items
+    private int mMaxWallpaperCellHSpan;
+
     // The raw sources of data for each of the different tabs of the customization page
     private List<AppWidgetProviderInfo> mWidgetList;
     private List<ResolveInfo> mShortcutList;
@@ -140,6 +143,7 @@
         TypedArray a;
         a = context.obtainStyledAttributes(attrs, R.styleable.CustomizePagedView, defStyle, 0);
         mWallpaperCellHSpan = a.getInt(R.styleable.CustomizePagedView_wallpaperCellSpanX, 4);
+        mMaxWallpaperCellHSpan = a.getInt(R.styleable.CustomizePagedView_wallpaperCellCountX, 8);
         mMaxWidgetsCellHSpan = a.getInt(R.styleable.CustomizePagedView_widgetCellCountX, 8);
         a.recycle();
         a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, defStyle, 0);
@@ -926,7 +930,7 @@
         // We need to repopulate the LinearLayout for the wallpaper pages
         removeAllViews();
         int numPages = (int) Math.ceil((float) (mWallpaperList.size() * mWallpaperCellHSpan) /
-                mMaxWidgetsCellHSpan);
+                mMaxWallpaperCellHSpan);
         for (int i = 0; i < numPages; ++i) {
             LinearLayout layout = new PagedViewExtendedLayout(getContext());
             layout.setGravity(Gravity.CENTER_HORIZONTAL);
@@ -944,7 +948,7 @@
         LinearLayout layout = (LinearLayout) getChildAt(page);
         layout.removeAllViews();
         final int count = mWallpaperList.size();
-        final int numItemsPerPage = mMaxWidgetsCellHSpan / mWallpaperCellHSpan;
+        final int numItemsPerPage = mMaxWallpaperCellHSpan / mWallpaperCellHSpan;
         final int startIndex = page * numItemsPerPage;
         final int endIndex = Math.min(count, startIndex + numItemsPerPage);
         for (int i = startIndex; i < endIndex; ++i) {