Merge "Updating shourcuts only when the corresponding user also matches the AppInfo" into ub-now-porkchop
diff --git a/res/drawable-hdpi/screenpanel.9.png b/res/drawable-hdpi/screenpanel.9.png
index eed0f2c..bf806c3 100644
--- a/res/drawable-hdpi/screenpanel.9.png
+++ b/res/drawable-hdpi/screenpanel.9.png
Binary files differ
diff --git a/res/drawable-hdpi/screenpanel_hover.9.png b/res/drawable-hdpi/screenpanel_hover.9.png
index 2cea8a4..1726837 100644
--- a/res/drawable-hdpi/screenpanel_hover.9.png
+++ b/res/drawable-hdpi/screenpanel_hover.9.png
Binary files differ
diff --git a/res/drawable-mdpi/screenpanel.9.png b/res/drawable-mdpi/screenpanel.9.png
index 6f8b7e6..a9bed9f 100644
--- a/res/drawable-mdpi/screenpanel.9.png
+++ b/res/drawable-mdpi/screenpanel.9.png
Binary files differ
diff --git a/res/drawable-mdpi/screenpanel_hover.9.png b/res/drawable-mdpi/screenpanel_hover.9.png
index 8a94984..ce12197 100644
--- a/res/drawable-mdpi/screenpanel_hover.9.png
+++ b/res/drawable-mdpi/screenpanel_hover.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/screenpanel.9.png b/res/drawable-xhdpi/screenpanel.9.png
index 2d70d7a..fe604ba 100644
--- a/res/drawable-xhdpi/screenpanel.9.png
+++ b/res/drawable-xhdpi/screenpanel.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/screenpanel_hover.9.png b/res/drawable-xhdpi/screenpanel_hover.9.png
index 0032fff..3c05dc5 100644
--- a/res/drawable-xhdpi/screenpanel_hover.9.png
+++ b/res/drawable-xhdpi/screenpanel_hover.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/screenpanel.9.png b/res/drawable-xxhdpi/screenpanel.9.png
index 7ed058e..2769bdd 100644
--- a/res/drawable-xxhdpi/screenpanel.9.png
+++ b/res/drawable-xxhdpi/screenpanel.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/screenpanel_hover.9.png b/res/drawable-xxhdpi/screenpanel_hover.9.png
index 24d2266..e36d293 100644
--- a/res/drawable-xxhdpi/screenpanel_hover.9.png
+++ b/res/drawable-xxhdpi/screenpanel_hover.9.png
Binary files differ
diff --git a/res/layout-land/migration_cling.xml b/res/layout-land/migration_cling.xml
index 4765524..307cba8 100644
--- a/res/layout-land/migration_cling.xml
+++ b/res/layout-land/migration_cling.xml
@@ -41,8 +41,9 @@
     </FrameLayout>
 
     <LinearLayout
-        android:layout_width="280dp"
+        android:layout_width="@dimen/cling_migration_content_width"
         android:layout_height="wrap_content"
+        android:layout_marginEnd="@dimen/cling_migration_content_margin"
         android:orientation="vertical"
         android:paddingLeft="24dp"
         android:paddingRight="24dp" >
diff --git a/res/layout-port/migration_cling.xml b/res/layout-port/migration_cling.xml
index 932a9f4..dde8dbc 100644
--- a/res/layout-port/migration_cling.xml
+++ b/res/layout-port/migration_cling.xml
@@ -42,9 +42,10 @@
             android:src="@drawable/ic_migration" />
 
         <LinearLayout
-            android:layout_width="280dp"
+            android:layout_width="@dimen/cling_migration_content_width"
             android:layout_height="wrap_content"
             android:layout_below="@+id/ic_cling_migration"
+            android:layout_marginStart="@dimen/cling_migration_content_margin"
             android:orientation="vertical"
             android:paddingLeft="24dp"
             android:paddingRight="24dp" >
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 68f476d..28679be 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -29,5 +29,7 @@
     <dimen name="cling_migration_logo_width">274dp</dimen>
     <dimen name="cling_migration_bg_size">600dp</dimen>
     <dimen name="cling_migration_bg_shift">-300dp</dimen>
