am bbdb00a7: am 3dfe0d75: am e8b600c5: Merge "Add translucent bar attributes to sw720dp values override." into jb-ub-now-indigo-rose

* commit 'bbdb00a7a9d302ffb8039647d751de2c9bb359e2':
diff --git a/Android.mk b/Android.mk
index 3b1a244..3bd20a7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -37,7 +37,7 @@
 LOCAL_PACKAGE_NAME := Launcher3
 #LOCAL_CERTIFICATE := shared
 
-LOCAL_OVERRIDES_PACKAGES := Home
+LOCAL_OVERRIDES_PACKAGES := Launcher2
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 
diff --git a/res/layout-port/workspace_cling.xml b/res/layout-port/workspace_cling.xml
index 9c000cb..b926ca9 100644
--- a/res/layout-port/workspace_cling.xml
+++ b/res/layout-port/workspace_cling.xml
@@ -62,8 +62,8 @@
             android:id="@+id/focused_hotseat_app_bubble"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_gravity="bottom|right"
-            android:layout_marginRight="25dp"
+            android:layout_gravity="bottom|left"
+            android:layout_marginLeft="25dp"
             android:layout_marginBottom="90dp"
             android:orientation="vertical"
             android:visibility="gone">
@@ -90,8 +90,8 @@
             <ImageView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_gravity="right"
-                android:layout_marginRight="80dp"
+                android:layout_gravity="left"
+                android:layout_marginLeft="78dp"
                 android:src="@drawable/cling_arrow_down" />
         </LinearLayout>
     </FrameLayout>
@@ -101,7 +101,7 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginBottom="15dp"
-        android:layout_marginLeft="20dp"
-        android:layout_gravity="bottom|left"
+        android:layout_marginRight="20dp"
+        android:layout_gravity="bottom|right"
         android:onClick="dismissWorkspaceCling" />
 </com.android.launcher3.Cling>
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 287bb50..8dab943 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -109,9 +109,8 @@
         LauncherAppState app = LauncherAppState.getInstance();
         DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
 
-        setCompoundDrawablesWithIntrinsicBounds(null,
-                new FastBitmapDrawable(b),
-                null, null);
+        setCompoundDrawables(null,
+                Utilities.createIconDrawable(b), null, null);
         setCompoundDrawablePadding((int) ((grid.folderIconSizePx - grid.iconSizePx) / 2f));
         setText(info.title);
         setTag(info);
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 5231aac..69d9a3d 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -532,8 +532,8 @@
     protected boolean createAndAddShortcut(ShortcutInfo item) {
         final BubbleTextView textView =
             (BubbleTextView) mInflater.inflate(R.layout.application, this, false);
-        textView.setCompoundDrawablesWithIntrinsicBounds(null,
-                new FastBitmapDrawable(item.getIcon(mIconCache)), null, null);
+        textView.setCompoundDrawables(null,
+                Utilities.createIconDrawable(item.getIcon(mIconCache)), null, null);
         textView.setText(item.title);
         textView.setTag(item);
         textView.setTextColor(getResources().getColor(R.color.folder_items_text_color));
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index 7e1e350..cd1ff2c 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -98,6 +98,7 @@
     private int mPreviewOffsetY;
     private float mMaxPerspectiveShift;
     boolean mAnimating = false;
+    private Rect mOldBounds = new Rect();
 
     private PreviewItemDrawingParams mParams = new PreviewItemDrawingParams(0, 0, 0, 0);
     private PreviewItemDrawingParams mAnimParams = new PreviewItemDrawingParams(0, 0, 0, 0);
@@ -534,6 +535,7 @@
         Drawable d = params.drawable;
 
         if (d != null) {
+            mOldBounds.set(d.getBounds());
             d.setBounds(0, 0, mIntrinsicIconSize, mIntrinsicIconSize);
             d.setFilterBitmap(true);
             d.setColorFilter(Color.argb(params.overlayAlpha, 255, 255, 255),
@@ -541,6 +543,7 @@
             d.draw(canvas);
             d.clearColorFilter();
             d.setFilterBitmap(false);
+            d.setBounds(mOldBounds);
         }
         canvas.restore();
     }
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 2aab64d..094e188 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -150,7 +150,7 @@
             TextView allAppsButton = (TextView)
                     inflater.inflate(R.layout.all_apps_button, mContent, false);
             Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
-            d.setBounds(0, 0, Utilities.sIconTextureWidth, Utilities.sIconTextureHeight);
+            Utilities.resizeIconDrawable(d);
             allAppsButton.setCompoundDrawables(null, d, null, null);
 
             allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 1797826..543b8ee 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -29,6 +29,8 @@
 import android.graphics.drawable.Drawable;
 
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
 
 /**
  * Cache of application icons.  Icons can be made from any thread.
@@ -147,6 +149,21 @@
     }
 
     /**
+     * Empty out the cache that aren't of the correct grid size
+     */
+    public void flushInvalidIcons(DeviceProfile grid) {
+        synchronized (mCache) {
+            Iterator<Entry<ComponentName, CacheEntry>> it = mCache.entrySet().iterator();
+            while (it.hasNext()) {
+                final CacheEntry e = it.next().getValue();
+                if (e.icon.getWidth() != grid.iconSizePx || e.icon.getHeight() != grid.iconSizePx) {
+                    it.remove();
+                }
+            }
+        }
+    }
+
+    /**
      * Fill in "application" with the icon and label for "info."
      */
     public void getTitleAndIcon(AppInfo application, ResolveInfo info,
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 821c15f..7df73b1 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -36,6 +36,9 @@
 import org.json.*;
 
 public class InstallShortcutReceiver extends BroadcastReceiver {
+    private static final String TAG = "InstallShortcutReceiver";
+    private static final boolean DBG = false;
+
     public static final String ACTION_INSTALL_SHORTCUT =
             "com.android.launcher.action.INSTALL_SHORTCUT";
 
@@ -94,10 +97,11 @@
                 }
                 json = json.endObject();
                 SharedPreferences.Editor editor = sharedPrefs.edit();
+                if (DBG) Log.d(TAG, "Adding to APPS_PENDING_INSTALL: " + json);
                 addToStringSet(sharedPrefs, editor, APPS_PENDING_INSTALL, json.toString());
                 editor.commit();
             } catch (org.json.JSONException e) {
-                Log.d("InstallShortcutReceiver", "Exception when adding shortcut: " + e);
+                Log.d(TAG, "Exception when adding shortcut: " + e);
             }
         }
     }
