Merge "Use numAllAppsColumns to calculate height of all apps icons" 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/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/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 11f9ddd..60b0d17 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -50,7 +50,6 @@
 import com.android.launcher3.BaseActivity;
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Utilities;
-import com.android.launcher3.icons.BitmapRenderer;
 import com.android.launcher3.util.MainThreadInitializedObject;
 import com.android.launcher3.util.SystemUiController;
 import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
@@ -162,23 +161,6 @@
         setThumbnail(task, thumbnailData, true /* refreshNow */);
     }
 
-    /**
-     * By combining the two in a single bitmap then we only have to do a single draw
-     * call in the onDraw function. Also, this fixes a bug where the background was
-     * visible in the corners because of anti-aliasing.
-     */
-    public Bitmap combineThumbnailAndBackground(Bitmap bm) {
-        return BitmapRenderer.createHardwareBitmap(bm.getWidth(), bm.getHeight(), c -> {
-            final boolean drawBackgroundOnly = mTask == null || mTask.isLocked;
-            if (drawBackgroundOnly) {
-                c.drawPaint(mBackgroundPaint);
-            } else {
-                c.drawPaint(mBackgroundPaint);
-                c.drawBitmap(bm, 0, 0, null);
-            }
-        });
-    }
-
     /** Updates the shader, paint, matrix to redraw. */
     public void refresh() {
         refresh(false);
@@ -191,7 +173,6 @@
     private void refresh(boolean shouldRefreshOverlay) {
         if (mThumbnailData != null && mThumbnailData.thumbnail != null) {
             Bitmap bm = mThumbnailData.thumbnail;
-            bm = combineThumbnailAndBackground(bm);
             bm.prepareToDraw();
             mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
             mPaint.setShader(mBitmapShader);
@@ -213,6 +194,7 @@
      * <p>
      * If dimAlpha is 0, no dimming is applied; if dimAlpha is 1, the thumbnail will be the
      * extracted background color.
+     *
      */
     public void setDimAlpha(float dimAlpha) {
         mDimAlpha = dimAlpha;
@@ -314,6 +296,18 @@
                 return;
             }
         }
+
+        // Always draw the background since the snapshots might be translucent or partially empty
+        // (For example, tasks been reparented out of dismissing split root when drag-to-dismiss
+        // split screen).
+        canvas.drawRoundRect(x, y, width, height, cornerRadius, cornerRadius, mBackgroundPaint);
+
+        final boolean drawBackgroundOnly = mTask == null || mTask.isLocked || mBitmapShader == null
+                || mThumbnailData == null;
+        if (drawBackgroundOnly) {
+            return;
+        }
+
         canvas.drawRoundRect(x, y, width, height, cornerRadius, cornerRadius, mPaint);
     }
 
@@ -344,6 +338,7 @@
 
     private void updateThumbnailPaintFilter() {
         ColorFilter filter = getColorFilter(mDimAlpha);
+        mBackgroundPaint.setColorFilter(filter);
         int alpha = (int) (mDimAlpha * 255);
         mDimmingPaintAfterClearing.setAlpha(alpha);
         if (mBitmapShader != null) {
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);