Merge "Pass sourceRectHint to auto-enter-pip transition" into tm-dev
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 0e391ce..36c9d13 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -526,7 +526,7 @@
             endListener = composeViewContentAnimator(launcherAnimator, alphas, scales);
         } else {
             List<View> viewsToAnimate = new ArrayList<>();
-            Workspace workspace = mLauncher.getWorkspace();
+            Workspace<?> workspace = mLauncher.getWorkspace();
             workspace.forEachVisiblePage(
                     view -> viewsToAnimate.add(((CellLayout) view).getShortcutsAndWidgets()));
 
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
index 680012c..d63bc18 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
@@ -131,7 +131,7 @@
     private int placeFoldersInWorkspace(ArrayDeque<FolderInfo> folders) {
         if (folders.isEmpty()) return 0;
 
-        Workspace workspace = mLauncher.getWorkspace();
+        Workspace<?> workspace = mLauncher.getWorkspace();
         InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
 
         GridOccupancy[] occupancyList = new GridOccupancy[workspace.getChildCount()];
@@ -176,7 +176,7 @@
      * @return pageId where items are migrated
      */
     private int migrateHotseatWhole() {
-        Workspace workspace = mLauncher.getWorkspace();
+        Workspace<?> workspace = mLauncher.getWorkspace();
 
         int pageId = -1;
         int toRow = 0;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 296000b..a22398d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -29,6 +29,7 @@
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
 import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
 import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
+import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_SIZE;
 
 import android.animation.AnimatorSet;
 import android.app.ActivityOptions;
@@ -214,8 +215,12 @@
         );
         // Adjust the frame by the rounded corners (ie. leaving just the bar as the inset) when
         // the IME is showing
-        mWindowLayoutParams.providedInternalImeInsets = Insets.of(0,
+        mWindowLayoutParams.providedInternalImeInsets = new Insets[ITYPE_SIZE];
+        final Insets reducingSize = Insets.of(0,
                 getDefaultTaskbarWindowHeight() - mTaskbarHeightForIme, 0, 0);
+        mWindowLayoutParams.providedInternalImeInsets[ITYPE_EXTRA_NAVIGATION_BAR] = reducingSize;
+        mWindowLayoutParams.providedInternalImeInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT] =
+                reducingSize;
 
         mWindowLayoutParams.insetsRoundedCornerFrame = true;
 
@@ -563,8 +568,14 @@
             }
         }
         mWindowLayoutParams.height = height;
-        mWindowLayoutParams.providedInternalImeInsets =
+        final Insets reducingSize =
                 Insets.of(0, height - mTaskbarHeightForIme, 0, 0);
+        if (mWindowLayoutParams.providedInternalImeInsets == null) {
+            mWindowLayoutParams.providedInternalImeInsets = new Insets[ITYPE_SIZE];
+        }
+        mWindowLayoutParams.providedInternalImeInsets[ITYPE_EXTRA_NAVIGATION_BAR] = reducingSize;
+        mWindowLayoutParams.providedInternalImeInsets[ITYPE_BOTTOM_TAPPABLE_ELEMENT] =
+                reducingSize;
         mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
     }
 
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index eed67b6..36e6420 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -26,6 +26,7 @@
 import android.animation.ObjectAnimator;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.BaseQuickstepLauncher;
@@ -74,6 +75,8 @@
     private int mState;
     private LauncherState mLauncherState = LauncherState.NORMAL;
 
+    private @Nullable TaskBarRecentsAnimationListener mTaskBarRecentsAnimationListener;
+
     private boolean mIsAnimatingToLauncherViaGesture;
     private boolean mIsAnimatingToLauncherViaResume;
 
@@ -163,12 +166,11 @@
         animatorSet.play(stashController.applyStateWithoutStart(duration));
         animatorSet.play(applyState(duration, false));
 
-        TaskBarRecentsAnimationListener listener = new TaskBarRecentsAnimationListener(callbacks);
-        callbacks.addListener(listener);
+        mTaskBarRecentsAnimationListener = new TaskBarRecentsAnimationListener(callbacks);
+        callbacks.addListener(mTaskBarRecentsAnimationListener);
         RecentsView recentsView = mLauncher.getOverviewPanel();
         recentsView.setTaskLaunchListener(() -> {
-            listener.endGestureStateOverride(true);
-            callbacks.removeListener(listener);
+            mTaskBarRecentsAnimationListener.endGestureStateOverride(true);
         });
         return animatorSet;
     }
