Merge "Refactor of Launcher drag and drop to use a DragObject"
diff --git a/res/drawable-hdpi/app_market_generic.png b/res/drawable-hdpi/app_market_generic.png
index 2a2381f..117453c 100644
--- a/res/drawable-hdpi/app_market_generic.png
+++ b/res/drawable-hdpi/app_market_generic.png
Binary files differ
diff --git a/res/layout-large/customization_drawer.xml b/res/layout-large/customization_drawer.xml
index d8db066..0c59a3f 100644
--- a/res/layout-large/customization_drawer.xml
+++ b/res/layout-large/customization_drawer.xml
@@ -40,15 +40,12 @@
                 launcher:wallpaperCellSpanX="@integer/customization_drawer_contents_wallpaperCellSpanX"
                 launcher:wallpaperCellCountX="@integer/customization_drawer_contents_wallpaperCellCountX"
                 launcher:widgetCellCountX="@integer/customization_drawer_contents_widgetCellCountX"
-                launcher:cellCountX="@integer/customization_drawer_contents_cellCountX"
-                launcher:cellCountY="@integer/customization_drawer_contents_cellCountY"
                 launcher:pageLayoutWidthGap="@dimen/customization_drawer_contents_pageLayoutWidthGap"
-                launcher:pageLayoutHeightGap="12dp"
-                launcher:pageLayoutPaddingTop="40dp"
-                launcher:pageLayoutPaddingBottom="25dp"
-                launcher:pageLayoutPaddingLeft="20dp"
-                launcher:pageLayoutPaddingRight="20dp"
-                launcher:pageLayoutMaxHeight="@dimen/customization_drawer_content_height" />
+                launcher:pageLayoutHeightGap="@dimen/customization_drawer_contents_pageLayoutHeightGap"
+                launcher:pageLayoutPaddingTop="@dimen/customization_drawer_contents_pageLayoutPaddingTop"
+                launcher:pageLayoutPaddingBottom="@dimen/customization_drawer_contents_pageLayoutPaddingBottom"
+                launcher:pageLayoutPaddingLeft="@dimen/customization_drawer_contents_pageLayoutPaddingLeft"
+                launcher:pageLayoutPaddingRight="@dimen/customization_drawer_contents_pageLayoutPaddingRight" />
          </FrameLayout>
       </LinearLayout>
 </com.android.launcher2.CustomizeTrayTabHost>
\ No newline at end of file
diff --git a/res/layout-large/launcher.xml b/res/layout-large/launcher.xml
index 6a16eb5..2d14137 100644
--- a/res/layout-large/launcher.xml
+++ b/res/layout-large/launcher.xml
@@ -44,7 +44,7 @@
     <include layout="@layout/customization_drawer"
         android:id="@+id/customization_drawer"
         android:layout_width="match_parent"
-        android:layout_height="@dimen/customization_drawer_height"
+        android:layout_height="wrap_content"
         android:layout_gravity="bottom"
         android:visibility="invisible" />
 </com.android.launcher2.DragLayer>
diff --git a/res/values-large-land/dimens.xml b/res/values-large-land/dimens.xml
index 0f7e0ed..eeb16f4 100644
--- a/res/values-large-land/dimens.xml
+++ b/res/values-large-land/dimens.xml
@@ -19,9 +19,6 @@
          or right while you're dragging. -->
     <dimen name="scroll_zone">100dip</dimen>
 
-    <dimen name="customization_drawer_height">480dp</dimen>
-    <dimen name="customization_drawer_content_height">420dp</dimen>
-
     <dimen name="all_apps_view_pageLayoutWidthGap">36dp</dimen>
     <dimen name="all_apps_view_pageLayoutHeightGap">6dp</dimen>
     <dimen name="all_apps_view_pageLayoutPaddingTop">20dp</dimen>
@@ -29,10 +26,15 @@
     <dimen name="all_apps_view_pageLayoutPaddingLeft">40dp</dimen>
     <dimen name="all_apps_view_pageLayoutPaddingRight">40dp</dimen>
 
+    <!-- Dimensions for customize should generally be the same as all apps, or very similar. -->
+    <dimen name="customization_drawer_contents_pageLayoutWidthGap">32dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutHeightGap">12dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingTop">20dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingBottom">20dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingLeft">40dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingRight">40dp</dimen>
+
     <integer name="customization_drawer_contents_wallpaperCellSpanX">3</integer>
     <integer name="customization_drawer_contents_wallpaperCellCountX">12</integer>
     <integer name="customization_drawer_contents_widgetCellCountX">14</integer>
