Merge "Fix issue with UiThreadReveal on L devices" into ub-launcher3-burnaby
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index d382c6a..802922e 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -18,7 +18,6 @@
 <com.android.launcher3.LauncherRootView
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:launcher="http://schemas.android.com/apk/res-auto"
-
     android:id="@+id/launcher"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
diff --git a/res/values-gu-rIN/strings.xml b/res/values-gu-rIN/strings.xml
index b547db4..4a2274f 100644
--- a/res/values-gu-rIN/strings.xml
+++ b/res/values-gu-rIN/strings.xml
@@ -26,15 +26,15 @@
     <string name="activity_not_available" msgid="7456344436509528827">"એપ્લિકેશન ઉપલબ્ધ નથી"</string>
     <string name="safemode_shortcut_error" msgid="9160126848219158407">"સુરક્ષિત મોડમાં ડાઉનલોડ કરેલ એપ્લિકેશન અક્ષમ કરી"</string>
     <string name="safemode_widget_error" msgid="4863470563535682004">"સુરક્ષિત મોડમાં વિજેટ્સ અક્ષમ કર્યા"</string>
-    <string name="toggle_weight_watcher" msgid="5645299835184636119">"Mem દર્શાવો"</string>
+    <string name="toggle_weight_watcher" msgid="5645299835184636119">"Mem બતાવો"</string>
     <string name="long_press_widget_to_add" msgid="7699152356777458215">"વિજેટ ચૂંટવા માટે ટચ કરો અને પકડી રાખો."</string>
     <string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string>
-    <string name="all_apps_search_bar_hint" msgid="7084713969757597256">"શોધ એપ્લિકેશન્સ"</string>
-    <string name="all_apps_loading_message" msgid="7557140873644765180">"એપ્લિકેશન્સ લોડ કરી રહ્યું છે…"</string>
-    <string name="all_apps_no_search_results" msgid="6332185285860416787">"\"<xliff:g id="QUERY">%1$s</xliff:g>\" થી મેળ ખાતી કોઈ એપ્લિકેશન્સ મળી નથી"</string>
+    <string name="all_apps_search_bar_hint" msgid="7084713969757597256">"શોધ એપ્લિકેશનો"</string>
+    <string name="all_apps_loading_message" msgid="7557140873644765180">"એપ્લિકેશનો લોડ કરી રહ્યું છે…"</string>
+    <string name="all_apps_no_search_results" msgid="6332185285860416787">"\"<xliff:g id="QUERY">%1$s</xliff:g>\" થી મેળ ખાતી કોઈ એપ્લિકેશનો મળી નથી"</string>
     <string name="out_of_space" msgid="4691004494942118364">"આ હોમ સ્ક્રીન પર વધુ જગ્યા નથી."</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"મનપસંદ ટ્રે પર વધુ જગ્યા નથી"</string>
-    <string name="all_apps_button_label" msgid="9110807029020582876">"એપ્લિકેશન્સ"</string>
+    <string name="all_apps_button_label" msgid="9110807029020582876">"એપ્લિકેશનો"</string>
     <string name="all_apps_home_button_label" msgid="252062713717058851">"હોમ"</string>
     <string name="delete_target_label" msgid="1822697352535677073">"દૂર કરો"</string>
     <string name="delete_target_uninstall_label" msgid="5100785476250872595">"અનઇન્સ્ટોલ કરો"</string>
diff --git a/res/values-ml-rIN/strings.xml b/res/values-ml-rIN/strings.xml
index 71a9e36..59ad153 100644
--- a/res/values-ml-rIN/strings.xml
+++ b/res/values-ml-rIN/strings.xml
@@ -38,7 +38,7 @@
     <string name="all_apps_home_button_label" msgid="252062713717058851">"ഹോം"</string>
     <string name="delete_target_label" msgid="1822697352535677073">"നീക്കംചെയ്യുക"</string>
     <string name="delete_target_uninstall_label" msgid="5100785476250872595">"അണ്‍ഇസ്റ്റാളുചെയ്യുക"</string>