@@ -257,7 +259,10 @@
         if (hasAnyFlag(changedFlags, FLAG_RESUMED)
                 || launcherStateChangedDuringAnimToResumeAlignment) {
             boolean isResumed = isResumed();
-            float toAlignmentForResumedState = isResumed && goingToUnstashedLauncherState() ? 1 : 0;
+            // If launcher is resumed, we show the icons when going to an unstashed launcher state
+            // or launcher state is not changed (e.g. in overview, launcher is paused and resumed).
+            float toAlignmentForResumedState = isResumed && (goingToUnstashedLauncherState()
+                    || !goingToUnstashedLauncherStateChanged) ? 1 : 0;
             // If we're already animating to the value, just leave it be instead of restarting it.
             if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) {
                 ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState
@@ -379,7 +384,7 @@
     }
 
     private void onIconAlignmentRatioChangedForStateTransition() {
-        if (!isResumed()) {
+        if (!isResumed() && mTaskBarRecentsAnimationListener == null) {
             return;
         }
         onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioForLauncherState);
@@ -455,6 +460,7 @@
 
         private void endGestureStateOverride(boolean finishedToApp) {
             mCallbacks.removeListener(this);
+            mTaskBarRecentsAnimationListener = null;
 
             // Update the resumed state immediately to ensure a seamless handoff
             boolean launcherResumed = !finishedToApp;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 3521ee3..be67136 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -33,6 +33,7 @@
 
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Utilities;
+import com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView;
 import com.android.launcher3.testing.TestProtocol;
 import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
 import com.android.quickstep.AnimatedFloat;
@@ -518,14 +519,41 @@
      */
     public void setSystemGestureInProgress(boolean inProgress) {
         mIsSystemGestureInProgress = inProgress;
-        // Only update FLAG_STASHED_IN_APP_IME when system gesture is not in progress.
-        if (!mIsSystemGestureInProgress) {
+        if (mIsSystemGestureInProgress) {
+            return;
+        }
+
+        // Only update the following flags when system gesture is not in progress.
+        maybeResetStashedInAppAllApps(hasAnyFlag(FLAG_STASHED_IN_APP_IME) == mIsImeShowing);
+        if (hasAnyFlag(FLAG_STASHED_IN_APP_IME) != mIsImeShowing) {
             updateStateForFlag(FLAG_STASHED_IN_APP_IME, mIsImeShowing);
             applyState(TASKBAR_STASH_DURATION_FOR_IME, getTaskbarStashStartDelayForIme());
         }
     }
 
     /**
+     * Reset stashed in all apps only if no system gesture is in progress.
+     * <p>
+     * Otherwise, the reset should be deferred until after the gesture is finished.
+     *
+     * @see #setSystemGestureInProgress
+     */
+    public void maybeResetStashedInAppAllApps() {
+        maybeResetStashedInAppAllApps(true);
+    }
+
+    private void maybeResetStashedInAppAllApps(boolean applyState) {
+        if (mIsSystemGestureInProgress) {
+            return;
+        }
+
+        updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, false);
+        if (applyState) {
+            applyState(TaskbarAllAppsSlideInView.DEFAULT_CLOSE_DURATION);
+        }
+    }
+
+    /**
      * When hiding the IME, delay the unstash animation to align with the end of the transition.
      */
     private long getTaskbarStashStartDelayForIme() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
index 5d2d72a..a37ebac 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java
@@ -34,7 +34,7 @@
 public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarAllAppsContext>
         implements Insettable, DeviceProfile.OnDeviceProfileChangeListener {
     static final int DEFAULT_OPEN_DURATION = 500;
-    static final int DEFAULT_CLOSE_DURATION = 200;
+    public static final int DEFAULT_CLOSE_DURATION = 200;
 
     private TaskbarAllAppsContainerView mAppsView;
     private OnCloseListener mOnCloseBeginListener;
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
index 32ebbe8..f19b7de 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java
@@ -16,7 +16,6 @@
 package com.android.launcher3.taskbar.allapps;
 
 import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_ALL_APPS;
-import static com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView.DEFAULT_CLOSE_DURATION;
 import static com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView.DEFAULT_OPEN_DURATION;
 import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;
 
@@ -86,9 +85,9 @@
         mSlideInView.setOnCloseBeginListener(() -> {
             AbstractFloatingView.closeOpenContainer(
                     mContext, AbstractFloatingView.TYPE_ACTION_POPUP);
-            mTaskbarStashController.updateStateForFlag(
-                    FLAG_STASHED_IN_APP_ALL_APPS, false);
-            mTaskbarStashController.applyState(DEFAULT_CLOSE_DURATION);
+            // Post in case view is closing due to gesture navigation. If a gesture is in progress,
+            // wait to unstash until after the gesture is finished.
+            mSlideInView.post(mTaskbarStashController::maybeResetStashedInAppAllApps);
         });
     }
 }
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 829accc..f32b315 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -263,7 +263,7 @@
 
         switch (state.ordinal) {
             case HINT_STATE_ORDINAL: {
-                Workspace workspace = getWorkspace();
+                Workspace<?> workspace = getWorkspace();
                 getStateManager().goToState(NORMAL);
                 if (workspace.getNextPage() != Workspace.DEFAULT_PAGE) {
                     workspace.post(workspace::moveToDefaultScreen);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
index 4d05349..b1d83e7 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
@@ -118,7 +118,7 @@
             config.duration = Math.max(config.duration, scrollDuration);
             overview.snapToPage(DEFAULT_PAGE, Math.toIntExact(config.duration));
 
-            Workspace workspace = mActivity.getWorkspace();
+            Workspace<?> workspace = mActivity.getWorkspace();
             // Start from a higher workspace scale, but only if we're invisible so we don't jump.
             boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE;
             if (isWorkspaceVisible) {
diff --git a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java
index 6f171f9..97be437 100644
--- a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java
+++ b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java
@@ -45,7 +45,7 @@
     // Percentage of the width of the quick search bar that will be reduced
     // from the both sides of the bar when progress is 0
     private static final float MAX_WIDTH_INSET_FRACTION = 0.15f;
-    private static final FloatProperty<Workspace> WORKSPACE_SCALE_PROPERTY =
+    private static final FloatProperty<Workspace<?>> WORKSPACE_SCALE_PROPERTY =
             WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_UNFOLD_ANIMATION);
     private static final FloatProperty<Hotseat> HOTSEAT_SCALE_PROPERTY =
             HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_UNFOLD_ANIMATION);
diff --git a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
index 44396fa..b1e2eac 100644
--- a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
+++ b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
@@ -92,7 +92,7 @@
 
         if (staggerWorkspace) {
             DeviceProfile grid = launcher.getDeviceProfile();
-            Workspace workspace = launcher.getWorkspace();
+            Workspace<?> workspace = launcher.getWorkspace();
             Hotseat hotseat = launcher.getHotseat();
 
             // Hotseat and QSB takes up two additional rows.
diff --git a/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java b/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java
index 3d72398..354d157 100644
--- a/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java
+++ b/quickstep/src/com/android/quickstep/util/UnfoldMoveFromCenterWorkspaceAnimator.java
@@ -37,7 +37,7 @@
 
     @Override
     protected void onPrepareViewsForAnimation() {
-        Workspace workspace = mLauncher.getWorkspace();
+        Workspace<?> workspace = mLauncher.getWorkspace();
 
         // App icons and widgets
         workspace
diff --git a/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java b/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java
index 5326d2b..5eb543e 100644
--- a/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java
+++ b/quickstep/src/com/android/quickstep/util/WorkspaceRevealAnim.java
@@ -53,7 +53,7 @@
 
     // Should be used for animations running alongside this WorkspaceRevealAnim.
     public static final int DURATION_MS = 350;
-    private static final FloatProperty<Workspace> WORKSPACE_SCALE_PROPERTY =
+    private static final FloatProperty<Workspace<?>> WORKSPACE_SCALE_PROPERTY =
             WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_REVEAL_ANIM);
 
     private static final FloatProperty<Hotseat> HOTSEAT_SCALE_PROPERTY =
@@ -68,7 +68,7 @@
         ResourceProvider rp = DynamicResource.provider(launcher);
         mScaleStart = rp.getFloat(R.dimen.swipe_up_scale_start);
 
-        Workspace workspace = launcher.getWorkspace();
+        Workspace<?> workspace = launcher.getWorkspace();
         workspace.setPivotToScaleWithSelf(launcher.getHotseat());
 
         // Add reveal animations.
diff --git a/quickstep/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/src/com/android/quickstep/views/ClearAllButton.java
index 332cbeb..50be5ea 100644
--- a/quickstep/src/com/android/quickstep/views/ClearAllButton.java
+++ b/quickstep/src/com/android/quickstep/views/ClearAllButton.java
@@ -141,7 +141,10 @@
         }
         applyPrimaryTranslation();
         applySecondaryTranslation();
-        mScrollAlpha = 1 - shift / orientationSize;
+        float clearAllSpacing =
+                recentsView.getPageSpacing() + recentsView.getClearAllExtraPageSpacing();
+        clearAllSpacing = mIsRtl ? -clearAllSpacing : clearAllSpacing;
+        mScrollAlpha = Math.max((clearAllScroll + clearAllSpacing - scroll) / clearAllSpacing, 0);
         updateAlpha();
     }
 
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index e64e439..c6d26a1 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -383,7 +383,7 @@
     private static final float ANIMATION_DISMISS_PROGRESS_MIDPOINT = 0.5f;
     private static final float END_DISMISS_TRANSLATION_INTERPOLATION_OFFSET = 0.75f;
 
-    private static final float SIGNIFICANT_MOVE_THRESHOLD_TABLET = 0.15f;
+    private static final float SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE = 0.15f;
 
     protected final RecentsOrientedState mOrientationState;
     protected final BaseActivityInterface<STATE_TYPE, ACTIVITY_TYPE> mSizeStrategy;
@@ -1195,9 +1195,14 @@
     }
 
     @Override
-    protected float getSignificantMoveThreshold() {
-        return mActivity.getDeviceProfile().isTablet ? SIGNIFICANT_MOVE_THRESHOLD_TABLET
-                : super.getSignificantMoveThreshold();
+    protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) {
+        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
+        if (!deviceProfile.isTablet) {
+            return super.isSignificantMove(absoluteDelta, pageOrientedSize);
+        }
+
+        return absoluteDelta
+                > deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
     }
 
     @Override
@@ -1289,10 +1294,11 @@
                     return;
                 }
                 TaskView taskView = getTaskViewAt(mNextPage);