-    <integer name="customization_drawer_contents_cellCountX">8</integer>
-    <integer name="customization_drawer_contents_cellCountY">3</integer>
-    <dimen name="customization_drawer_contents_pageLayoutWidthGap">32dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/res/values-large-port/dimens.xml b/res/values-large-port/dimens.xml
index 2ea9e38..89f8605 100644
--- a/res/values-large-port/dimens.xml
+++ b/res/values-large-port/dimens.xml
@@ -19,9 +19,6 @@
          or right while you're dragging. -->
     <dimen name="scroll_zone">40dp</dimen>
 
-    <dimen name="customization_drawer_height">800dp</dimen>
-    <dimen name="customization_drawer_content_height">420dp</dimen>
-
     <dimen name="all_apps_view_pageLayoutWidthGap">36dp</dimen>
     <dimen name="all_apps_view_pageLayoutHeightGap">36dp</dimen>
     <dimen name="all_apps_view_pageLayoutPaddingTop">25dp</dimen>
@@ -32,7 +29,12 @@
     <integer name="customization_drawer_contents_wallpaperCellSpanX">3</integer>
     <integer name="customization_drawer_contents_wallpaperCellCountX">9</integer>
     <integer name="customization_drawer_contents_widgetCellCountX">9</integer>
-    <integer name="customization_drawer_contents_cellCountX">5</integer>
-    <integer name="customization_drawer_contents_cellCountY">3</integer>
+
+    <!-- Dimensions for customize should generally be the same as all apps, or very similar. -->
     <dimen name="customization_drawer_contents_pageLayoutWidthGap">36dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutHeightGap">12dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingTop">25dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingBottom">25dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingLeft">20dp</dimen>
+    <dimen name="customization_drawer_contents_pageLayoutPaddingRight">20dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/res/values-large/dimens.xml b/res/values-large/dimens.xml
index 2416109..10836b9 100644
--- a/res/values-large/dimens.xml
+++ b/res/values-large/dimens.xml
@@ -88,4 +88,14 @@
      the drag view should be offset from the position of the original view. -->
     <dimen name="dragViewOffsetX">0dp</dimen>
     <dimen name="dragViewOffsetY">-12dp</dimen>
+
+    <!-- The actual number of rows/columns will be determined dynamically based on the screen
+         size, but in portrait we want to cap the rows at 3, otherwise it looks weird. -->
+    <integer name="customization_drawer_contents_maxCellCountY">3</integer>
+
+    <!-- The percentage of vertical space that the customize tray should try to fill. -->
+    <integer name="customization_drawer_verticalFillPercentage">65</integer>
+
+    <!-- Max number of rows in all apps, because too many looks weird. -->
+    <integer name="all_apps_view_maxCellCountY">6</integer>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9ad3e24..7e8bec0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -25,6 +25,13 @@
     <!-- Do not translate. android:process of this application. -->
     <string name="process" translate="false"><xliff:g id="x"></xliff:g></string>
     
+    <!-- Do not translate. We wish to prioritize the Wallpaper and Live Wallpaper pickers,
+         but because they are in a different package, we need to reference the component in
+         a non language-dependent way.  If the Live Wallpaper picker component name changes
+         this will have to be updated as well. -->
+    <string name="live_wallpaper_picker_package_name" translate="false">com.android.wallpaper.livepicker</string>
+    <string name="live_wallpaper_picker_class_name" translate="false">com.android.wallpaper.livepicker.LiveWallpaperActivity</string>
+
     <!-- General -->
     <skip />
     <!-- Application name -->
