Merge "Move ContextualSearchHapticManager to MainThreadInitialiedObject" into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
index 1141a01..55722a9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
@@ -151,30 +151,26 @@
                 DisplayController.showLockedTaskbarOnHome(context)
         ) {
             // adding the taskbar touch region
-            val touchableHeight: Int
             var left = 0
             var right = context.deviceProfile.widthPx
-            var bubbleBarAdjustment = 0
+            val touchableHeight: Int
             if (uiController.isAnimatingToLauncher) {
                 val dp = controllers.taskbarActivityContext.deviceProfile
                 touchableHeight = windowLayoutParams.height
                 if (dp.isQsbInline) {
                     // if Qsb is inline need to exclude search icon from touch region
                     val isRtl = Utilities.isRtl(context.resources)
-                    bubbleControllers?.bubbleBarViewController?.let {
-                        if (dp.shouldAdjustHotseatOnBubblesLocationUpdate(context)) {
+                    val navBarOffset =
+                        bubbleControllers?.bubbleBarViewController?.let {
                             val isBubblesOnLeft = it.bubbleBarLocation.isOnLeft(isRtl)
-                            bubbleBarAdjustment =
-                                dp.getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl)
-                        }
-                    }
+                            dp.getHotseatTranslationXForNavBar(context, isBubblesOnLeft)
+                        } ?: 0
                     val hotseatPadding: Rect = dp.getHotseatLayoutPadding(context)
                     val borderSpacing: Int = dp.hotseatBorderSpace
                     if (isRtl) {
-                        right =
-                            dp.widthPx - hotseatPadding.right + borderSpacing + bubbleBarAdjustment
+                        right = dp.widthPx - hotseatPadding.right + borderSpacing + navBarOffset
                     } else {
-                        left = hotseatPadding.left - borderSpacing + bubbleBarAdjustment
+                        left = hotseatPadding.left - borderSpacing + navBarOffset
                     }
                 }
             } else {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 559be36..4bc7d3c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -886,19 +886,18 @@
         mBubbleBarLocation = location;
         if (location == null) {
             // bubble bar is not present, hence no location, resetting the hotseat
-            updateHotseatAndQsbTranslationX(0, animate);
+            updateHotseatAndQsbTranslationX(/* targetValue = */ 0, animate);
             mBubbleBarLocation = null;
             return;
         }
         DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
-        if (!deviceProfile.shouldAdjustHotseatOnBubblesLocationUpdate(
+        if (!deviceProfile.shouldAdjustHotseatOnNavBarLocationUpdate(
                 mControllers.taskbarActivityContext)) {
             return;
         }
-        boolean isRtl = isRtl(mLauncher.getResources());
-        boolean isBubblesOnLeft = location.isOnLeft(isRtl);
+        boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources()));
         int targetX = deviceProfile
-                .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl);
+                .getHotseatTranslationXForNavBar(mLauncher, isBubblesOnLeft);
         updateHotseatAndQsbTranslationX(targetX, animate);
     }
 
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index c275536..e9458ff 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -837,12 +837,11 @@
 
         int firstRecentTaskIndex = -1;
         int hotseatNavBarTranslationX = 0;
