Hide searchbox when header protection is on.

Bug: 191726215
Test: manual
Change-Id: I086a05654faf718683ebe5dfbcf64b6bd6347ca8
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java
index 20c6938..e8510b7 100644
--- a/src/com/android/launcher3/ExtendedEditText.java
+++ b/src/com/android/launcher3/ExtendedEditText.java
@@ -96,6 +96,9 @@
         }
     }
 
+    // inherited class can override to change the appearance of the edit text.
+    public void show() {}
+
     public void showKeyboard() {
         mShowImeAfterFirstLayout = !showSoftInput();
     }
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 67f2a9e..aabbe65 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -717,6 +717,10 @@
                     : mSearchContainer.getBottom();
             canvas.drawRect(0, 0, getWidth(), bottom + getTranslationY(),
                     mHeaderPaint);
+
+            if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && getTranslationY() == 0) {
+                mSearchUiManager.getEditText().setBackground(null);
+            }
         }
     }
 
@@ -805,6 +809,9 @@
             getSearchView().setBackgroundColor(viewBG);
             getFloatingHeaderView().setHeaderColor(viewBG);
             invalidateHeader();
+            if (scrolledOffset == 0 && mSearchUiManager.getEditText() != null) {
+                mSearchUiManager.getEditText().show();
+            }
         }
     }
 
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 4ad694b..52dc19b 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -188,6 +188,7 @@
         StatsLogManager mgr = BaseDraggingActivity.fromContext(getContext()).getStatsLogManager();
         switch (state) {
             case SCROLL_STATE_DRAGGING:
+                requestFocus();
                 mgr.logger().sendToInteractionJankMonitor(
                         LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN, this);
                 break;
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index 06ccbbd..ecdd206 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -132,6 +132,12 @@
 
     public static OptionsPopupView show(
             Launcher launcher, RectF targetRect, List<OptionItem> items, boolean shouldAddArrow) {
+        return show(launcher, targetRect, items, shouldAddArrow, 0 /* width */);
+    }
+
+    public static OptionsPopupView show(
+            Launcher launcher, RectF targetRect, List<OptionItem> items, boolean shouldAddArrow,
+            int width) {
         OptionsPopupView popup = (OptionsPopupView) launcher.getLayoutInflater()
                 .inflate(R.layout.longpress_options_menu, launcher.getDragLayer(), false);
         popup.mTargetRect = targetRect;
@@ -140,6 +146,9 @@
         for (OptionItem item : items) {
             DeepShortcutView view =
                     (DeepShortcutView) popup.inflateAndAdd(R.layout.system_shortcut, popup);
+            if (width > 0) {
+                view.getLayoutParams().width = width;
+            }
             view.getIconView().setBackgroundDrawable(item.icon);
             view.getBubbleText().setText(item.label);
             view.setOnClickListener(popup);