diff --git a/src/com/android/launcher2/AllAppsBackground.java b/src/com/android/launcher2/AllAppsBackground.java
index 5292d0a..51e1ee4 100644
--- a/src/com/android/launcher2/AllAppsBackground.java
+++ b/src/com/android/launcher2/AllAppsBackground.java
@@ -25,8 +25,8 @@
 import android.view.View;
 
 /**
- * An implementation of PagedView that populates the pages of the workspace
- * with all of the user's applications.
+ * The background for AllApps which moves independently of the AllApps tray (for example, when we
+ * transition between AllApps and the Workspace while in spring-loaded mode).
  */
 public class AllAppsBackground extends View {
     private Drawable mBackground;
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index ead2c5d..64e6f98 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -73,6 +73,8 @@
     private int mLastMeasureWidth = -1;
     private int mLastMeasureHeight = -1;
 
+    private int mMaxCellCountY;
+
     public AllAppsPagedView(Context context) {
         this(context, null);
     }
@@ -90,9 +92,10 @@
         a.recycle();
         setSoundEffectsEnabled(false);
 
-        Resources r = context.getResources();
+        final Resources r = context.getResources();
         setDragSlopeThreshold(
                 r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold) / 100.0f);
+        mMaxCellCountY = r.getInteger(R.integer.all_apps_view_maxCellCountY);
     }
 
     @Override
@@ -172,7 +175,19 @@
         availableHeight -= mPageLayoutPaddingTop + mPageLayoutPaddingBottom;
         availableHeight -= cellHeight; // Assume at least one row
         availableHeight -= screenHeight * 0.16f;
-        return (1 + availableHeight / (cellHeight + mPageLayoutHeightGap));
+        if (availableHeight > 0) {
+            return Math.min(mMaxCellCountY,
+                    1 + availableHeight / (cellHeight + mPageLayoutHeightGap));
+        }
+        return 0;
+    }
+
+    int getCellCountX() {
+        return mCellCountX;
+    }
+
+    int getCellCountY() {
+        return mCellCountY;
     }
 
     void allowHardwareLayerCreation() {
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index fabd9e4..4500744 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -167,6 +168,22 @@
         setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
     }
 
+    /** Removes and returns the ResolveInfo with the specified ComponentName */
+    private ResolveInfo removeResolveInfoWithComponentName(List<ResolveInfo> list,
+            ComponentName cn) {
+        Iterator<ResolveInfo> iter = list.iterator();
+        while (iter.hasNext()) {
+            ResolveInfo rinfo = iter.next();
+            ActivityInfo info = rinfo.activityInfo;
+            ComponentName c = new ComponentName(info.packageName, info.name);
+            if (c.equals(cn)) {
+                iter.remove();
+                return rinfo;
+            }
+        }
+        return null;
+    }
+
     public void onPackagesUpdated() {
         // Get the list of widgets and shortcuts
         mWidgets.clear();
@@ -182,6 +199,20 @@
                 PackageManager.GET_META_DATA);
         Collections.sort(mWallpapers,
                 new LauncherModel.ShortcutNameComparator(mPackageManager));