-    <string name="info_target_label" msgid="8053346143994679532">"അപ്ലിക്കേഷൻ വിവരം"</string>
+    <string name="info_target_label" msgid="8053346143994679532">"ആപ്പ് വിവരം"</string>
     <string name="permlab_install_shortcut" msgid="5632423390354674437">"കുറുക്കുവഴികൾ ഇൻസ്റ്റാളുചെയ്യുക"</string>
     <string name="permdesc_install_shortcut" msgid="923466509822011139">"ഉപയോക്തൃ ഇടപെടൽ ഇല്ലാതെ കുറുക്കുവഴികൾ ചേർക്കാൻ അപ്ലിക്കേഷനെ അനുവദിക്കുന്നു."</string>
     <string name="permlab_read_settings" msgid="1941457408239617576">"ഹോം ക്രമീകരണങ്ങളും കുറുക്കുവഴികളും റീഡുചെയ്യുക"</string>
diff --git a/res/values-ta-rIN/strings.xml b/res/values-ta-rIN/strings.xml
index e2b680a..1f2a6f9 100644
--- a/res/values-ta-rIN/strings.xml
+++ b/res/values-ta-rIN/strings.xml
@@ -51,7 +51,7 @@
     <string name="folder_hint_text" msgid="6617836969016293992">"பெயரிடப்படாத கோப்புறை"</string>
     <string name="default_scroll_format" msgid="7475544710230993317">"பக்கம் %1$d / %2$d"</string>
     <string name="workspace_scroll_format" msgid="8458889198184077399">"முகப்புத் திரை %1$d of %2$d"</string>
-    <string name="first_run_cling_title" msgid="2459738000155917941">"வரவேற்கிறோம்"</string>
+    <string name="first_run_cling_title" msgid="2459738000155917941">"நல்வரவு"</string>
     <string name="migration_cling_title" msgid="9181776667882933767">"பயன்பாட்டின் ஐகான்களை நகலெடுக்கவும்"</string>
     <string name="migration_cling_description" msgid="2752413805582227644">"பழைய முகப்புத் திரைகளிலிருந்து ஐகான்களையும் கோப்புறைகளையும் இறக்குமதி செய்யவா?"</string>
     <string name="migration_cling_copy_apps" msgid="946331230090919440">"ஐகான்களை நகலெடு"</string>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index a50540d..62b05b0 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -265,7 +265,7 @@
             if (isTablet) {
                 // Pad the left and right of the workspace to ensure consistent spacing
                 // between all icons
-                int width = isLandscape ? Math.max(widthPx, heightPx) : Math.min(widthPx, heightPx);
+                int width = getCurrentWidth();
                 // XXX: If the icon size changes across orientations, we will have to take
                 //      that into account here too.
                 int gap = (int) ((width - 2 * edgeMarginPx -
@@ -301,12 +301,8 @@
                 // Pad the left and right of the workspace to ensure consistent spacing
                 // between all icons
                 float gapScale = 1f + (dragViewScale - 1f) / 2f;
-                int width = isLandscape
-                        ? Math.max(widthPx, heightPx)
-                        : Math.min(widthPx, heightPx);
-                int height = isLandscape
-                        ? Math.max(widthPx, heightPx)
-                        : Math.min(widthPx, heightPx);
+                int width = getCurrentWidth();
+                int height = getCurrentHeight();
                 int paddingTop = searchBarBounds.bottom;
                 int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx;
                 int availableWidth = Math.max(0, width - (int) ((inv.numColumns * cellWidthPx) +
@@ -517,4 +513,16 @@
             }
         }
     }
+
+    private int getCurrentWidth() {
+        return isLandscape
+                ? Math.max(widthPx, heightPx)
+                : Math.min(widthPx, heightPx);
+    }
+
+    private int getCurrentHeight() {
+        return isLandscape
+                ? Math.min(widthPx, heightPx)
+                : Math.max(widthPx, heightPx);
+    }
 }
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index b9ac2a4..916418f 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -466,7 +466,7 @@
         }
 
         LauncherActivityInfoCompat launcherActInfo = mLauncherApps.resolveActivity(intent, user);
-        CacheEntry entry = cacheLocked(component, launcherActInfo, user, true, true);
+        CacheEntry entry = cacheLocked(component, launcherActInfo, user, true, false /* useLowRes */);
         return entry.icon;
     }
 
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 339d5a3..6648b6e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -263,6 +263,7 @@
     private ViewGroup mOverviewPanel;
 
     private View mAllAppsButton;