-                // Only snap to fully visible focused task.
-                if (taskView == null
-                        || !taskView.isFocusedTask()
-                        || !isTaskViewFullyVisible(taskView)) {
+                // Snap to fully visible focused task and clear all button.
+                boolean shouldSnapToFocusedTask = taskView != null && taskView.isFocusedTask()
+                        && isTaskViewFullyVisible(taskView);
+                boolean shouldSnapToClearAll = mNextPage == indexOfChild(mClearAllButton);
+                if (!shouldSnapToFocusedTask && !shouldSnapToClearAll) {
                     return;
                 }
             }
@@ -4535,7 +4541,7 @@
                 ? getClearAllExtraPageSpacing() : 0;
     }
 
-    private int getClearAllExtraPageSpacing() {
+    protected int getClearAllExtraPageSpacing() {
         return showAsGrid()
                 ? Math.max(mActivity.getDeviceProfile().overviewGridSideMargin - mPageSpacing, 0)
                 : 0;
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 652a61c..422240c 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -37,4 +37,7 @@
     <dimen name="drop_target_button_drawable_vertical_padding">2dp</dimen>
     <dimen name="drop_target_top_margin">6dp</dimen>
     <dimen name="drop_target_bottom_margin">6dp</dimen>
+
+    <!-- Workspace grid visualization parameters -->
+    <dimen name="grid_visualization_horizontal_cell_spacing">24dp</dimen>
 </resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 27b13d7..602dd6d 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -46,4 +46,7 @@
     <dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
     <dimen name="drop_target_button_drawable_vertical_padding">16dp</dimen>
     <dimen name="dynamic_grid_drop_target_size">56dp</dimen>
+
+<!-- Workspace grid visualization parameters -->
+    <dimen name="grid_visualization_horizontal_cell_spacing">6dp</dimen>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 9a41070..e5e2217 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -381,8 +381,9 @@
 
 
 <!-- Workspace grid visualization parameters -->
-    <dimen name="grid_visualization_rounding_radius">22dp</dimen>
-    <dimen name="grid_visualization_cell_spacing">6dp</dimen>
+    <dimen name="grid_visualization_rounding_radius">28dp</dimen>
+    <dimen name="grid_visualization_horizontal_cell_spacing">6dp</dimen>
+    <dimen name="grid_visualization_vertical_cell_spacing">6dp</dimen>
 
 <!-- Search results related parameters -->
     <dimen name="search_row_icon_size">48dp</dimen>
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index 300f22b..4b4a017 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -383,7 +383,7 @@
 
         // Handle invalid resize across CellLayouts in the two panel UI.
         if (mCellLayout.getParent() instanceof Workspace) {
-            Workspace workspace = (Workspace) mCellLayout.getParent();
+            Workspace<?> workspace = (Workspace<?>) mCellLayout.getParent();
             CellLayout pairedCellLayout = workspace.getScreenPair(mCellLayout);
             if (pairedCellLayout != null) {
                 Rect focusedCellLayoutBound = sTmpRect;
@@ -570,7 +570,7 @@
         final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
         final CellLayout pairedCellLayout;
         if (mCellLayout.getParent() instanceof Workspace) {
-            Workspace workspace = (Workspace) mCellLayout.getParent();
+            Workspace<?> workspace = (Workspace<?>) mCellLayout.getParent();
             pairedCellLayout = workspace.getScreenPair(mCellLayout);
         } else {
             pairedCellLayout = null;
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index d235180..87bbac6 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -148,7 +148,8 @@
     private boolean mVisualizeDropLocation = true;
     private RectF mVisualizeGridRect = new RectF();
     private Paint mVisualizeGridPaint = new Paint();
-    private int mGridVisualizationPadding;
+    private int mGridVisualizationPaddingX;
+    private int mGridVisualizationPaddingY;
     private int mGridVisualizationRoundingRadius;
     private float mGridAlpha = 0f;
     private int mGridColor = 0;
@@ -260,8 +261,10 @@
         mBackground.setAlpha(0);
 
         mGridColor = Themes.getAttrColor(getContext(), R.attr.workspaceAccentColor);
-        mGridVisualizationPadding =
-                res.getDimensionPixelSize(R.dimen.grid_visualization_cell_spacing);
+        mGridVisualizationPaddingX = res.getDimensionPixelSize(
+                R.dimen.grid_visualization_horizontal_cell_spacing);
+        mGridVisualizationPaddingY = res.getDimensionPixelSize(
+                R.dimen.grid_visualization_vertical_cell_spacing);
         mGridVisualizationRoundingRadius =
                 res.getDimensionPixelSize(R.dimen.grid_visualization_rounding_radius);
         mReorderPreviewAnimationMagnitude = (REORDER_PREVIEW_MAGNITUDE * deviceProfile.iconSizePx);
@@ -591,8 +594,8 @@
 
     protected void visualizeGrid(Canvas canvas) {
         DeviceProfile dp = mActivity.getDeviceProfile();
-        int paddingX = (int) Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPadding);
-        int paddingY = (int) Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPadding);
+        int paddingX = Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPaddingX);
+        int paddingY = Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPaddingY);
         mVisualizeGridRect.set(paddingX, paddingY,
                 mCellWidth - paddingX,
                 mCellHeight - paddingY);
@@ -1200,7 +1203,7 @@
             return getContext().getString(R.string.move_to_hotseat_position,
                     Math.max(cellX, cellY) + 1);
         } else {
-            Workspace workspace = getWorkspace();
+            Workspace<?> workspace = getWorkspace();
             int row = cellY + 1;
             int col = workspace.mIsRtl ? mCountX - cellX : cellX + 1;
             int panelCount = workspace.getPanelCount();
@@ -1214,7 +1217,7 @@
         }
     }
 