+    <dimen name="cling_migration_content_margin">64dp</dimen>
+    <dimen name="cling_migration_content_width">280dp</dimen>
 
 </resources>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 9ae155b..8be9964 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -25,4 +25,9 @@
      the drag view should be offset from the position of the original view. -->
     <dimen name="dragViewOffsetX">0dp</dimen>
     <dimen name="dragViewOffsetY">0dp</dimen>
+
+<!-- Cling -->
+    <dimen name="cling_migration_content_margin">96dp</dimen>
+    <dimen name="cling_migration_content_width">320dp</dimen>
+
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index befaf37..2c9e689 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -33,6 +33,8 @@
     <dimen name="cling_migration_logo_width">165dp</dimen>
     <dimen name="cling_migration_bg_size">400dp</dimen>
     <dimen name="cling_migration_bg_shift">-200dp</dimen>
+    <dimen name="cling_migration_content_margin">16dp</dimen>
+    <dimen name="cling_migration_content_width">280dp</dimen>
 
 <!-- Workspace -->
     <dimen name="workspace_max_gap">16dp</dimen>
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index d0b3f43..0ff1ef4 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -959,10 +959,7 @@
     }
 
     public void setShortcutAndWidgetAlpha(float alpha) {
-        final int childCount = getChildCount();
-        for (int i = 0; i < childCount; i++) {
-            getChildAt(i).setAlpha(alpha);
-        }
+        mShortcutsAndWidgets.setAlpha(alpha);
     }
 
     public ShortcutAndWidgetContainer getShortcutsAndWidgets() {
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 75be836..ddc1bd9 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -62,7 +62,7 @@
     // Empty class name is used for storing package default entry.
     private static final String EMPTY_CLASS_NAME = ".";
 
-    private static final boolean DEBUG = true;
+    private static final boolean DEBUG = false;
 
     private static class CacheEntry {
         public Bitmap icon;
@@ -511,7 +511,7 @@
                 Log.w(TAG, "failed to decode pre-load icon for " + key);
             }
         } catch (FileNotFoundException e) {
-            if (DEBUG) Log.d(TAG, "there is no restored icon for: " + key, e);
+            if (DEBUG) Log.d(TAG, "there is no restored icon for: " + key);
         } catch (IOException e) {
             Log.w(TAG, "failed to read pre-load icon for: " + key, e);
         } finally {
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 2657b6e..b6144f4 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -38,7 +38,7 @@
     private static final String TAG = "LauncherAppState";
     private static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs";
 
-    private static final boolean DEBUG = true;  // STOPSHIP(cwren) temporary for debugging
+    private static final boolean DEBUG = false;
 
     private final AppFilter mAppFilter;
     private final BuildInfo mBuildInfo;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 616e536..29cd9e3 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -85,7 +85,7 @@
 public class LauncherModel extends BroadcastReceiver
         implements LauncherAppsCompat.OnAppsChangedCallbackCompat {
     static final boolean DEBUG_LOADERS = false;
-    private static final boolean DEBUG_RECEIVER = true;  // STOPSHIP(cwren) temporary for debugging
+    private static final boolean DEBUG_RECEIVER = false;
 
     static final String TAG = "Launcher.Model";
 
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
index 57fac7f..5997e7b 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
@@ -41,9 +41,9 @@
             // TODO change this to use api version once L gets an API number.
             if (sInstance == null) {
                 if (Utilities.isLmp()) {
-                    sInstance = new AppWidgetManagerCompatVL(context);
+                    sInstance = new AppWidgetManagerCompatVL(context.getApplicationContext());
                 } else {
-                    sInstance = new AppWidgetManagerCompatV16(context);
+                    sInstance = new AppWidgetManagerCompatV16(context.getApplicationContext());
                 }
             }
             return sInstance;
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
index 30af38e..c3853ab 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
@@ -121,15 +121,9 @@
         } else {
             badgeLocation.offset(bitmap.getWidth() - badgeSize - badgeMargin, top);
         }
-        Drawable drawable = null;
-        // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
-        // This hack is just to prevent crash in older builds.
-        try {
-            drawable = mPm.getUserBadgedDrawableForDensity(new BitmapDrawable(res, bitmap),
-                    info.getProfile(), badgeLocation, 0);
-        } catch (Exception e) {
-            return bitmap;
-        }
+
+        Drawable drawable = mPm.getUserBadgedDrawableForDensity(
+                new BitmapDrawable(res, bitmap), info.getProfile(), badgeLocation, 0);
 
         if (drawable instanceof BitmapDrawable) {
             return ((BitmapDrawable) drawable).getBitmap();
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java
index de8c669..e3879ee 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompat.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java
@@ -51,9 +51,9 @@
             // STOPSHIP(kennyguy) change this to use api version once L gets an API number.
             if (sInstance == null) {
                 if ("L".equals(Build.VERSION.CODENAME)) {
-                    sInstance = new LauncherAppsCompatVL(context);
+                    sInstance = new LauncherAppsCompatVL(context.getApplicationContext());
                 } else {
-                    sInstance = new LauncherAppsCompatV16(context);
+                    sInstance = new LauncherAppsCompatV16(context.getApplicationContext());
                 }
             }
             return sInstance;
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
index c47f223..7e5e6bf 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
@@ -22,19 +22,17 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
+import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.PackageInfo;
 import android.content.pm.ResolveInfo;
 import android.graphics.Rect;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
-import android.os.UserHandle;
 import android.provider.Settings;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 /**
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
index 6422551..c4a9783 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
@@ -82,7 +82,11 @@
         synchronized (mCallbacks) {
             mCallbacks.put(callback, wrappedCallback);
         }
-        mLauncherApps.addCallback(wrappedCallback);
+        try {
+            mLauncherApps.registerCallback(wrappedCallback);
+        } catch (Throwable e) {
+            // STOPSHIP(kennyguy): Remove when LRW71 hits googlefood
+        }
     }
 
     public void removeOnAppsChangedCallback(
@@ -92,7 +96,11 @@
             wrappedCallback = mCallbacks.remove(callback);
         }
         if (wrappedCallback != null) {
-            mLauncherApps.removeCallback(wrappedCallback);
+            try {
+                mLauncherApps.unregisterCallback(wrappedCallback);
+            } catch (Throwable e) {
+                // STOPSHIP(kennyguy): Remove when LRW71 hits googlefood
+            }
         }
     }
 
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index 0a84280..4ad10d8 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -48,6 +48,7 @@
         mBound = false;
 
         mInstaller.registerSessionCallback(mCallback);
+
         // On start, send updates for all active sessions
         for (SessionInfo info : mInstaller.getAllSessions()) {
             mPendingReplays.append(info.getSessionId(), info);
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVL.java b/src/com/android/launcher3/compat/UserManagerCompatVL.java
index e54db61..19eeabd 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVL.java
@@ -51,13 +51,7 @@
 
     @Override
     public Drawable getBadgedDrawableForUser(Drawable unbadged, UserHandleCompat user) {
-        // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
-        // This hack is just to prevent crash in older builds.
-        try {
-            return mPm.getUserBadgedIcon(unbadged, user.getUser());
-        } catch (Exception e) {
-            return unbadged;
-        }
+        return mPm.getUserBadgedIcon(unbadged, user.getUser());
     }
 
     @Override
@@ -65,13 +59,7 @@
         if (user == null) {
             return label;
         }
-        // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
-        // This hack is just to prevent crash in older builds.
-        try {
         return mPm.getUserBadgedLabel(label, user.getUser());
-        } catch (Exception e) {
-            return label;
-        }
     }
 }