Merge "Task thumbnail background is spilling to the front, making the BK 1px smaller to fix it" into tm-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 6bc2a93..d5c399b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -75,4 +75,15 @@
     public void hideAllApps() {
         mControllers.taskbarAllAppsController.hide();
     }
+
+    /**
+     * User expands PiP to full-screen (or split-screen) mode, try to hide the Taskbar.
+     */
+    public void onExpandPip() {
+        if (mControllers != null) {
+            final TaskbarStashController stashController = mControllers.taskbarStashController;
+            stashController.updateStateForFlag(TaskbarStashController.FLAG_IN_APP, true);
+            stashController.applyState();
+        }
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
index d79b946..7556bf4 100644
--- a/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
+++ b/quickstep/src/com/android/quickstep/interaction/TutorialFragment.java
@@ -325,7 +325,7 @@
 
     @Override
     public boolean onTouch(View view, MotionEvent motionEvent) {
-        if (mTutorialController != null) {
+        if (mTutorialController != null && !isGestureComplete()) {
             mTutorialController.hideFeedback();
         }
         // Note: Using logical-or to ensure both functions get called.
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index d041589..22491bc 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -5104,6 +5104,19 @@
                 mRecentsView.mPipCornerRadius = cornerRadius;
             }
         }
+
+        @Override
+        public void onExpandPip() {
+            MAIN_EXECUTOR.execute(() -> {
+                if (mRecentsView == null
+                        || mRecentsView.mSizeStrategy.getTaskbarController() == null) {
+                    return;
+                }
+                // Hide the task bar when leaving PiP to prevent it from flickering once
+                // the app settles in full-screen mode.
+                mRecentsView.mSizeStrategy.getTaskbarController().onExpandPip();
+            });
+        }
     }
 
     /** Get the color used for foreground scrimming the RecentsView for sharing. */
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 009ee27..0c33bce 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -982,8 +982,17 @@
      */
     public Rect getHotseatLayoutPadding(Context context) {
         if (isVerticalBarLayout()) {
-            int paddingTop = Math.max(mInsets.top - cellLayoutPaddingPx.top, 0);
-            int paddingBottom = Math.max(mInsets.bottom - cellLayoutPaddingPx.bottom, 0);
+            // The hotseat icons will be placed in the middle of the hotseat cells.
+            // Changing the hotseatCellHeightPx is not affecting hotseat icon positions
+            // in vertical bar layout.
+            // Workspace icons are moved up by a small factor. The variable diffOverlapFactor
+            // is set to account for that difference.
+            float diffOverlapFactor = iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;
+            int paddingTop = Math.max((int) (mInsets.top + cellLayoutPaddingPx.top
+                    - diffOverlapFactor), 0);
+            int paddingBottom = Math.max((int) (mInsets.bottom + cellLayoutPaddingPx.bottom
+                    + diffOverlapFactor), 0);
+
             if (isSeascape()) {
                 mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
                         hotseatBarSidePaddingEndPx, paddingBottom);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 2f9b563..1cead11 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -651,7 +651,7 @@
         mDragLayer.onOneHandedModeStateChanged(activated);
     }
 
-    private void initDeviceProfile(InvariantDeviceProfile idp) {
+    protected void initDeviceProfile(InvariantDeviceProfile idp) {
         // Load configuration-specific DeviceProfile
         mDeviceProfile = idp.getDeviceProfile(this);
         if (isInMultiWindowMode()) {
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 16264da..7687fea 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -84,7 +84,7 @@
     private final ArrayList<AdapterItem> mSearchResults = new ArrayList<>();
     private BaseAllAppsAdapter<T> mAdapter;
     private AppInfoComparator mAppNameComparator;
-    private final int mNumAppsPerRow;
+    private final int mNumAppsPerRowAllApps;
     private int mNumAppRowsInAdapter;
     private ItemInfoMatcher mItemFilter;
 
@@ -94,7 +94,7 @@
         mActivityContext = ActivityContext.lookupContext(context);
         mAppNameComparator = new AppInfoComparator(context);
         mWorkAdapterProvider = adapterProvider;
-        mNumAppsPerRow = mActivityContext.getDeviceProfile().inv.numColumns;
+        mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
         mAllAppsStore.addUpdateListener(this);
     }
 
@@ -336,7 +336,7 @@
 
             }
         }
-        if (mNumAppsPerRow != 0) {
+        if (mNumAppsPerRowAllApps != 0) {
             // Update the number of rows in the adapter after we do all the merging (otherwise, we
             // would have to shift the values again)
             int numAppsInSection = 0;
@@ -344,10 +344,10 @@
             int rowIndex = -1;
             for (AdapterItem item : mAdapterItems) {
                 item.rowIndex = 0;
-                if (AllAppsGridAdapter.isDividerViewType(item.viewType)) {
+                if (BaseAllAppsAdapter.isDividerViewType(item.viewType)) {
                     numAppsInSection = 0;
-                } else if (AllAppsGridAdapter.isIconViewType(item.viewType)) {
-                    if (numAppsInSection % mNumAppsPerRow == 0) {
+                } else if (BaseAllAppsAdapter.isIconViewType(item.viewType)) {
+                    if (numAppsInSection % mNumAppsPerRowAllApps == 0) {
                         numAppsInRow = 0;
                         rowIndex++;
                     }
@@ -365,12 +365,13 @@
                     float rowFraction = 1f / mNumAppRowsInAdapter;
                     for (FastScrollSectionInfo info : mFastScrollerSections) {
                         AdapterItem item = info.fastScrollToItem;
-                        if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
+                        if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
                             info.touchFraction = 0f;
                             continue;
                         }
 
-                        float subRowFraction = item.rowAppIndex * (rowFraction / mNumAppsPerRow);
+                        float subRowFraction =
+                                item.rowAppIndex * (rowFraction / mNumAppsPerRowAllApps);
                         info.touchFraction = item.rowIndex * rowFraction + subRowFraction;
                     }
                     break;
@@ -379,7 +380,7 @@
                     float cumulativeTouchFraction = 0f;
                     for (FastScrollSectionInfo info : mFastScrollerSections) {
                         AdapterItem item = info.fastScrollToItem;
-                        if (!AllAppsGridAdapter.isIconViewType(item.viewType)) {
+                        if (!BaseAllAppsAdapter.isIconViewType(item.viewType)) {
                             info.touchFraction = 0f;
                             continue;
                         }
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
index 1d1960d..976284d 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
@@ -163,10 +163,10 @@
     protected String mEmptySearchMessage;
     protected int mAppsPerRow;
 
-    private final LayoutInflater mLayoutInflater;
-    private final OnClickListener mOnIconClickListener;
-    private OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS;
-    private OnFocusChangeListener mIconFocusListener;
+    protected final LayoutInflater mLayoutInflater;
+    protected final OnClickListener mOnIconClickListener;
+    protected OnLongClickListener mOnIconLongClickListener = INSTANCE_ALL_APPS;
+    protected OnFocusChangeListener mIconFocusListener;
     // The click listener to send off to the market app, updated each time the search query changes.
     private OnClickListener mMarketSearchClickListener;
     private final int mExtraHeight;