Merge "Handle RS reflection name changes."
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 1c2fa12..a9e4dfe 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -444,11 +444,6 @@
         return false;
     }
     @Override
-    public Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo, Rect recycle) {
-        return null;
-    }
-    @Override
     public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset,
             int yOffset, DragView dragView, Object dragInfo) {
         return null;
diff --git a/src/com/android/launcher2/ApplicationInfoDropTarget.java b/src/com/android/launcher2/ApplicationInfoDropTarget.java
index b053fa0..99a5258 100644
--- a/src/com/android/launcher2/ApplicationInfoDropTarget.java
+++ b/src/com/android/launcher2/ApplicationInfoDropTarget.java
@@ -76,11 +76,6 @@
         return false;
     }
 
-    public Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo, Rect recycle) {
-        return null;
-    }
-
     public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
             DragView dragView, Object dragInfo) {
 
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 4307391..8fb3025 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -52,7 +52,7 @@
 import com.android.launcher.R;
 
 public class CustomizePagedView extends PagedView
-    implements View.OnLongClickListener,
+    implements View.OnLongClickListener, View.OnClickListener,
                 DragSource {
 
     public enum CustomizationType {
@@ -108,6 +108,7 @@
     private List<AppWidgetProviderInfo> mWidgetList;
     private List<ResolveInfo> mFolderList;
     private List<ResolveInfo> mShortcutList;
+    private List<ResolveInfo> mWallpaperList;
 
     private static final int sCellCountX = 8;
     private static final int sCellCountY = 4;
@@ -188,6 +189,11 @@
         mShortcutList = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
         Collections.sort(mShortcutList, resolveInfoComparator);
 
+        // get the list of wallpapers
+        Intent wallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
+        mWallpaperList = mPackageManager.queryIntentActivities(wallpapersIntent, 0);
+        Collections.sort(mWallpaperList, resolveInfoComparator);
+
         // reset the icon cache
         mPageViewIconCache.clear();
 
@@ -211,6 +217,31 @@
     }
 
     @Override
+    public void onClick(View v) {
+        if (!v.isInTouchMode()) {
+            return;
+        }
+
+        final View animView = v;
+        switch (mCustomizationType) {
+        case WallpaperCustomization:
+            // animate some feedback to the long press
+            animateClickFeedback(v, new Runnable() {
+                @Override
+                public void run() {
+                    // add the shortcut
+                    ResolveInfo info = (ResolveInfo) animView.getTag();
+                    Intent createWallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER);
+                    ComponentName name = new ComponentName(info.activityInfo.packageName,
+                            info.activityInfo.name);
+                    createWallpapersIntent.setComponent(name);
+                    mLauncher.processWallpaper(createWallpapersIntent);
+                }
+            });
+        }
+    }
+
+    @Override
     public boolean onLongClick(View v) {
         if (!v.isInTouchMode()) {
             return false;
@@ -476,7 +507,11 @@
             PagedViewIcon icon = (PagedViewIcon) mInflater.inflate(
                     R.layout.customize_paged_view_item, layout, false);
             icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache);
-            icon.setOnLongClickListener(this);
+            if (mCustomizationType == CustomizationType.WallpaperCustomization) {
+                icon.setOnClickListener(this);
+            } else {
+                icon.setOnLongClickListener(this);
+            }
 
             final int index = i - startIndex;
             final int x = index % sCellCountX;
@@ -486,34 +521,6 @@
         }
     }
 
