diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 0c4867c..5173672 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -20,19 +20,24 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.xmlpull.v1.XmlPullParser;
+
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.ObjectAnimator;
 import android.animation.PropertyValuesHolder;
+import android.app.WallpaperManager;
 import android.appwidget.AppWidgetManager;
 import android.appwidget.AppWidgetProviderInfo;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.graphics.Canvas;
@@ -41,15 +46,15 @@
 import android.util.AttributeSet;
 import android.util.Log;
 import android.util.LruCache;
-import android.view.Gravity;
+import android.util.Slog;
+import android.util.TypedValue;
+import android.util.Xml;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.LinearInterpolator;
-import android.widget.FrameLayout;
 import android.widget.ImageView;
-import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.android.launcher.R;
@@ -63,7 +68,8 @@
      */
     public enum ContentType {
         Applications,
-        Widgets
+        Widgets,
+        Wallpapers
     }
 
     // Refs
@@ -76,6 +82,7 @@
     private ContentType mContentType;
     private ArrayList<ApplicationInfo> mApps;
     private List<Object> mWidgets;
+    private List<ResolveInfo> mWallpapers;
 
     // Caching
     private Drawable mDefaultWidgetBackground;
@@ -86,8 +93,9 @@
     // Dimens
     private int mContentWidth;
     private int mMaxWidgetSpan, mMinWidgetSpan;
-    private int mWidgetCellWidthGap, mWidgetCellHeightGap;
+    private int mCellWidthGap, mCellHeightGap;
     private int mWidgetCountX, mWidgetCountY;
+    private int mWallpaperCountX, mWallpaperCountY;
     private final int mWidgetPreviewIconPaddedDimension;
     private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
     private PagedViewCellLayout mWidgetSpacingLayout;
@@ -104,6 +112,7 @@
         mContentType = ContentType.Applications;
         mApps = new ArrayList<ApplicationInfo>();
         mWidgets = new ArrayList<Object>();
+        mWallpapers = new ArrayList<ResolveInfo>();
         mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
         mWidgetPreviewCache = new LruCache<Object, Bitmap>(sWidgetPreviewCacheSize) {
             protected int sizeOf(Object key, Bitmap value) {
@@ -120,12 +129,14 @@
         mCellCountY = a.getInt(R.styleable.PagedView_cellCountY, 4);
         a.recycle();
         a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0);
-        mWidgetCellWidthGap =
+        mCellWidthGap =
             a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellWidthGap, 10);
-        mWidgetCellHeightGap =
+        mCellHeightGap =
             a.getDimensionPixelSize(R.styleable.AppsCustomizePagedView_widgetCellHeightGap, 10);
         mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2);
         mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2);
+        mWallpaperCountX = a.getInt(R.styleable.AppsCustomizePagedView_wallpaperCountX, 2);
+        mWallpaperCountY = a.getInt(R.styleable.AppsCustomizePagedView_wallpaperCountY, 2);
         a.recycle();
 
         // Create a dummy page that we can use to approximate the cell dimensions of widgets and
@@ -164,6 +175,13 @@
         mWidgets.addAll(mPackageManager.queryIntentActivities(shortcutsIntent, 0));
         Collections.sort(mWidgets,
                 new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager));