-    private Workspace getWorkspace() {
+    private Workspace<?> getWorkspace() {
         return Launcher.cast(mActivity).getWorkspace();
     }
 
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index b94cdbf..ec3629d 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -179,7 +179,7 @@
         }
 
         Launcher launcher = Launcher.getLauncher(getContext());
-        Workspace workspace = launcher.getWorkspace();
+        Workspace<?> workspace = launcher.getWorkspace();
         DeviceProfile dp = launcher.getDeviceProfile();
         int buttonHorizontalPadding = dp.dropTargetHorizontalPaddingPx;
         int buttonVerticalPadding = dp.dropTargetVerticalPaddingPx;
@@ -252,8 +252,7 @@
                 int overlap = start + leftButton.getMeasuredWidth() + rightButton.getMeasuredWidth()
                         - end;
                 if (overlap > 0) {
-                    start -= overlap / 2;
-                    end += overlap / 2;
+                    end += overlap;
                 }
 
                 leftButton.layout(start, 0, start + leftButton.getMeasuredWidth(),
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 9c749aa7..d1d6c18 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -41,7 +41,7 @@
 
     @ViewDebug.ExportedProperty(category = "launcher")
     private boolean mHasVerticalHotseat;
-    private Workspace mWorkspace;
+    private Workspace<?> mWorkspace;
     private boolean mSendTouchToWorkspace;
     @Nullable
     private Consumer<Boolean> mOnVisibilityAggregatedCallback;
@@ -122,7 +122,7 @@
         InsettableFrameLayout.dispatchInsets(this, insets);
     }
 