-    private void syncWallpaperPages() {
-        // NOT CURRENTLY IMPLEMENTED
-
-        // we need to repopulate with PagedViewCellLayouts
-        removeAllViews();
-
-        // add any necessary pages
-        int numPages = 1;
-        for (int i = 0; i < numPages; ++i) {
-            PagedViewCellLayout layout = new PagedViewCellLayout(getContext());
-            setupPage(layout);
-            addView(layout);
-        }
-    }
-
-    private void syncWallpaperPageItems(int page) {
-        PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page);
-        layout.removeAllViews();
-
-        TextView text = (TextView) mInflater.inflate(
-                R.layout.customize_paged_view_wallpaper_placeholder, layout, false);
-        // NOTE: this is just place holder text until MikeJurka implements wallpaper picker
-        text.setText("Wallpaper customization coming soon!");
-
-        setupPage(layout);
-        layout.addViewToCellLayout(text, -1, 0, new PagedViewCellLayout.LayoutParams(0, 0, 3, 1));
-    }
-
     @Override
     public void syncPages() {
         boolean centerPagedViewCellLayouts = false;
@@ -530,7 +537,7 @@
             centerPagedViewCellLayouts = true;
             break;
         case WallpaperCustomization:
-            syncWallpaperPages();
+            syncListPages(mWallpaperList);
             centerPagedViewCellLayouts = true;
             break;
         default:
@@ -570,7 +577,7 @@
             syncListPageItems(page, mShortcutList);
             break;
         case WallpaperCustomization:
-            syncWallpaperPageItems(page);
+            syncListPageItems(page, mWallpaperList);
             break;
         }
     }
diff --git a/src/com/android/launcher2/DeleteZone.java b/src/com/android/launcher2/DeleteZone.java
index 12713e5..01a20f7 100644
--- a/src/com/android/launcher2/DeleteZone.java
+++ b/src/com/android/launcher2/DeleteZone.java
@@ -83,11 +83,6 @@
             DragView dragView, Object dragInfo) {
         return true;
     }
-    
-    public Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo, Rect recycle) {
-        return null;
-    }
 
     public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
             DragView dragView, Object dragInfo) {
diff --git a/src/com/android/launcher2/DropTarget.java b/src/com/android/launcher2/DropTarget.java
index e33ec9a..d2e3ace 100644
--- a/src/com/android/launcher2/DropTarget.java
+++ b/src/com/android/launcher2/DropTarget.java
@@ -88,27 +88,6 @@
     boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
             DragView dragView, Object dragInfo);
 
-    /**
-     * Estimate the surface area where this object would land if dropped at the
-     * given location.
-     * 
-     * @param source DragSource where the drag started
-     * @param x X coordinate of the drop location
-     * @param y Y coordinate of the drop location
-     * @param xOffset Horizontal offset with the object being dragged where the
-     *            original touch happened
-     * @param yOffset Vertical offset with the object being dragged where the
-     *            original touch happened
-     * @param dragView The DragView that's being dragged around on screen.
-     * @param dragInfo Data associated with the object being dragged
-     * @param recycle {@link Rect} object to be possibly recycled.
-     * @return Estimated area that would be occupied if object was dropped at
-     *         the given location. Should return null if no estimate is found,
-     *         or if this target doesn't provide estimations.
-     */
-    Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo, Rect recycle);
-
     // These methods are implemented in Views
     void getHitRect(Rect outRect);
     void getLocationOnScreen(int[] loc);
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java
index 78a9516..e2cef0e 100644
--- a/src/com/android/launcher2/FolderIcon.java
+++ b/src/com/android/launcher2/FolderIcon.java
@@ -71,11 +71,6 @@
                 && item.container != mInfo.id;
     }
 
-    public Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo, Rect recycle) {
-        return null;
-    }
-
     public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
             DragView dragView, Object dragInfo) {
         ShortcutInfo item;
diff --git a/src/com/android/launcher2/HolographicOutlineHelper.java b/src/com/android/launcher2/HolographicOutlineHelper.java
index 6210337..d6c5484 100644
--- a/src/com/android/launcher2/HolographicOutlineHelper.java
+++ b/src/com/android/launcher2/HolographicOutlineHelper.java
@@ -59,21 +59,17 @@
      * pages.
      */
     public float highlightAlphaInterpolator(float r) {
-        final float pivot = 0.3f;
-        if (r < pivot) {
-            return Math.max(0.5f, 0.65f * cubic(r / pivot));
-        } else {
-            return Math.min(1.0f, 0.65f * cubic(1 - (r - pivot) / (1 - pivot)));
-        }
+        float maxAlpha = 0.6f;
+        return (float) Math.pow(maxAlpha * (1.0f - r), 1.5f);
     }
 
     /**
      * Returns the interpolated view alpha for the effect we want when scrolling pages.
      */
     public float viewAlphaInterpolator(float r) {
-        final float pivot = 0.6f;
+        final float pivot = 0.95f;
         if (r < pivot) {
-            return r / pivot;
+            return (float) Math.pow(r / pivot, 1.5f);
         } else {
             return 1.0f;
         }
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 8eece96..d619aa2 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1459,6 +1459,10 @@
         }
     }
 