+    private View mWidgetsButton;
 
     private SearchDropTargetBar mSearchDropTargetBar;
 
@@ -1370,8 +1371,8 @@
         }
 
         mOverviewPanel = (ViewGroup) findViewById(R.id.overview_panel);
-        View widgetButton = findViewById(R.id.widget_button);
-        widgetButton.setOnClickListener(new OnClickListener() {
+        mWidgetsButton = findViewById(R.id.widget_button);
+        mWidgetsButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View arg0) {
                 if (!mWorkspace.isSwitchingState()) {
@@ -1379,7 +1380,7 @@
                 }
             }
         });
-        widgetButton.setOnTouchListener(getHapticFeedbackTouchListener());
+        mWidgetsButton.setOnTouchListener(getHapticFeedbackTouchListener());
 
         View wallpaperButton = findViewById(R.id.wallpaper_button);
         wallpaperButton.setOnClickListener(new OnClickListener() {
@@ -1465,6 +1466,10 @@
         return mAllAppsButton;
     }
 
+    public View getWidgetsButton() {
+        return mWidgetsButton;
+    }
+
     /**
      * Creates a view representing a shortcut.
      *
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 7414a22..9d2a890 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1999,7 +1999,7 @@
                                                 "constructing info for partially restored package",
                                                 true);
                                         info = getRestoredItemInfo(c, titleIndex, intent,
-                                                promiseType, cursorIconInfo, context);
+                                                promiseType, itemType, cursorIconInfo, context);
                                         intent = getRestoredItemIntent(c, context, intent);
                                     } else {
                                         // Don't restore items for other profiles.
@@ -3380,7 +3380,7 @@
      * to a package that is not yet installed on the system.
      */
     public ShortcutInfo getRestoredItemInfo(Cursor c, int titleIndex, Intent intent,
-            int promiseType, CursorIconInfo iconInfo, Context context) {
+            int promiseType, int itemType, CursorIconInfo iconInfo, Context context) {
         final ShortcutInfo info = new ShortcutInfo();
         info.user = UserHandleCompat.myUserHandle();
 
@@ -3406,7 +3406,7 @@
         }
 
         info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
-        info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
+        info.itemType = itemType;
         info.promisedIntent = intent;
         info.status = promiseType;
         return info;
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index ee72aea..cc5e18b 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -772,7 +772,7 @@
 
                     long id = c.getLong(idIndex);
                     updateStmt.bindLong(1, id);
-                    updateStmt.execute();
+                    updateStmt.executeUpdateDelete();
                 }
                 db.setTransactionSuccessful();
             } catch (SQLException ex) {
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 0ea9d8b..d69b743 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -90,21 +90,14 @@
      * Private callbacks made during transition setup.
      */
     static abstract class PrivateTransitionCallbacks {
-        void onRevealViewVisible(View revealView, View contentView, View allAppsButtonView) {}
         float getMaterialRevealViewFinalAlpha(View revealView) {
             return 0;
         }
-        float getMaterialRevealViewFinalXDrift(View revealView) {
-            return 0;
-        }
-        float getMaterialRevealViewFinalYDrift(View revealView) {
-            return 0;
-        }
         float getMaterialRevealViewStartFinalRadius() {
             return 0;
         }
         AnimatorListenerAdapter getMaterialRevealViewAnimatorListener(View revealView,
-                View allAppsButtonView) {
+                View buttonView) {
             return null;
         }
         void onTransitionComplete() {}
@@ -135,30 +128,13 @@
     public void startAnimationToAllApps(final boolean animated,
             final boolean startSearchAfterTransition) {
         final AllAppsContainerView toView = mLauncher.getAppsView();
+        final View buttonView = mLauncher.getAllAppsButton();
         PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
-            private int[] mAllAppsToPanelDelta;
-
-            @Override
-            public void onRevealViewVisible(View revealView, View contentView,
-                    View allAppsButtonView) {
-                // Get the y delta between the center of the page and the center of the all apps
-                // button
-                mAllAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
-                        allAppsButtonView, null);
-            }
             @Override
             public float getMaterialRevealViewFinalAlpha(View revealView) {
                 return 1f;
             }
             @Override
-            public float getMaterialRevealViewFinalXDrift(View revealView) {
-                return mAllAppsToPanelDelta[0];
-            }
-            @Override
-            public float getMaterialRevealViewFinalYDrift(View revealView) {
-                return mAllAppsToPanelDelta[1];
-            }
-            @Override
             public float getMaterialRevealViewStartFinalRadius() {
                 int allAppsButtonSize = mLauncher.getDeviceProfile().allAppsButtonVisualSize;
                 return allAppsButtonSize / 2;
@@ -183,9 +159,9 @@
             }
         };
         // Only animate the search bar if animating from spring loaded mode back to all apps
-        startAnimationToOverlay(Workspace.State.NORMAL_HIDDEN, toView, toView.getContentView(),
-                toView.getRevealView(), toView.getSearchBarView(), animated,
-                true /* hideSearchBar */, cb);
+        startAnimationToOverlay(Workspace.State.NORMAL_HIDDEN, buttonView, toView,
+                toView.getContentView(), toView.getRevealView(), toView.getSearchBarView(),
+                animated, true /* hideSearchBar */, cb);
     }
 
     /**
@@ -193,22 +169,15 @@
      */
     public void startAnimationToWidgets(final boolean animated) {
         final WidgetsContainerView toView = mLauncher.getWidgetsView();
-        final Resources res = mLauncher.getResources();
+        final View buttonView = mLauncher.getWidgetsButton();
+
         PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
             @Override
-            public void onRevealViewVisible(View revealView, View contentView,
-                    View allAppsButtonView) {
-            }
-            @Override
             public float getMaterialRevealViewFinalAlpha(View revealView) {
                 return 0.3f;
             }
-            @Override
-            public float getMaterialRevealViewFinalYDrift(View revealView) {
-                return revealView.getMeasuredHeight() / 2;
-            }
         };