+        // Move Live Wallpapers to the front of the list
+        Context c = getContext();
+        ResolveInfo liveWallpapers = removeResolveInfoWithComponentName(mWallpapers,
+            new ComponentName(c.getString(R.string.live_wallpaper_picker_package_name),
+                c.getString(R.string.live_wallpaper_picker_class_name)));
+        if (liveWallpapers != null) {
+            mWallpapers.add(0, liveWallpapers);
+        }
+        // Move Wallpapers to the front of the list
+        ResolveInfo wallpapers = removeResolveInfoWithComponentName(mWallpapers,
+            new ComponentName(c.getPackageName(), WallpaperChooser.class.getName()));
+        if (wallpapers != null) {
+            mWallpapers.add(0, wallpapers);
+        }
     }
 
     /**
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 5f848a8..f189cd5 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -71,7 +71,7 @@
 
     // These are temporary variables to prevent having to allocate a new object just to
     // return an (x, y) value from helper functions. Do NOT use them to maintain other state.
-    private final int[] mTmpCellXY = new int[2];
+    private final int[] mTmpXY = new int[2];
     private final int[] mTmpPoint = new int[2];
     private final PointF mTmpPointF = new PointF();
 
@@ -694,6 +694,14 @@
             if ((child.getVisibility() == VISIBLE || child.getAnimation() != null) &&
                     lp.isLockedToGrid) {
                 child.getHitRect(frame);
+
+                // The child hit rect is relative to the CellLayoutChildren parent, so we need to
+                // offset that by this CellLayout's padding to test an (x,y) point that is relative
+                // to this view.
+                final int tmpXY[] = mTmpXY;
+                child.getLocationOnScreen(tmpXY);
+                frame.offset(mLeftPadding, mTopPadding);
+
                 if (frame.contains(x, y)) {
                     cellInfo.cell = child;
                     cellInfo.cellX = lp.cellX;
@@ -708,7 +716,7 @@
         }
 
         if (!found) {
-            final int cellXY[] = mTmpCellXY;
+            final int cellXY[] = mTmpXY;
             pointToCellExact(x, y, cellXY);
 
             cellInfo.cell = null;
@@ -1161,7 +1169,7 @@
                         }
                     }
                 }
-                final int[] cellXY = mTmpCellXY;
+                final int[] cellXY = mTmpXY;
                 cellToCenterPoint(x, y, cellXY);
 
                 double distance = Math.sqrt(Math.pow(cellXY[0] - pixelX, 2)
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 68ec535..5ac261f 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -108,6 +108,9 @@
     // The max number of wallpaper cells to take a "page" of wallpaper items
     private int mMaxWallpaperCellHSpan;
 
+    // The maximum number of rows in a paged view.
+    private int mMaxCellCountY;
+
     // The raw sources of data for each of the different tabs of the customization page
     private List<AppWidgetProviderInfo> mWidgetList;
     private List<ResolveInfo> mShortcutList;
@@ -143,7 +146,10 @@
 
     private int[] mDragViewOrigin = new int[2];
 
-    private int mPageContentWidth;
+    private int mPageContentWidth = -1;
+    private int mPageContentHeight = -1;
+
+    private AllAppsPagedView mAllAppsPagedView;
 
     public CustomizePagedView(Context context) {
         this(context, null, 0);
@@ -162,10 +168,6 @@
         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);
-        mCellCountX = a.getInt(R.styleable.PagedView_cellCountX, 7);
-        mCellCountY = a.getInt(R.styleable.PagedView_cellCountY, 4);
-        a.recycle();
 
         mCustomizationType = CustomizationType.WidgetCustomization;
         mWidgetPages = new ArrayList<ArrayList<AppWidgetProviderInfo>>();
@@ -176,6 +178,8 @@
         setDragSlopeThreshold(
                 r.getInteger(R.integer.config_customizationDrawerDragSlopeThreshold) / 100.0f);
 
+        mMaxCellCountY = r.getInteger(R.integer.customization_drawer_contents_maxCellCountY);
+
         setVisibility(View.GONE);
         setSoundEffectsEnabled(false);
         setupWorkspaceLayout();
@@ -188,29 +192,44 @@
     }
 
     @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+    protected void onMeasure(int widthSpec, int heightSpec) {
+        // Base the size of this control on the size of the All Apps view.
+        final int cellCountX = mAllAppsPagedView.getCellCountX();
+        final int cellCountY = Math.min(mAllAppsPagedView.getCellCountY(), mMaxCellCountY);
 
-        final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
-        final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+        if (cellCountX != mCellCountX || cellCountY != mCellCountY) {
+            mCellCountX = cellCountX;
+            mCellCountY = cellCountY;
 
-        if (mFirstMeasure) {
-            mFirstMeasure = false;
-
-            // TODO: actually calculate mCellCountX/mCellCountY as some function of
-            // widthSize and heightSize
-            //mCellCountX = ?
-            //mCellCountY = ?
-
-            // Since mCellCountX/mCellCountY changed, we need to update the pages
-            invalidatePageData();
-
-            // Create a dummy page and set it up to find out the content width (used by our parent)
+            // Create a dummy page and set it up to determine our size.
+            // The size is based on the app shortcuts tab having the same dimensions as All Apps.
             PagedViewCellLayout layout = new PagedViewCellLayout(getContext());
             setupPage(layout);
             mPageContentWidth = layout.getContentWidth();
+            mPageContentHeight = layout.getContentHeight();
             mMinPageWidth = layout.getWidthBeforeFirstLayout();
         }
+        if (mPageContentHeight > 0) {
+            // Lock our height to the size of the page content
+            final int h = mPageContentHeight + mPageLayoutPaddingTop + mPageLayoutPaddingBottom;
+            heightSpec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);
+        }
+        super.onMeasure(widthSpec, heightSpec);
+        mFirstMeasure = false;
+    }
+
+    @Override
+    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+        if (mFirstLayout) {
+            invalidatePageData();
+
+            // invalidatePageData() is what causes the child pages to be created. We need the
+            // children to be measured before layout, so force a new measure here.
+            measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
+                    MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
+        }
+        super.onLayout(changed, left, top, right, bottom);
+        mFirstLayout = false;
     }
 
     public void setLauncher(Launcher launcher) {
@@ -219,6 +238,10 @@
         mPackageManager = context.getPackageManager();
     }
 
+    public void setAllAppsPagedView(AllAppsPagedView view) {
+        mAllAppsPagedView = view;
+    }
+
     /**
      * Sets the list of applications that launcher has loaded.
      */