+
+        // Get the list of wallpapers
+        Intent wallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
+        mWallpapers = mPackageManager.queryIntentActivities(wallpapersIntent,
+                PackageManager.GET_META_DATA);
+        Collections.sort(mWallpapers,
+                new LauncherModel.ShortcutNameComparator(mPackageManager));
     }
 
     /**
@@ -275,30 +293,47 @@
                 }
             });
         } else if (v instanceof PagedViewWidget) {
-            Workspace w = mLauncher.getWorkspace();
-            int currentWorkspaceScreen = mLauncher.getCurrentWorkspaceScreen();
-            final CellLayout cl = (CellLayout) w.getChildAt(currentWorkspaceScreen);
-            final View dragView = v.findViewById(R.id.widget_preview);
-            final ItemInfo itemInfo = (ItemInfo) v.getTag();
-            animateClickFeedback(v, new Runnable() {
-                @Override
-                public void run() {
-                    cl.calculateSpans(itemInfo);
-                    if (cl.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY)) {
-                        if (LauncherApplication.isScreenXLarge()) {
-                            animateItemOntoScreen(dragView, cl, itemInfo);
-                        } else {
-                            mLauncher.addExternalItemToScreen(itemInfo, cl);
-                            itemInfo.dropPos = null;
-                        }
-
-                        // Hide the pane so we can see the workspace we dropped on
-                        mLauncher.showWorkspace(true);
-                    } else {
-                        mLauncher.showOutOfSpaceMessage();
+            final ResolveInfo info = (ResolveInfo) v.getTag();
+            if (mWallpapers.contains(info)) {
+                // Start the wallpaper picker
+                animateClickFeedback(v, new Runnable() {
+                    @Override
+                    public void run() {
+                        // add the shortcut
+                        Intent createWallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
+                        ComponentName name = new ComponentName(info.activityInfo.packageName,
+                                info.activityInfo.name);
+                        createWallpapersIntent.setComponent(name);
+                        mLauncher.processWallpaper(createWallpapersIntent);
                     }
-                }
-            });
+                });
+            } else {
+                // Add the widget to the current workspace screen
+                Workspace w = mLauncher.getWorkspace();
+                int currentWorkspaceScreen = mLauncher.getCurrentWorkspaceScreen();
+                final CellLayout cl = (CellLayout) w.getChildAt(currentWorkspaceScreen);
+                final View dragView = v.findViewById(R.id.widget_preview);
+                final ItemInfo itemInfo = (ItemInfo) v.getTag();
+                animateClickFeedback(v, new Runnable() {
+                    @Override
+                    public void run() {
+                        cl.calculateSpans(itemInfo);
+                        if (cl.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY)) {
+                            if (LauncherApplication.isScreenXLarge()) {
+                                animateItemOntoScreen(dragView, cl, itemInfo);
+                            } else {
+                                mLauncher.addExternalItemToScreen(itemInfo, cl);
+                                itemInfo.dropPos = null;
+                            }
+
+                            // Hide the pane so we can see the workspace we dropped on
+                            mLauncher.showWorkspace(true);
+                        } else {
+                            mLauncher.showOutOfSpaceMessage();
+                        }
+                    }
+                });
+            }
         }
     }
 
@@ -692,9 +727,9 @@
         int numWidgetsPerPage = mWidgetCountX * mWidgetCountY;
         int offset = page * numWidgetsPerPage;
         int cellWidth = ((mWidgetSpacingLayout.getContentWidth() - mPageLayoutWidthGap
-                - ((mWidgetCountX - 1) * mWidgetCellWidthGap)) / mWidgetCountX);
+                - ((mWidgetCountX - 1) * mCellWidthGap)) / mWidgetCountX);
         int cellHeight = ((mWidgetSpacingLayout.getContentHeight() - mPageLayoutHeightGap
-                - ((mWidgetCountY - 1) * mWidgetCellHeightGap)) / mWidgetCountY);
+                - ((mWidgetCountY - 1) * mCellHeightGap)) / mWidgetCountY);
         for (int i = 0; i < Math.min(numWidgetsPerPage, mWidgets.size() - offset); ++i) {
             Object rawInfo = mWidgets.get(offset + i);
             PendingAddItemInfo createItemInfo = null;
@@ -730,11 +765,166 @@
             int iy = i / mWidgetCountX;
             PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
                     cellHeight);
-            lp.leftMargin = (ix * cellWidth) + (ix * mWidgetCellWidthGap);
-            lp.topMargin = (iy * cellHeight) + (iy * mWidgetCellHeightGap);
+            lp.leftMargin = (ix * cellWidth) + (ix * mCellWidthGap);
+            lp.topMargin = (iy * cellHeight) + (iy * mCellHeightGap);
             layout.addView(widget, lp);
         }
     }
+
+    /*
+     * This method fetches an xml file specified in the manifest identified by
+     * WallpaperManager.WALLPAPER_PREVIEW_META_DATA). The xml file specifies
+     * an image which will be used as the wallpaper preview for an activity
+     * which responds to ACTION_SET_WALLPAPER. This image is returned and used
+     * in the customize drawer.
+     */
+    private Drawable parseWallpaperPreviewXml(ResolveInfo ri) {
+        ActivityInfo activityInfo = ri.activityInfo;
+        XmlResourceParser parser = null;
+        ComponentName component = new ComponentName(ri.activityInfo.packageName,
+                ri.activityInfo.name);
+        try {
+            parser = activityInfo.loadXmlMetaData(mPackageManager,
+                    WallpaperManager.WALLPAPER_PREVIEW_META_DATA);
+            if (parser == null) {
+                Slog.w(LOG_TAG, "No " + WallpaperManager.WALLPAPER_PREVIEW_META_DATA
+                        + " meta-data for " + "wallpaper provider '" + component + '\'');
+                return null;
+            }
+
+            AttributeSet attrs = Xml.asAttributeSet(parser);
+
+            int type;
+            while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+                    && type != XmlPullParser.START_TAG) {
+                // drain whitespace, comments, etc.
+            }
+
+            String nodeName = parser.getName();
+            if (!"wallpaper-preview".equals(nodeName)) {
+                Slog.w(LOG_TAG, "Meta-data does not start with wallpaper-preview tag for "
+                        + "wallpaper provider '" + component + '\'');
+                return null;
+            }
+
+            // If metaData was null, we would have returned earlier when getting
+            // the parser No need to do the check here
+            Resources res = mPackageManager.getResourcesForApplication(
+                    activityInfo.applicationInfo);
+
+            TypedArray sa = res.obtainAttributes(attrs,
+                    com.android.internal.R.styleable.WallpaperPreviewInfo);
+
+            TypedValue value = sa.peekValue(
+                    com.android.internal.R.styleable.WallpaperPreviewInfo_staticWallpaperPreview);
+            if (value == null) return null;
+
+            return res.getDrawable(value.resourceId);
+        } catch (Exception e) {
+            Slog.w(LOG_TAG, "XML parsing failed for wallpaper provider '" + component + '\'', e);
+            return null;
+        } finally {
+            if (parser != null) parser.close();
+        }
+    }
+    private FastBitmapDrawable getWallpaperPreview(ResolveInfo info, int cellWidth, int cellHeight){
+        // Return the cached version if necessary
+        Bitmap cachedBitmap = mWidgetPreviewCache.get(info);
+        if (cachedBitmap != null) {
+            return new FastBitmapDrawable(cachedBitmap);
+        }
+
+        // Get the preview
+        Resources resources = getContext().getResources();
+        Drawable wallpaperPreview = parseWallpaperPreviewXml(info);
+        Drawable wallpaperIcon = null;
+        int expectedWidth;
+        int expectedHeight;
+        if (wallpaperPreview != null) {
+            expectedWidth = wallpaperPreview.getIntrinsicWidth();
+            expectedHeight = wallpaperPreview.getIntrinsicHeight();
+        } else {
+            wallpaperPreview = mDefaultWidgetBackground;
+            expectedWidth = expectedHeight = Math.min(cellWidth, cellHeight);
+
+            // Draw the icon in the top left corner
+            String packageName = info.activityInfo.packageName;
+            try {
+                if (info.icon > 0) {
+                    wallpaperIcon = mPackageManager.getDrawable(packageName, info.icon, null);
+                }
+                if (wallpaperIcon == null) {
+                    wallpaperIcon = resources.getDrawable(R.drawable.ic_launcher_application);
+                }
+            } catch (Resources.NotFoundException e) {}
+        }
+
+        // Create the bitmap
+        Bitmap preview = Bitmap.createBitmap(expectedWidth, expectedHeight, Config.ARGB_8888);
+        renderDrawableToBitmap(wallpaperPreview, preview, 0, 0, expectedWidth, expectedHeight,
+                1f, 1f);
+        if (wallpaperIcon != null) {
+            int iconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size);
+            int offset = (int) (iconSize * sWidgetPreviewIconPaddingPercentage);
+            renderDrawableToBitmap(wallpaperIcon, preview, offset, offset, iconSize, iconSize,
+                    1f, 1f);
+        }
+
+        FastBitmapDrawable previewDrawable = new FastBitmapDrawable(preview);
+        previewDrawable.setBounds(0, 0, expectedWidth, expectedHeight);
+        mWidgetPreviewCache.put(info, preview);
+        return previewDrawable;
+    }
+    /*
+     * Wallpapers PagedView implementation
+     */
+    public void syncWallpaperPages() {
+        // Ensure that we have the right number of pages
+        Context context = getContext();
+        int numWidgetsPerPage = mWallpaperCountX * mWallpaperCountY;
+        int numPages = (int) Math.ceil(mWallpapers.size() / (float) numWidgetsPerPage);
+        for (int i = 0; i < numPages; ++i) {
+            PagedViewGridLayout layout = new PagedViewGridLayout(context, mWallpaperCountX,
+                    mWallpaperCountY);
+            setupPage(layout);
+            addView(layout);
+        }
+    }
+    public void syncWallpaperPageItems(int page) {
+        PagedViewGridLayout layout = (PagedViewGridLayout) getChildAt(page);
+        layout.removeAllViews();
+
+        // Calculate the dimensions of each cell we are giving to each widget
+        int numWidgetsPerPage = mWallpaperCountX * mWallpaperCountY;
+        int offset = page * numWidgetsPerPage;
+        int cellWidth = ((mWidgetSpacingLayout.getContentWidth() - mPageLayoutWidthGap
+                - ((mWallpaperCountX - 1) * mCellWidthGap)) / mWallpaperCountX);
+        int cellHeight = ((mWidgetSpacingLayout.getContentHeight() - mPageLayoutHeightGap
+                - ((mWallpaperCountY - 1) * mCellHeightGap)) / mWallpaperCountY);
+        for (int i = 0; i < Math.min(numWidgetsPerPage, mWallpapers.size() - offset); ++i) {
+            ResolveInfo info = mWallpapers.get(offset + i);
+            PagedViewWidget widget = (PagedViewWidget) mLayoutInflater.inflate(
+                    R.layout.apps_customize_wallpaper, layout, false);
+
+            // Fill in the shortcuts information
+            FastBitmapDrawable preview = getWallpaperPreview(info, cellWidth, cellHeight);
+            widget.applyFromResolveInfo(mPackageManager, info, preview, null, false);
+            widget.setTag(info);
+            widget.setOnClickListener(this);
+            widget.setOnLongClickListener(this);
+            widget.setOnTouchListener(this);
+
+            // Layout each widget
+            int ix = i % mWallpaperCountX;
+            int iy = i / mWallpaperCountX;
+            PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
+                    cellHeight);
+            lp.leftMargin = (ix * cellWidth) + (ix * mCellWidthGap);
+            lp.topMargin = (iy * cellHeight) + (iy * mCellHeightGap);
+            layout.addView(widget, lp);
+        }
+    }
+
     @Override
     public void syncPages() {
         removeAllViews();
@@ -745,6 +935,9 @@
         case Widgets:
             syncWidgetPages();
             break;
+        case Wallpapers:
+            syncWallpaperPages();
+            break;
         }
     }
     @Override