-        startAnimationToOverlay(Workspace.State.OVERVIEW_HIDDEN, toView,
+        startAnimationToOverlay(Workspace.State.OVERVIEW_HIDDEN, buttonView, toView,
                 toView.getContentView(), toView.getRevealView(), null, animated,
                 true /* hideSearchBar */, cb);
     }
@@ -238,23 +207,22 @@
      * Creates and starts a new animation to a particular overlay view.
      */
     @SuppressLint("NewApi")
-    private void startAnimationToOverlay(final Workspace.State toWorkspaceState, final View toView,
-             final View contentView, final View revealView, final View overlaySearchBarView,
-             final boolean animated, final boolean hideSearchBar,
-             final PrivateTransitionCallbacks pCb) {
+    private void startAnimationToOverlay(final Workspace.State toWorkspaceState,
+            final View buttonView, final View toView, final View contentView, final View revealView,
+            final View overlaySearchBarView, final boolean animated, final boolean hideSearchBar,
+            final PrivateTransitionCallbacks pCb) {
         final Resources res = mLauncher.getResources();
         final boolean material = Utilities.isLmpOrAbove();
         final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
         final int itemsAlphaStagger =
                 res.getInteger(R.integer.config_overlayItemsAlphaStagger);
 
-        final View allAppsButtonView = mLauncher.getAllAppsButton();
         final View fromView = mLauncher.getWorkspace();
 
         final HashMap<View, Integer> layerViews = new HashMap<>();
 
         // If for some reason our views aren't initialized, don't animate
-        boolean initialized = allAppsButtonView != null;
+        boolean initialized = buttonView != null;
 
         // Cancel the current animation
         cancelAnimation();
@@ -275,16 +243,17 @@
             revealView.setAlpha(0f);
             revealView.setTranslationY(0f);
             revealView.setTranslationX(0f);
-            pCb.onRevealViewVisible(revealView, contentView, allAppsButtonView);
 
             // Calculate the final animation values
             final float revealViewToAlpha;
             final float revealViewToXDrift;
             final float revealViewToYDrift;
             if (material) {
+                int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
+                        buttonView, null);
                 revealViewToAlpha = pCb.getMaterialRevealViewFinalAlpha(revealView);
-                revealViewToYDrift = pCb.getMaterialRevealViewFinalYDrift(revealView);
-                revealViewToXDrift = pCb.getMaterialRevealViewFinalXDrift(revealView);
+                revealViewToYDrift = buttonViewToPanelDelta[1];
+                revealViewToXDrift = buttonViewToPanelDelta[0];
             } else {
                 revealViewToAlpha = 0f;
                 revealViewToYDrift = 2 * height / 3;
@@ -337,10 +306,9 @@
             mStateAnimation.play(itemsAlpha);
 
             if (material) {
-                // Animate the all apps button
                 float startRadius = pCb.getMaterialRevealViewStartFinalRadius();
                 AnimatorListenerAdapter listener = pCb.getMaterialRevealViewAnimatorListener(
-                        revealView, allAppsButtonView);
+                        revealView, buttonView);
                 Animator reveal = UiThreadCircularReveal.createCircularReveal(revealView, width / 2,
                         height / 2, startRadius, revealRadius);
                 reveal.setDuration(revealDuration);
@@ -453,22 +421,6 @@
             int[] mAllAppsToPanelDelta;
 
             @Override
-            public void onRevealViewVisible(View revealView, View contentView,
-                                            View allAppsButtonView) {
-                // Get the y delta between the center of the page and the center of the all apps
-                // button
-                mAllAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
-                        allAppsButtonView, null);
-            }
-            @Override
-            public float getMaterialRevealViewFinalXDrift(View revealView) {
-                return mAllAppsToPanelDelta[0];
-            }
-            @Override
-            public float getMaterialRevealViewFinalYDrift(View revealView) {
-                return mAllAppsToPanelDelta[1];
-            }
-            @Override
             float getMaterialRevealViewFinalAlpha(View revealView) {
                 // No alpha anim from all apps
                 return 1f;
@@ -499,9 +451,10 @@
             }
         };
         // Only animate the search bar if animating to spring loaded mode from all apps