-    public void setWorkspace(Workspace w) {
+    public void setWorkspace(Workspace<?> w) {
         mWorkspace = w;
     }
 
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3cc8a81..923e614 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2360,7 +2360,7 @@
         // Get the list of added items and intersect them with the set of items here
         final Collection<Animator> bounceAnims = new ArrayList<>();
         boolean canAnimatePageChange = canAnimatePageChange();
-        Workspace workspace = mWorkspace;
+        Workspace<?> workspace = mWorkspace;
         int newItemsScreenId = -1;
         int end = items.size();
         View newView = null;
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index 4f3ae59..808bf96 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -72,8 +72,8 @@
      * of all the ones set, to have a smooth experience even in the case of overlapping scaling
      * animation.
      */
-    public static final MultiScalePropertyFactory<Workspace> WORKSPACE_SCALE_PROPERTY_FACTORY =
-            new MultiScalePropertyFactory<Workspace>("workspace_scale_property");
+    public static final MultiScalePropertyFactory<Workspace<?>> WORKSPACE_SCALE_PROPERTY_FACTORY =
+            new MultiScalePropertyFactory<Workspace<?>>("workspace_scale_property");
 
     /** Property to set the scale of hotseat. */
     public static final MultiScalePropertyFactory<Hotseat> HOTSEAT_SCALE_PROPERTY_FACTORY =
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 1eb493b..f5ac359 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1195,8 +1195,8 @@
         mAllowOverScroll = enable;
     }
 
-    protected float getSignificantMoveThreshold() {
-        return SIGNIFICANT_MOVE_THRESHOLD;
+    protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) {
+        return absoluteDelta > pageOrientedSize * SIGNIFICANT_MOVE_THRESHOLD;
     }
 
     @Override
@@ -1322,13 +1322,12 @@
                 velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
 
                 int velocity = (int) mOrientationHandler.getPrimaryVelocity(velocityTracker,
-                    mActivePointerId);
+                        mActivePointerId);
                 float delta = primaryDirection - mDownMotionPrimary;
-                delta /= mOrientationHandler.getPrimaryScale(this);
-                int pageOrientedSize = mOrientationHandler.getMeasuredSize(getPageAt(mCurrentPage));
-
-                boolean isSignificantMove = Math.abs(delta)
-                        > pageOrientedSize * getSignificantMoveThreshold();
+                int pageOrientedSize = (int) (mOrientationHandler.getMeasuredSize(
+                        getPageAt(mCurrentPage))
+                        * mOrientationHandler.getPrimaryScale(this));
+                boolean isSignificantMove = isSignificantMove(Math.abs(delta), pageOrientedSize);
 
                 mTotalMotion += Math.abs(mLastMotion + mLastMotionRemainder - primaryDirection);
                 boolean passedSlop = mAllowEasyFling || mTotalMotion > mPageSlop;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 61090e7..86e88b7 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -149,6 +149,8 @@
      * {@link #isFinishedSwitchingState()} ()} to return true. */
     private static final float FINISHED_SWITCHING_STATE_TRANSITION_PROGRESS = 0.5f;
 
+    private static final float SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE = 0.15f;
+
     private static final boolean ENFORCE_DRAG_EVENT_ORDER = false;
 
     private static final int ADJACENT_SCREEN_DROP_DURATION = 300;
@@ -3410,6 +3412,17 @@
         return getContext().getString(R.string.workspace_scroll_format, currentPage, totalPages);
     }
 
+    @Override
+    protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) {
+        DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
+        if (!deviceProfile.isTablet) {
+            return super.isSignificantMove(absoluteDelta, pageOrientedSize);
+        }
+
+        return absoluteDelta
+                > deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
+    }
+
     /**
      * Used as a workaround to ensure that the AppWidgetService receives the
      * PACKAGE_ADDED broadcast before updating widgets.
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 1e09b2d..84b95ec 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -67,18 +67,18 @@
  */
 public class WorkspaceStateTransitionAnimation {
 
-    private static final FloatProperty<Workspace> WORKSPACE_SCALE_PROPERTY =
+    private static final FloatProperty<Workspace<?>> WORKSPACE_SCALE_PROPERTY =
             WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WORKSPACE_STATE);
 
     private static final FloatProperty<Hotseat> HOTSEAT_SCALE_PROPERTY =
             HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WORKSPACE_STATE);
 
     private final Launcher mLauncher;
-    private final Workspace mWorkspace;
+    private final Workspace<?> mWorkspace;
 
     private float mNewScale;
 