@@ -106,9 +110,15 @@
                                               ArrayList<String> packageNames) {
         synchronized(sLock) {
             Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
+            if (DBG) {
+                Log.d(TAG, "APPS_PENDING_INSTALL: " + strings
+                        + ", removing packages: " + packageNames);
+            }
             if (strings != null) {
                 Set<String> newStrings = new HashSet<String>(strings);
-                for (String json : newStrings) {
+                Iterator<String> newStringsIter = newStrings.iterator();
+                while (newStringsIter.hasNext()) {
+                    String json = newStringsIter.next();
                     try {
                         JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
                         Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
@@ -117,12 +127,12 @@
                             pn = launchIntent.getComponent().getPackageName();
                         }
                         if (packageNames.contains(pn)) {
-                            newStrings.remove(json);
+                            newStringsIter.remove();
                         }
                     } catch (org.json.JSONException e) {
-                        Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e);
+                        Log.d(TAG, "Exception reading shortcut to remove: " + e);
                     } catch (java.net.URISyntaxException e) {
-                        Log.d("InstallShortcutReceiver", "Exception reading shortcut to remove: " + e);
+                        Log.d(TAG, "Exception reading shortcut to remove: " + e);
                     }
                 }
                 sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL,
@@ -135,6 +145,7 @@
             SharedPreferences sharedPrefs) {
         synchronized(sLock) {
             Set<String> strings = sharedPrefs.getStringSet(APPS_PENDING_INSTALL, null);
+            if (DBG) Log.d(TAG, "Getting and clearing APPS_PENDING_INSTALL: " + strings);
             if (strings == null) {
                 return new ArrayList<PendingInstallShortcutInfo>();
             }
@@ -167,11 +178,9 @@
                         new PendingInstallShortcutInfo(data, name, launchIntent);
                     infos.add(info);
                 } catch (org.json.JSONException e) {
-                    Log.d("InstallShortcutReceiver",
-                            "Exception reading shortcut to add: " + e);
+                    Log.d(TAG, "Exception reading shortcut to add: " + e);
                 } catch (java.net.URISyntaxException e) {
-                    Log.d("InstallShortcutReceiver",
-                            "Exception reading shortcut to add: " + e);
+                    Log.d(TAG, "Exception reading shortcut to add: " + e);
                 }
             }
             sharedPrefs.edit().putStringSet(APPS_PENDING_INSTALL, new HashSet<String>()).commit();
@@ -203,6 +212,8 @@
             return;
         }
 
+        if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0));
+
         Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
         if (intent == null) {
             return;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ee13f29..b0e4968 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -402,6 +402,7 @@
                 Context.MODE_PRIVATE);
         mModel = app.setLauncher(this);
         mIconCache = app.getIconCache();
+        mIconCache.flushInvalidIcons(grid);
         mDragController = new DragController(this);
         mInflater = getLayoutInflater();
 
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index 01f72a7..5d4f9c6 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -30,6 +30,7 @@
     static HashSet<Animator> sAnimators = new HashSet<Animator>();
     static Animator.AnimatorListener sEndAnimListener = new Animator.AnimatorListener() {
         public void onAnimationStart(Animator animation) {
+            sAnimators.add(animation);
         }
 
         public void onAnimationRepeat(Animator animation) {
@@ -45,7 +46,6 @@
     };
 
     public static void cancelOnDestroyActivity(Animator a) {
-        sAnimators.add(a);
         a.addListener(sEndAnimListener);
     }
 
diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java
index c6d5e49..8bfe42d 100644
--- a/src/com/android/launcher3/PagedViewIcon.java
+++ b/src/com/android/launcher3/PagedViewIcon.java
@@ -69,7 +69,8 @@
             PagedViewIcon.PressedCallback cb) {
         mIcon = info.iconBitmap;
         mPressedCallback = cb;
-        setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
+        setCompoundDrawables(null, Utilities.createIconDrawable(mIcon),
+                null, null);
         setText(info.title);
         setTag(info);
     }