-        if (mCurrentBubbleBarLocation != null
-                && taskbarDp.shouldAdjustHotseatOnBubblesLocationUpdate(mActivity)) {
-            boolean isRtl = mTaskbarView.isLayoutRtl();
-            boolean isBubblesOnLeft = mCurrentBubbleBarLocation.isOnLeft(isRtl);
+        if (mCurrentBubbleBarLocation != null) {
+            boolean isBubblesOnLeft = mCurrentBubbleBarLocation
+                    .isOnLeft(mTaskbarView.isLayoutRtl());
             hotseatNavBarTranslationX = taskbarDp
-                    .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl);
+                    .getHotseatTranslationXForNavBar(mActivity, isBubblesOnLeft);
         }
         for (int i = 0; i < mTaskbarView.getChildCount(); i++) {
             View child = mTaskbarView.getChildAt(i);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index acdff71..4ad65e1 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -1101,10 +1101,9 @@
         if (isBubbleBarEnabled()
                 && enableBubbleBarInPersistentTaskBar()
                 && mBubbleBarLocation != null) {
-            boolean isRtl = isRtl(getResources());
-            boolean isBubblesOnLeft = mBubbleBarLocation.isOnLeft(isRtl);
+            boolean isBubblesOnLeft = mBubbleBarLocation.isOnLeft(isRtl(getResources()));
             translationX += mDeviceProfile
-                    .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl);
+                    .getHotseatTranslationXForNavBar(this, isBubblesOnLeft);
         }
         if (isBubbleBarEnabled()
                 && mDeviceProfile.shouldAdjustHotseatForBubbleBar(getContext(), hasBubbles())) {
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 76dc770..5acff06 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -1130,6 +1130,9 @@
                 if (itemInfo.isDisabled()) {
                     setContentDescription(getContext().getString(R.string.disabled_app_label,
                             itemInfo.contentDescription));
+                } else if (itemInfo instanceof WorkspaceItemInfo wai && wai.isArchived()) {
+                    setContentDescription(
+                            getContext().getString(R.string.app_archived_title, itemInfo.title));
                 } else if (hasDot()) {
                     int count = mDotInfo.getNotificationCount();
                     setContentDescription(
@@ -1142,8 +1145,16 @@
     }
 
     private void setDownloadStateContentDescription(ItemInfoWithIcon info, int progressLevel) {
-        if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_ARCHIVED) != 0 && progressLevel == 0) {
-            setContentDescription(getContext().getString(R.string.app_archived_title, info.title));
+        if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_ARCHIVED) != 0
+                && progressLevel == 0) {
+            if (mIcon instanceof PreloadIconDrawable) {
+                // Tell user that download is pending and not to tap to download again.
+                setContentDescription(getContext().getString(
+                        R.string.app_waiting_download_title, info.title));
+            } else {
+                setContentDescription(getContext().getString(
+                        R.string.app_archived_title, info.title));
+            }
         } else if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK)
                 != 0) {
             String percentageString = NumberFormat.getPercentInstance()
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index afe0ee1..8862550 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -2355,18 +2355,23 @@
     /**
      * Returns whether Taskbar and Hotseat should adjust horizontally on bubble bar location update.
      */
-    public boolean shouldAdjustHotseatOnBubblesLocationUpdate(Context context) {
+    public boolean shouldAdjustHotseatOnNavBarLocationUpdate(Context context) {
         return enableBubbleBar()
                 && enableBubbleBarInPersistentTaskBar()
                 && !DisplayController.getNavigationMode(context).hasGestures;
     }
 
     /** Returns hotseat translation X for the bubble bar position. */
-    public int getHotseatTranslationXForBubbleBar(boolean isNavbarOnRight, boolean isRtl) {
-        if (isNavbarOnRight) {
-            return isRtl ? -navButtonsLayoutWidthPx : 0;
+    public int getHotseatTranslationXForNavBar(Context context, boolean isBubblesOnLeft) {
+        if (shouldAdjustHotseatOnNavBarLocationUpdate(context)) {
+            boolean isRtl = Utilities.isRtl(context.getResources());
+            if (isBubblesOnLeft) {
+                return isRtl ? -navButtonsLayoutWidthPx : 0;
+            } else {
+                return isRtl ? 0 : navButtonsLayoutWidthPx;
+            }
         } else {
-            return isRtl ? 0 : navButtonsLayoutWidthPx;
+            return 0;
         }
     }
 
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
index de3bb9e..7e3e392 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
@@ -118,8 +118,14 @@
     @Override
     public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
 
-        if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) {
-            Log.i(TAG, "User tapped ime search button");
+        if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO || (
+                actionId == EditorInfo.IME_NULL && event != null
+                        && event.getAction() == KeyEvent.ACTION_DOWN)) {
+            if (actionId == EditorInfo.IME_NULL) {
+                Log.i(TAG, "User pressed ENTER key");
+            } else {
+                Log.i(TAG, "User tapped ime search button");
+            }
             // selectFocusedView should return SearchTargetEvent that is passed onto onClick
             return mLauncher.getAppsView().getMainAdapterProvider().launchHighlightedItem();
         }