-    public WorkspaceStateTransitionAnimation(Launcher launcher, Workspace workspace) {
+    public WorkspaceStateTransitionAnimation(Launcher launcher, Workspace<?> workspace) {
         mLauncher = launcher;
         mWorkspace = workspace;
     }
@@ -224,7 +224,7 @@
      * Returns a spring based animator for the scale property of {@param workspace}.
      */
     public static ValueAnimator getWorkspaceSpringScaleAnimator(Launcher launcher,
-            Workspace workspace, float scale) {
+            Workspace<?> workspace, float scale) {
         return getSpringScaleAnimator(launcher, workspace, scale, WORKSPACE_SCALE_PROPERTY);
     }
 
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 18c05eb..462daf5 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -19,7 +19,7 @@
 import com.android.launcher3.ButtonDropTarget;
 import com.android.launcher3.CellLayout;
 import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherSettings.Favorites;
+import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.PendingAddItemInfo;
 import com.android.launcher3.R;
 import com.android.launcher3.Workspace;
@@ -153,61 +153,9 @@
         } else if (action == MOVE) {
             return beginAccessibleDrag(host, item, fromKeyboard);
         } else if (action == ADD_TO_WORKSPACE) {
-            final int[] coordinates = new int[2];
-            final int screenId = findSpaceOnWorkspace(item, coordinates);
-            if (screenId == -1) {
-                return false;
-            }
-            mContext.getStateManager().goToState(NORMAL, true, forSuccessCallback(() -> {
-                if (item instanceof AppInfo) {
-                    WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
-                    mContext.getModelWriter().addItemToDatabase(info,
-                            Favorites.CONTAINER_DESKTOP,
-                            screenId, coordinates[0], coordinates[1]);
-
-                    mContext.bindItems(
-                            Collections.singletonList(info),
-                            /* forceAnimateIcons= */ true,
-                            /* focusFirstItemForAccessibility= */ true);
-                    announceConfirmation(R.string.item_added_to_workspace);
-                } else if (item instanceof PendingAddItemInfo) {
-                    PendingAddItemInfo info = (PendingAddItemInfo) item;
-                    Workspace workspace = mContext.getWorkspace();
-                    workspace.snapToPage(workspace.getPageIndexForScreenId(screenId));
-                    mContext.addPendingItem(info, Favorites.CONTAINER_DESKTOP,
-                            screenId, coordinates, info.spanX, info.spanY);
-                }
-                else if (item instanceof WorkspaceItemInfo) {
-                    WorkspaceItemInfo info = ((WorkspaceItemInfo) item).clone();
-                    mContext.getModelWriter().addItemToDatabase(info,
-                            Favorites.CONTAINER_DESKTOP,
-                            screenId, coordinates[0], coordinates[1]);
-                    mContext.bindItems(Collections.singletonList(info), true, true);
-                }
-            }));
-            return true;
+            return addToWorkspace(item, true);
         } else if (action == MOVE_TO_WORKSPACE) {
-            Folder folder = Folder.getOpen(mContext);
-            folder.close(true);
-            WorkspaceItemInfo info = (WorkspaceItemInfo) item;
-            folder.getInfo().remove(info, false);
-
-            final int[] coordinates = new int[2];
-            final int screenId = findSpaceOnWorkspace(item, coordinates);
-            if (screenId == -1) {
-                return false;
-            }
-            mContext.getModelWriter().moveItemInDatabase(info,
-                    Favorites.CONTAINER_DESKTOP,
-                    screenId, coordinates[0], coordinates[1]);
-
-            // Bind the item in next frame so that if a new workspace page was created,
-            // it will get laid out.
-            new Handler().post(() -> {
-                mContext.bindItems(Collections.singletonList(item), true);
-                announceConfirmation(R.string.item_moved);
-            });
-            return true;
+            return moveToWorkspace(item);
         } else if (action == RESIZE) {
             final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) item;
             List<OptionItem> actions = getSupportedResizeActions(host, info);
@@ -403,4 +351,76 @@
         }
         return screenId;
     }
+
+    /**
+     * Functionality to add the item {@link ItemInfo} to the workspace
+     * @param item item to be added
+     * @param accessibility true if the first item to be added to the workspace
+     *     should be focused for accessibility.
+     *
+     * @return true if the item could be successfully added
+     */
+    public boolean addToWorkspace(ItemInfo item, boolean accessibility) {
+        final int[] coordinates = new int[2];
+        final int screenId = findSpaceOnWorkspace(item, coordinates);
+        if (screenId == -1) {
+            return false;
+        }
+        mContext.getStateManager().goToState(NORMAL, true, forSuccessCallback(() -> {
+            if (item instanceof AppInfo) {
+                WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem();
+                mContext.getModelWriter().addItemToDatabase(info,
+                        LauncherSettings.Favorites.CONTAINER_DESKTOP,
+                        screenId, coordinates[0], coordinates[1]);
+
+                mContext.bindItems(
+                        Collections.singletonList(info),
+                        /* forceAnimateIcons= */ true,
+                        /* focusFirstItemForAccessibility= */ accessibility);
+                announceConfirmation(R.string.item_added_to_workspace);
+            } else if (item instanceof PendingAddItemInfo) {
+                PendingAddItemInfo info = (PendingAddItemInfo) item;
+                Workspace<?> workspace = mContext.getWorkspace();
+                workspace.snapToPage(workspace.getPageIndexForScreenId(screenId));
+                mContext.addPendingItem(info, LauncherSettings.Favorites.CONTAINER_DESKTOP,
+                        screenId, coordinates, info.spanX, info.spanY);
+            } else if (item instanceof WorkspaceItemInfo) {
+                WorkspaceItemInfo info = ((WorkspaceItemInfo) item).clone();
+                mContext.getModelWriter().addItemToDatabase(info,
+                        LauncherSettings.Favorites.CONTAINER_DESKTOP,
+                        screenId, coordinates[0], coordinates[1]);
+                mContext.bindItems(Collections.singletonList(info), true, accessibility);
+            }
+        }));
+        return true;
+    }
+    /**
+     * Functionality to move the item {@link ItemInfo} to the workspace
+     * @param item item to be moved
+     *
+     * @return true if the item could be successfully added
+     */
+    public boolean moveToWorkspace(ItemInfo item) {
+        Folder folder = Folder.getOpen(mContext);
+        folder.close(true);
+        WorkspaceItemInfo info = (WorkspaceItemInfo) item;
+        folder.getInfo().remove(info, false);
+
+        final int[] coordinates = new int[2];
+        final int screenId = findSpaceOnWorkspace(item, coordinates);
+        if (screenId == -1) {
+            return false;
+        }
+        mContext.getModelWriter().moveItemInDatabase(info,
+                LauncherSettings.Favorites.CONTAINER_DESKTOP,
+                screenId, coordinates[0], coordinates[1]);
+
+        // Bind the item in next frame so that if a new workspace page was created,
+        // it will get laid out.
+        new Handler().post(() -> {
+            mContext.bindItems(Collections.singletonList(item), true);
+            announceConfirmation(R.string.item_moved);
+        });
+        return true;
+    }
 }
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 5ee4203..14e10918 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -104,7 +104,10 @@
         mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
     }
 