diff --git a/src/com/android/launcher3/SearchDropTargetBar.java b/src/com/android/launcher3/SearchDropTargetBar.java
index e681aa1..435dbda 100644
--- a/src/com/android/launcher3/SearchDropTargetBar.java
+++ b/src/com/android/launcher3/SearchDropTargetBar.java
@@ -138,7 +138,8 @@
      * Shows and hides the search bar.
      */
     public void showSearchBar(boolean animated) {
-        if (!mIsSearchBarHidden) return;
+        boolean needToCancelOngoingAnimation = mQSBSearchBarAnim.isRunning() && !animated;
+        if (!mIsSearchBarHidden && !needToCancelOngoingAnimation) return;
         if (animated) {
             prepareStartAnimation(mQSBSearchBar);
             mQSBSearchBarAnim.reverse();
@@ -153,7 +154,8 @@
         mIsSearchBarHidden = false;
     }
     public void hideSearchBar(boolean animated) {
-        if (mIsSearchBarHidden) return;
+        boolean needToCancelOngoingAnimation = mQSBSearchBarAnim.isRunning() && !animated;
+        if (mIsSearchBarHidden && !needToCancelOngoingAnimation) return;
         if (animated) {
             prepareStartAnimation(mQSBSearchBar);
             mQSBSearchBarAnim.start();
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 2cb9314..21c546d 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -66,6 +66,23 @@
     static int sColorIndex = 0;
 
     /**
+     * Returns a FastBitmapDrawable with the icon, accurately sized.
+     */
+    static Drawable createIconDrawable(Bitmap icon) {
+        FastBitmapDrawable d = new FastBitmapDrawable(icon);
+        d.setFilterBitmap(true);
+        resizeIconDrawable(d);
+        return d;
+    }
+
+    /**
+     * Resizes an icon drawable to the correct icon size.
+     */
+    static void resizeIconDrawable(Drawable icon) {
+        icon.setBounds(0, 0, sIconTextureWidth, sIconTextureHeight);
+    }
+
+    /**
      * Returns a bitmap suitable for the all apps view. Used to convert pre-ICS
      * icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size)
      * to the proper size (48dp)
diff --git a/src/com/android/launcher3/WallpaperCropActivity.java b/src/com/android/launcher3/WallpaperCropActivity.java
index 79cc88e..30ec340 100644
--- a/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/src/com/android/launcher3/WallpaperCropActivity.java
@@ -87,9 +87,15 @@
 
         mCropView = (CropView) findViewById(R.id.cropView);
 
-        Intent cropIntent = this.getIntent();
+        Intent cropIntent = getIntent();
         final Uri imageUri = cropIntent.getData();
 
+        if (imageUri == null) {
+            Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
+            finish();
+            return;
+        }
+
         int rotation = getRotationFromExif(this, imageUri);
         mCropView.setTileSource(new BitmapRegionTileSource(this, imageUri, 1024, rotation), null);
         mCropView.setTouchEnabled(true);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 1d5b5ac..f6416c8 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1446,6 +1446,12 @@
         }
 
         if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
+
+        CellLayout cc = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID);
+        if (progress > 0 && cc.getVisibility() != VISIBLE && !isSmall()) {
+            cc.setVisibility(VISIBLE);
+        }
+
         mLastCustomContentScrollProgress = progress;
 
         setBackgroundAlpha(progress * 0.8f);
@@ -3046,7 +3052,9 @@
     private void cleanupFolderCreation() {
         if (mDragFolderRingAnimator != null) {
             mDragFolderRingAnimator.animateToNaturalState();
+            mDragFolderRingAnimator = null;
         }
+        mFolderCreationAlarm.setOnAlarmListener(null);
         mFolderCreationAlarm.cancelAlarm();
     }
 
@@ -3390,9 +3398,11 @@
         }
 
         public void onAlarm(Alarm alarm) {
-            if (mDragFolderRingAnimator == null) {
-                mDragFolderRingAnimator = new FolderRingAnimator(mLauncher, null);
+            if (mDragFolderRingAnimator != null) {
+                // This shouldn't happen ever, but just in case, make sure we clean up the mess.
+                mDragFolderRingAnimator.animateToNaturalState();
             }
+            mDragFolderRingAnimator = new FolderRingAnimator(mLauncher, null);
             mDragFolderRingAnimator.setCell(cellX, cellY);
             mDragFolderRingAnimator.setCellLayout(layout);
             mDragFolderRingAnimator.animateToAcceptState();
@@ -4077,6 +4087,7 @@
             }
         }
         mRestoredPages.clear();
+        mSavedStates = null;
     }
 
     @Override