+    void processWallpaper(Intent intent) {
+        startActivityForResult(intent, REQUEST_PICK_WALLPAPER);
+    }
+
     void addLiveFolder(Intent intent) {
         // Handle case where user selected "Folder"
         String folderName = getResources().getString(R.string.group_folder);
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 2cd7f20..9dbe61d 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -374,17 +374,23 @@
                     int childWidth = layout.getMeasuredWidth();
                     int halfChildWidth = (childWidth / 2);
                     int childCenter = getChildOffset(i) + halfChildWidth;
-                    int distanceFromScreenCenter = Math.abs(childCenter - screenCenter);
-                    float alpha = 0.0f;
-                    if (distanceFromScreenCenter < halfChildWidth) {
-                        alpha = 1.0f;
-                    } else if (distanceFromScreenCenter > childWidth) {
-                        alpha = 0.0f;
+
+                    int d = halfChildWidth;
+                    int distanceFromScreenCenter = childCenter - screenCenter;
+                    if (distanceFromScreenCenter > 0) {
+                        if (i > 0) {
+                            d += getChildAt(i - 1).getMeasuredWidth() / 2;
+                        }
                     } else {
-                        float dimAlpha = (float) (distanceFromScreenCenter - halfChildWidth) / halfChildWidth;
-                        dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
-                        alpha = 1.0f - dimAlpha;
+                        if (i < childCount - 1) {
+                            d += getChildAt(i + 1).getMeasuredWidth() / 2;
+                        }
                     }
+
+                    float dimAlpha = (float) (Math.abs(distanceFromScreenCenter)) / d;
+                    dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha)));
+                    float alpha = 1.0f - dimAlpha;
+
                     if (Float.compare(alpha, layout.getAlpha()) != 0) {
                         layout.setAlpha(alpha);
                     }
diff --git a/src/com/android/launcher2/UserFolder.java b/src/com/android/launcher2/UserFolder.java
index b46e924..c7466b8 100644
--- a/src/com/android/launcher2/UserFolder.java
+++ b/src/com/android/launcher2/UserFolder.java
@@ -38,11 +38,6 @@
                     itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT)
                 && item.container != mInfo.id;
     }
-    
-    public Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
-            DragView dragView, Object dragInfo, Rect recycle) {
-        return null;
-    }
 
     public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
             DragView dragView, Object dragInfo) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 0568d89..599fbda 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1145,39 +1145,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    public Rect estimateDropLocation(DragSource source, int x, int y,
-            int xOffset, int yOffset, DragView dragView, Object dragInfo, Rect recycle) {
-        final CellLayout layout = getCurrentDropLayout();
-
-        final CellLayout.CellInfo cellInfo = mDragInfo;
-        final int spanX = cellInfo == null ? 1 : cellInfo.spanX;
-        final int spanY = cellInfo == null ? 1 : cellInfo.spanY;
-        final View ignoreView = cellInfo == null ? null : cellInfo.cell;
-
-        final Rect location = recycle != null ? recycle : new Rect();
-
-        // Find drop cell and convert into rectangle
-        int[] dropCell = estimateDropCell(x - xOffset, y - yOffset, spanX,
-                spanY, ignoreView, layout, mTempCell);
-
-        if (dropCell == null) {
-            return null;
-        }
-
-        layout.cellToPoint(dropCell[0], dropCell[1], mTempEstimate);
-        location.left = mTempEstimate[0];
-        location.top = mTempEstimate[1];
-
-        layout.cellToPoint(dropCell[0] + spanX, dropCell[1] + spanY, mTempEstimate);
-        location.right = mTempEstimate[0];
-        location.bottom = mTempEstimate[1];
-
-        return location;
-    }
-
-    /**
      * Calculate the nearest cell where the given object would be dropped.
      */
     private int[] estimateDropCell(int pixelX, int pixelY,