-    public void setup(DragController dragController, Workspace workspace) {
+    /**
+     * Set up the drag layer with the parameters.
+     */
+    public void setup(DragController dragController, Workspace<?> workspace) {
         mDragController = dragController;
         recreateControllers();
         mWorkspaceDragScrim = new Scrim(this);
diff --git a/src/com/android/launcher3/dragndrop/SpringLoadedDragController.java b/src/com/android/launcher3/dragndrop/SpringLoadedDragController.java
index 6325877..fb8a1bc 100644
--- a/src/com/android/launcher3/dragndrop/SpringLoadedDragController.java
+++ b/src/com/android/launcher3/dragndrop/SpringLoadedDragController.java
@@ -55,7 +55,7 @@
     public void onAlarm(Alarm alarm) {
         if (mScreen != null) {
             // Snap to the screen that we are hovering over now
-            Workspace w = mLauncher.getWorkspace();
+            Workspace<?> w = mLauncher.getWorkspace();
             if (!w.isVisible(mScreen)) {
                 w.snapToPage(w.indexOfChild(mScreen));
             }
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 7c665c6..5fe2435 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -342,7 +342,7 @@
             Rect to = finalRect;
             if (to == null) {
                 to = new Rect();
-                Workspace workspace = launcher.getWorkspace();
+                Workspace<?> workspace = launcher.getWorkspace();
                 // Set cellLayout and this to it's final state to compute final animation locations
                 workspace.setFinalTransitionTransform();
                 float scaleX = getScaleX();
diff --git a/src/com/android/launcher3/pageindicators/PageIndicator.java b/src/com/android/launcher3/pageindicators/PageIndicator.java
index 5967be7..ec69193 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicator.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicator.java
@@ -28,21 +28,22 @@
 
     /**
      * Sets the flag if the Page Indicator should autohide.
-     * @param shouldAutoHide
      */
     default void setShouldAutoHide(boolean shouldAutoHide) {
-        //No-op by default
+        // No-op by default
     }
+
     /**
      * Pauses all currently running animations.
      */
     default void pauseAnimations() {
-        //No-op by default
+        // No-op by default
     }
+
     /**
      * Force-ends all currently running or paused animations.
      */
     default void skipAnimationsToEnd() {
-        //No-op by default
+        // No-op by default
     }
 }
diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java
index f06e5ce..df8a3e2 100644
--- a/src/com/android/launcher3/popup/ArrowPopup.java
+++ b/src/com/android/launcher3/popup/ArrowPopup.java
@@ -351,7 +351,7 @@
         if (mColorExtractors == null) {
             return;
         }
-        Workspace workspace = launcher.getWorkspace();
+        Workspace<?> workspace = launcher.getWorkspace();
         if (workspace == null) {
             return;
         }
diff --git a/src/com/android/launcher3/states/SpringLoadedState.java b/src/com/android/launcher3/states/SpringLoadedState.java
index 9be3cc5..52356ce 100644
--- a/src/com/android/launcher3/states/SpringLoadedState.java
+++ b/src/com/android/launcher3/states/SpringLoadedState.java
@@ -46,7 +46,7 @@
     @Override
     public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
         DeviceProfile grid = launcher.getDeviceProfile();
-        Workspace ws = launcher.getWorkspace();
+        Workspace<?> ws = launcher.getWorkspace();
         if (ws.getChildCount() == 0) {
             return super.getWorkspaceScaleAndTranslation(launcher);
         }
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
index 2eae99a..a6b481a 100644
--- a/src/com/android/launcher3/testing/TestInformationHandler.java
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -178,7 +178,7 @@
 
             case TestProtocol.REQUEST_WORKSPACE_CELL_LAYOUT_SIZE:
                 return getLauncherUIProperty(Bundle::putIntArray, launcher -> {
-                    final Workspace workspace = launcher.getWorkspace();
+                    final Workspace<?> workspace = launcher.getWorkspace();
                     final int screenId = workspace.getScreenIdForPageIndex(
                             workspace.getCurrentPage());
                     final CellLayout cellLayout = workspace.getScreenWithId(screenId);
@@ -189,7 +189,7 @@
                 final WorkspaceCellCenterRequest request = extra.getParcelable(
                         TestProtocol.TEST_INFO_REQUEST_FIELD);
                 return getLauncherUIProperty(Bundle::putParcelable, launcher -> {
-                    final Workspace workspace = launcher.getWorkspace();
+                    final Workspace<?> workspace = launcher.getWorkspace();
                     // TODO(b/216387249): allow caller selecting different pages.
                     CellLayout cellLayout = (CellLayout) workspace.getPageAt(
                             workspace.getCurrentPage());
diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
index fe0bf6d..17bbdf1 100644
--- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java
+++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
@@ -64,7 +64,7 @@
 
     private final Rect mTempRect = new Rect();
     private final Launcher mLauncher;
-    private final Workspace mWorkspace;
+    private final Workspace<?> mWorkspace;
     private final PointF mTouchDownPoint = new PointF();
     private final float mTouchSlop;
 
@@ -72,7 +72,7 @@
 
     private final GestureDetector mGestureDetector;
 
-    public WorkspaceTouchListener(Launcher launcher, Workspace workspace) {
+    public WorkspaceTouchListener(Launcher launcher, Workspace<?> workspace) {
         mLauncher = launcher;
         mWorkspace = workspace;
         // Use twice the touch slop as we are looking for long press which is more
diff --git a/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java b/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java
index 8a7cae9..43e9820 100644
--- a/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java
+++ b/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java
@@ -14,6 +14,8 @@
 import android.util.Log;
 import android.view.animation.Interpolator;
 
+import androidx.annotation.AnyThread;
+
 import com.android.launcher3.Utilities;
 import com.android.launcher3.Workspace;
 import com.android.launcher3.anim.Interpolators;
@@ -30,7 +32,7 @@
     // Don't use all the wallpaper for parallax until you have at least this many pages
     private static final int MIN_PARALLAX_PAGE_SPAN = 4;
 
-    private final Workspace mWorkspace;
+    private final Workspace<?> mWorkspace;
     private final boolean mIsRtl;
     private final Handler mHandler;
 
@@ -41,7 +43,7 @@
     private boolean mLockedToDefaultPage;
     private int mNumScreens;
 
-    public WallpaperOffsetInterpolator(Workspace workspace) {
+    public WallpaperOffsetInterpolator(Workspace<?> workspace) {
         mWorkspace = workspace;
         mIsRtl = Utilities.isRtl(workspace.getResources());
         mHandler = new OffsetHandler(workspace.getContext());
@@ -182,6 +184,7 @@
         }
     }
 
+    @AnyThread
     private void updateOffset() {
         Message.obtain(mHandler, MSG_SET_NUM_PARALLAX, getNumPagesForWallpaperParallax(), 0,
                 mWindowToken).sendToTarget();
@@ -206,9 +209,12 @@
 
     @Override
     public void onReceive(Context context, Intent intent) {
-        mWallpaperIsLiveWallpaper =
-                WallpaperManager.getInstance(mWorkspace.getContext()).getWallpaperInfo() != null;
-        updateOffset();
+        UI_HELPER_EXECUTOR.execute(() -> {
+            // Updating the boolean on a background thread is fine as the assignments are atomic
+            mWallpaperIsLiveWallpaper =
+                    WallpaperManager.getInstance(context).getWallpaperInfo() != null;
+            updateOffset();
+        });
     }
 
     private static final int MSG_START_ANIMATION = 1;
diff --git a/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java b/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java
index 57f8bc7..f42142e 100644
--- a/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java
@@ -16,7 +16,6 @@
 
 package com.android.launcher3.widget;
 
-import android.annotation.SuppressLint;
 import android.appwidget.AppWidgetProviderInfo;
 import android.content.Context;
 import android.graphics.Canvas;
@@ -31,9 +30,6 @@
 
 import com.android.launcher3.R;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
 /**
  * A widget host views created while the host has not bind to the system service.
  */
@@ -73,34 +69,23 @@
             return;
         }
 
-        // Use double padding so that there is extra space between background and text
+        // Use double padding so that there is extra space between background and text if possible.
         int availableWidth = getMeasuredWidth() - 2 * (getPaddingLeft() + getPaddingRight());
+        if (availableWidth <= 0) {
+            availableWidth = getMeasuredWidth() - (getPaddingLeft() + getPaddingRight());
+        }
         if (mSetupTextLayout != null && mSetupTextLayout.getText().equals(info.label)
                 && mSetupTextLayout.getWidth() == availableWidth) {
             return;
         }
-        try {
-            mSetupTextLayout = new StaticLayout(info.label, mPaint, availableWidth,
-                    Layout.Alignment.ALIGN_CENTER, 1, 0, true);
-        } catch (IllegalArgumentException e) {
-            @SuppressLint("DrawAllocation") StringWriter stringWriter = new StringWriter();
-            @SuppressLint("DrawAllocation") PrintWriter printWriter = new PrintWriter(stringWriter);
-            mActivity.getDeviceProfile().dump(/*prefix=*/"", printWriter);
-            printWriter.flush();
-            String message = "b/203530620 "
-                    + "- availableWidth: " + availableWidth
-                    + ", getMeasuredWidth: " + getMeasuredWidth()
-                    + ", getPaddingLeft: " + getPaddingLeft()
-                    + ", getPaddingRight: " + getPaddingRight()
-                    + ", deviceProfile: " + stringWriter.toString();
-            throw new IllegalArgumentException(message, e);
-        }
+        mSetupTextLayout = new StaticLayout(info.label, mPaint, availableWidth,
+                Layout.Alignment.ALIGN_CENTER, 1, 0, true);
     }
 
     @Override
     protected void onDraw(Canvas canvas) {
         if (mSetupTextLayout != null) {
-            canvas.translate(getPaddingLeft() * 2,
+            canvas.translate((getWidth() - mSetupTextLayout.getWidth()) / 2,
                     (getHeight() - mSetupTextLayout.getHeight()) / 2);
             mSetupTextLayout.draw(canvas);
         }