-        startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage, appsView,
-                appsView.getContentView(), appsView.getRevealView(), appsView.getSearchBarView(),
-                animated, onCompleteRunnable, cb);
+        startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage,
+                mLauncher.getAllAppsButton(), appsView, appsView.getContentView(),
+                appsView.getRevealView(), appsView.getSearchBarView(), animated,
+                onCompleteRunnable, cb);
     }
 
     /**
@@ -510,23 +463,14 @@
     private void startAnimationToWorkspaceFromWidgets(final Workspace.State toWorkspaceState,
               final int toWorkspacePage, final boolean animated, final Runnable onCompleteRunnable) {
         final WidgetsContainerView widgetsView = mLauncher.getWidgetsView();
-        final Resources res = mLauncher.getResources();
         PrivateTransitionCallbacks cb = new PrivateTransitionCallbacks() {
             @Override
-            public void onRevealViewVisible(View revealView, View contentView,
-                                            View allAppsButtonView) {
-            }
-            @Override
-            public float getMaterialRevealViewFinalYDrift(View revealView) {
-                return revealView.getMeasuredHeight() / 2;
-            }
-            @Override
             float getMaterialRevealViewFinalAlpha(View revealView) {
-                return 0.4f;
+                return 0.3f;
             }
             @Override
             public AnimatorListenerAdapter getMaterialRevealViewAnimatorListener(
-                    final View revealView, final View allAppsButtonView) {
+                    final View revealView, final View widgetsButtonView) {
                 return new AnimatorListenerAdapter() {
                     public void onAnimationEnd(Animator animation) {
                         // Hide the reveal view
@@ -535,31 +479,31 @@
                 };
             }
         };
-        startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage, widgetsView,
-                widgetsView.getContentView(), widgetsView.getRevealView(), null, animated,
-                onCompleteRunnable, cb);
+        startAnimationToWorkspaceFromOverlay(toWorkspaceState, toWorkspacePage,
+                mLauncher.getWidgetsButton(), widgetsView, widgetsView.getContentView(),
+                widgetsView.getRevealView(), null, animated, onCompleteRunnable, cb);
     }
 
     /**
      * Creates and starts a new animation to the workspace.
      */
     private void startAnimationToWorkspaceFromOverlay(final Workspace.State toWorkspaceState,
-              final int toWorkspacePage, final View fromView, final View contentView,
-              final View revealView, final View overlaySearchBarView, final boolean animated,
-              final Runnable onCompleteRunnable, final PrivateTransitionCallbacks pCb) {
+              final int toWorkspacePage, final View buttonView, final View fromView,
+              final View contentView, final View revealView, final View overlaySearchBarView,
+              final boolean animated, final Runnable onCompleteRunnable,
+              final PrivateTransitionCallbacks pCb) {
         final Resources res = mLauncher.getResources();
         final boolean material = Utilities.isLmpOrAbove();
         final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
         final int itemsAlphaStagger =
                 res.getInteger(R.integer.config_overlayItemsAlphaStagger);
 
-        final View allAppsButtonView = mLauncher.getAllAppsButton();
         final View toView = mLauncher.getWorkspace();
 
         final HashMap<View, Integer> layerViews = new HashMap<>();
 
         // If for some reason our views aren't initialized, don't animate
-        boolean initialized = allAppsButtonView != null;
+        boolean initialized = buttonView != null;
 
         // Cancel the current animation
         cancelAnimation();
@@ -589,14 +533,15 @@
                 revealView.setAlpha(1f);
                 revealView.setTranslationY(0);
                 layerViews.put(revealView, BUILD_AND_SET_LAYER);
-                pCb.onRevealViewVisible(revealView, contentView, allAppsButtonView);
 
                 // Calculate the final animation values
                 final float revealViewToXDrift;
                 final float revealViewToYDrift;
                 if (material) {
-                    revealViewToYDrift = pCb.getMaterialRevealViewFinalYDrift(revealView);
-                    revealViewToXDrift = pCb.getMaterialRevealViewFinalXDrift(revealView);
+                    int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
+                            buttonView, null);
+                    revealViewToYDrift = buttonViewToPanelDelta[1];
+                    revealViewToXDrift = buttonViewToPanelDelta[0];
                 } else {
                     revealViewToYDrift = 2 * height / 3;
                     revealViewToXDrift = 0;
@@ -666,7 +611,7 @@
                     // Animate the all apps button
                     float finalRadius = pCb.getMaterialRevealViewStartFinalRadius();
                     AnimatorListenerAdapter listener =
-                            pCb.getMaterialRevealViewAnimatorListener(revealView, allAppsButtonView);
+                            pCb.getMaterialRevealViewAnimatorListener(revealView, buttonView);
                     Animator reveal = UiThreadCircularReveal.createCircularReveal(revealView, width / 2,
                             height / 2, revealRadius, finalRadius);
                     reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
diff --git a/src/com/android/launcher3/model/WidgetsModel.java b/src/com/android/launcher3/model/WidgetsModel.java
index 09a3242..15d3717 100644
--- a/src/com/android/launcher3/model/WidgetsModel.java
+++ b/src/com/android/launcher3/model/WidgetsModel.java
@@ -122,8 +122,10 @@
                 continue;
             }
             if (mAppFilter != null && !mAppFilter.shouldShowApp(componentName)) {
-                Log.d(TAG, String.format("%s is filtered and not added to the widget tray.",
+                if (DEBUG) {
+                    Log.d(TAG, String.format("%s is filtered and not added to the widget tray.",
                         packageName));
+                }
                 continue;
             }
 
diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java
index d07c955..d2ea252 100644
--- a/src/com/android/launcher3/widget/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java
@@ -163,13 +163,15 @@
         ViewGroup container = (ViewGroup) mLayoutInflater.inflate(
                 R.layout.widgets_list_row_view, parent, false);
         LinearLayout cellList = (LinearLayout) container.findViewById(R.id.widgets_cell_list);
-        MarginLayoutParams lp = (MarginLayoutParams) cellList.getLayoutParams();
+
+        // if the end padding is 0, then container view (horizontal scroll view) doesn't respect
+        // the end of the linear layout width + the start padding and doesn't allow scrolling.
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
-            lp.setMarginStart(mIndent);
+            cellList.setPaddingRelative(mIndent, 0, 1, 0);
         } else {
-            lp.leftMargin = mIndent;
+            cellList.setPadding(mIndent, 0, 1, 0);
         }
-        cellList.setLayoutParams(lp);
+
         return new WidgetsRowViewHolder(container);
     }