Merge "Pull down should work on search box, even if all apps scroll is not at top. b/30295305" into ub-launcher3-calgary
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 5c2c4b8..4909eb3 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -89,8 +89,7 @@
         android:layout_width="match_parent"
         android:layout_height="0dp"
         android:layout_gravity="bottom"
-        android:background="@android:color/black"
-        android:elevation="16dp"
+        android:background="@color/all_apps_navbar_color"
         android:focusable="false"
         android:visibility="invisible" />
 </com.android.launcher3.allapps.AllAppsContainerView>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 21d9d5c..d5ce786 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -39,6 +39,7 @@
     <color name="all_apps_caret_color">#FFFFFFFF</color>
     <color name="all_apps_caret_shadow_color">#22000000</color>
     <color name="all_apps_container_color">#FFF2F2F2</color>
+    <color name="all_apps_navbar_color">#28000000</color>
 
     <color name="spring_loaded_panel_color">#40FFFFFF</color>
     <color name="spring_loaded_highlighted_panel_border_color">#FFF</color>
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
index 89f7286..3d71632 100644
--- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
+++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
@@ -136,11 +136,11 @@
     // Setter/getter for the track bar width for animations
     public void setTrackWidth(int width) {
         mInvalidateRect.set(mThumbOffset.x - mThumbCurvature, 0, mThumbOffset.x + mThumbWidth,
-                mRv.getHeight());
+                mRv.getVisibleHeight());
         mTrackWidth = width;
         updateThumbPath();
         mInvalidateRect.union(mThumbOffset.x - mThumbCurvature, 0, mThumbOffset.x + mThumbWidth,
-                mRv.getHeight());
+                mRv.getVisibleHeight());
         mRv.invalidate(mInvalidateRect);
     }
 
@@ -198,7 +198,7 @@
                 if (mIsDragging) {
                     // Update the fastscroller section name at this touch position
                     int top = mRv.getBackgroundPadding().top;
-                    int bottom = mRv.getHeight() - mRv.getBackgroundPadding().bottom - mThumbHeight;
+                    int bottom = top + mRv.getVisibleHeight() - mThumbHeight;
                     float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset));
                     String sectionName = mRv.scrollToPositionAtProgress((boundedY - top) /
                             (bottom - top));