diff --git a/src/com/android/launcher2/CustomizeTrayTabHost.java b/src/com/android/launcher2/CustomizeTrayTabHost.java
index ab50cf1..6306bda 100644
--- a/src/com/android/launcher2/CustomizeTrayTabHost.java
+++ b/src/com/android/launcher2/CustomizeTrayTabHost.java
@@ -44,9 +44,14 @@
 
     private boolean mFirstLayout = true;
 
+    // How much of the vertical space this control should attempt to fill
+    private float mVerticalFillPercentage;
+
     private final LayoutInflater mInflater;
     private Context mContext;
 
+    private CustomizePagedView mCustomizePagedView;
+
     public CustomizeTrayTabHost(Context context, AttributeSet attrs) {
         super(context, attrs);
         mContext = context;
@@ -55,15 +60,17 @@
 
     @Override
     protected void onFinishInflate() {
+        final Resources res = getResources();
+
         setup();
 
-        final CustomizePagedView customizePagedView =
+        mCustomizePagedView =
             (CustomizePagedView) findViewById(R.id.customization_drawer_tab_contents);
 
         // Configure tabs
         TabContentFactory contentFactory = new TabContentFactory() {
             public View createTabContent(String tag) {
-                return customizePagedView;
+                return mCustomizePagedView;
             }
         };
 
@@ -87,26 +94,28 @@
         addTab(newTabSpec(SHORTCUTS_TAG)
                 .setIndicator(tabView).setContent(contentFactory));
 
+        mVerticalFillPercentage =
+                res.getInteger(R.integer.customization_drawer_verticalFillPercentage) / 100f;
+
         setOnTabChangedListener(new OnTabChangeListener() {
             public void onTabChanged(String tabId) {
                 final CustomizePagedView.CustomizationType newType =
                     getCustomizeFilterForTabTag(tabId);
-                if (newType != customizePagedView.getCustomizationFilter()) {
+                if (newType != mCustomizePagedView.getCustomizationFilter()) {
                     // animate the changing of the tab content by fading pages in and out
-                    final Resources res = getResources();
                     final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
-                    final float alpha = customizePagedView.getAlpha();
-                    ValueAnimator alphaAnim = ObjectAnimator.ofFloat(customizePagedView,
+                    final float alpha = mCustomizePagedView.getAlpha();
+                    ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mCustomizePagedView,
                             "alpha", alpha, 0.0f);
                     alphaAnim.setDuration(duration);
                     alphaAnim.addListener(new AnimatorListenerAdapter() {
                         @Override
                         public void onAnimationEnd(Animator animation) {
-                            customizePagedView.setCustomizationFilter(newType);
+                            mCustomizePagedView.setCustomizationFilter(newType);
 
-                            final float alpha = customizePagedView.getAlpha();
+                            final float alpha = mCustomizePagedView.getAlpha();
                             ValueAnimator alphaAnim = ObjectAnimator.ofFloat(
-                                    customizePagedView, "alpha", alpha, 1.0f);
+                                    mCustomizePagedView, "alpha", alpha, 1.0f);
                             alphaAnim.setDuration(duration);
                             alphaAnim.start();
                         }
@@ -138,6 +147,22 @@
     }
 
     @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+        // If there's extra room, try to grow to fill it
+        if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST) {
+            final int availableHeight = MeasureSpec.getSize(heightMeasureSpec);
+            final int finalHeight = Math.max(getMeasuredHeight(),
+                        (int) (availableHeight * mVerticalFillPercentage));
+
+            // Measure a second time with EXACTLY so that we get sized correctly
+            heightMeasureSpec = MeasureSpec.makeMeasureSpec(finalHeight, MeasureSpec.EXACTLY);
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        }
+    }
+
+    @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
         if (mFirstLayout) {
             mFirstLayout = false;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 9dfed69..2a16e99 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -933,6 +933,7 @@
         if (mCustomizePagedView != null) {
             mCustomizePagedView.setLauncher(this);
             mCustomizePagedView.setDragController(dragController);
+            mCustomizePagedView.setAllAppsPagedView(mAllAppsPagedView);
         } else {
              ImageView hotseatLeft = (ImageView) findViewById(R.id.hotseat_left);
              hotseatLeft.setContentDescription(mHotseatLabels[0]);
@@ -3211,7 +3212,7 @@
         // Find the app market activity by resolving an intent.
         // (If multiple app markets are installed, it will return the ResolverActivity.)
         ComponentName activityName = intent.resolveActivity(getPackageManager());
-        if (activityName != null) {
+        if (activityName != null && LauncherApplication.isScreenLarge()) {
             mAppMarketIntent = intent;
             sAppMarketIcon = updateTextButtonWithIconFromExternalActivity(
                     R.id.market_button, activityName, R.drawable.app_market_generic);
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index 15b155f..0ae7a59 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -286,11 +286,17 @@
     }
 
     int getContentHeight() {
-        return mCellCountY * mCellHeight + (mCellCountY - 1) * Math.max(0, mHeightGap);
+        if (mCellCountY > 0) {
+            return mCellCountY * mCellHeight + (mCellCountY - 1) * Math.max(0, mHeightGap);
+        }
+        return 0;
     }
 
     int getWidthBeforeFirstLayout() {
-        return mCellCountX * mCellWidth + (mCellCountX - 1) * Math.max(0, mWidthGap);
+        if (mCellCountX > 0) {
+            return mCellCountX * mCellWidth + (mCellCountX - 1) * Math.max(0, mWidthGap);
+        }
+        return 0;
     }
 
     @Override
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index 306ff9e..30f0b1d 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -31,7 +31,6 @@
 import android.os.Message;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
-import android.view.View;
 import android.widget.Checkable;
 
 import com.android.launcher.R;
diff --git a/src/com/android/launcher2/ShortcutsAdapter.java b/src/com/android/launcher2/ShortcutsAdapter.java
deleted file mode 100644
index de73c3e..0000000
--- a/src/com/android/launcher2/ShortcutsAdapter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher2;
-
-import java.util.ArrayList;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.TextView;
-
-import com.android.launcher.R;
-
-/**
- * GridView adapter to show the list of applications and shortcuts
- */
-public class ShortcutsAdapter extends ArrayAdapter<ShortcutInfo> {
-    private final LayoutInflater mInflater;
-    private final IconCache mIconCache;
-
-    public ShortcutsAdapter(Context context, ArrayList<ShortcutInfo> apps) {
-        super(context, 0, apps);
-        mInflater = LayoutInflater.from(context);
-        mIconCache = ((LauncherApplication)context.getApplicationContext()).getIconCache();
-    }
-
-    @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-        final ShortcutInfo info = getItem(position);
-
-        if (convertView == null) {
-            convertView = mInflater.inflate(R.layout.application_boxed, parent, false);
-        }
-
-        final TextView textView = (TextView) convertView;
-        textView.setCompoundDrawablesWithIntrinsicBounds(null,
-                new FastBitmapDrawable(info.getIcon(mIconCache)), null, null);
-        textView.setText(info.title);
-
-        return convertView;
-    }
-}
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/android/launcher2/Utilities.java
index ba25893..04abd77 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/android/launcher2/Utilities.java
@@ -68,28 +68,6 @@
         sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                 Paint.FILTER_BITMAP_FLAG));
     }
-
-    static Bitmap centerToFit(Bitmap bitmap, int width, int height, Context context) {
-        final int bitmapWidth = bitmap.getWidth();
-        final int bitmapHeight = bitmap.getHeight();
-
-        if (bitmapWidth < width || bitmapHeight < height) {
-            int color = context.getResources().getColor(R.color.window_background);
-
-            Bitmap centered = Bitmap.createBitmap(bitmapWidth < width ? width : bitmapWidth,
-                    bitmapHeight < height ? height : bitmapHeight, Bitmap.Config.RGB_565);
-            centered.setDensity(bitmap.getDensity());
-            Canvas canvas = new Canvas(centered);
-            canvas.drawColor(color);
-            canvas.drawBitmap(bitmap, (width - bitmapWidth) / 2.0f, (height - bitmapHeight) / 2.0f,
-                    null);
-
-            bitmap = centered;
-        }
-
-        return bitmap;
-    }
-
     static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff };
     static int sColorIndex = 0;