@@ -756,6 +949,9 @@
         case Widgets:
             syncWidgetPageItems(page);
             break;
+        case Wallpapers:
+            syncWallpaperPageItems(page);
+            break;
         }
     }
 
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 15920c3..e2d21b6 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -33,6 +33,7 @@
 
     private static final String APPS_TAB_TAG = "APPS";
     private static final String WIDGETS_TAB_TAG = "WIDGETS";
+    private static final String WALLPAPERS_TAB_TAG = "WALLPAPERS";
 
     private final LayoutInflater mLayoutInflater;
 
@@ -70,6 +71,9 @@
         tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
         tabView.setText(mContext.getString(R.string.widgets_tab_label));
         addTab(newTabSpec(WIDGETS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
+        tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
+        tabView.setText(mContext.getString(R.string.wallpapers_tab_label));
+        addTab(newTabSpec(WALLPAPERS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
         setOnTabChangedListener(this);
 
         // Set the width of the tab bar to match the content (for now)
@@ -91,6 +95,8 @@
             return AppsCustomizePagedView.ContentType.Applications;
         } else if (tag.equals(WIDGETS_TAB_TAG)) {
             return AppsCustomizePagedView.ContentType.Widgets;
+        } else if (tag.equals(WALLPAPERS_TAB_TAG)) {
+            return AppsCustomizePagedView.ContentType.Wallpapers;
         }
         return AppsCustomizePagedView.ContentType.Applications;
     }
@@ -103,6 +109,8 @@
             return APPS_TAB_TAG;
         } else if (type == AppsCustomizePagedView.ContentType.Widgets) {
             return WIDGETS_TAB_TAG;
+        } else if (type == AppsCustomizePagedView.ContentType.Wallpapers) {
+            return WALLPAPERS_TAB_TAG;
         }
         return APPS_TAB_TAG;
     }
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 41473c3..6492888 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -211,8 +211,10 @@
         name.setText(info.loadLabel(pm));
         name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
         final TextView dims = (TextView) findViewById(R.id.widget_dims);
-        dims.setText(String.format(mDimensionsFormatString, 1, 1));
-        dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+        if (dims != null) {
+            dims.setText(String.format(mDimensionsFormatString, 1, 1));
+            dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+        }
 
         if (createHolographicOutline) {
             mIconCache = cache;