@@ -230,7 +230,8 @@
 
         // Draw the scroll bar track and thumb
         if (mTrackPaint.getAlpha() > 0) {
-            canvas.drawRect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, mRv.getHeight(), mTrackPaint);
+            canvas.drawRect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth,
+                    mRv.getVisibleHeight(), mTrackPaint);
         }
         canvas.drawPath(mThumbPath, mThumbPaint);
 
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java
index b4567c5..b9e6277 100644
--- a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java
+++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java
@@ -112,7 +112,7 @@
             }
             mBgBounds.top = lastTouchY - (int) (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * bgHeight);
             mBgBounds.top = Math.max(edgePadding,
-                    Math.min(mBgBounds.top, mRv.getHeight() - edgePadding - bgHeight));
+                    Math.min(mBgBounds.top, mRv.getVisibleHeight() - edgePadding - bgHeight));
             mBgBounds.bottom = mBgBounds.top + bgHeight;
 
             // Generate a bitmap for a shadow matching these bounds
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d76d3e2..adf07a1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2668,6 +2668,12 @@
                 // If the app is only disabled because of the above flags, launch activity anyway.
                 // Framework will tell the user why the app is suspended.
             } else {
+                if (!TextUtils.isEmpty(shortcut.disabledMessage)) {
+                    // Use a message specific to this shortcut, if it has one.
+                    Toast.makeText(this, shortcut.disabledMessage, Toast.LENGTH_SHORT).show();
+                    return;
+                }
+                // Otherwise just use a generic error message.
                 int error = R.string.activity_not_available;
                 if ((shortcut.isDisabled & ShortcutInfo.FLAG_DISABLED_SAFEMODE) != 0) {
                     error = R.string.safemode_shortcut_error;
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 2b1ebde..eb70650 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -265,7 +265,6 @@
             toView.setScaleY(1.0f);
             toView.setAlpha(1.0f);
             toView.setVisibility(View.VISIBLE);
-            toView.bringToFront();
 
             // Show the content view
             contentView.setVisibility(View.VISIBLE);
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index a2182e8..8c466b2 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -133,6 +133,12 @@
      */
     int isDisabled = DEFAULT;
 
+    /**
+     * A message to display when the user tries to start a disabled shortcut.
+     * This is currently only used for deep shortcuts.
+     */
+    CharSequence disabledMessage;
+
     int status;
 
     /**
@@ -309,6 +315,7 @@
         } else {
             isDisabled |= FLAG_DISABLED_BY_PUBLISHER;
         }
+        disabledMessage = shortcutInfo.getDisabledMessage();
 
         // TODO: Use cache for this
         LauncherAppState launcherAppState = LauncherAppState.getInstance();
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index b4ca7ed..c7bc23b 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -470,7 +470,7 @@
                 MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams();
 
                 Rect insets = mLauncher.getDragLayer().getInsets();
-                getContentView().setPadding(0, 0, 0, insets.bottom);
+                getContentView().setPadding(0, 0, 0, 0);
                 int height = insets.top + grid.hotseatCellHeightPx;
 
                 mlp.topMargin = height;
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index d8f9fb1..39ab58b 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -38,7 +38,6 @@
 
 import com.android.launcher3.AppInfo;
 import com.android.launcher3.BubbleTextView;
-import com.android.launcher3.CellLayout;
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
@@ -49,7 +48,6 @@
 import java.util.HashMap;
 import java.util.List;
 
-
 /**
  * The grid view adapter of all the apps.
  */
@@ -134,6 +132,11 @@
                 return super.getRowCountForAccessibility(recycler, state);
             }
         }
+
+        @Override
+        public int getPaddingBottom() {
+            return mLauncher.getDragLayer().getInsets().bottom;
+        }
     }
 
     /**
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 55f544c..09076b3 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -28,6 +28,7 @@
 import com.android.launcher3.BubbleTextView;
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.ItemInfo;
+import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
 import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider;
 import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -423,6 +424,12 @@
         return getPaddingTop() + y - offset;
     }
 
+    @Override
+    protected int getVisibleHeight() {
+        return super.getVisibleHeight()
+                - Launcher.getLauncher(getContext()).getDragLayer().getInsets().bottom;
+    }
+
     /**
      * Returns the available scroll height:
      *   AvailableScrollHeight = Total height of the all items - last page height
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 337de46..5888230 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -262,10 +262,10 @@
             // Initialize values that should not change until #onDragEnd
             mStatusBarHeight = mLauncher.getDragLayer().getInsets().top;
             mHotseat.setVisibility(View.VISIBLE);
+            mHotseatBackgroundColor = mHotseat.getBackgroundDrawableColor();
+            mHotseat.setBackgroundTransparent(true /* transparent */);
             if (!mLauncher.isAllAppsVisible()) {
                 mLauncher.tryAndUpdatePredictedApps();
-                mHotseatBackgroundColor = mHotseat.getBackgroundDrawableColor();
-                mHotseat.setBackgroundTransparent(true /* transparent */);
                 mAppsView.setVisibility(View.VISIBLE);
                 mAppsView.setRevealDrawableColor(mHotseatBackgroundColor);
             }
diff --git a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
index 410693a..a6da668 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
@@ -114,6 +114,10 @@
         return mShortcutInfo.getRank();
     }
 
+    public CharSequence getDisabledMessage() {
+        return mShortcutInfo.getDisabledMessage();
+    }
+
     @Override
     public String toString() {
         return mShortcutInfo.toString();