Merge "Enables searching when using work tabs together with fallback search." into ub-launcher3-master
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a6c1e6e..9ee9514 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -27,6 +27,7 @@
 import android.support.v7.widget.RecyclerView;
 import android.text.Selection;
 import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -95,6 +96,7 @@
     private TransformingTouchDelegate mTouchDelegate;
     private boolean mUsingTabs;
     private boolean mHasPredictions = false;
+    private boolean mSearchModeWhileUsingTabs = false;
 
     private final HashMap<ComponentKey, AppInfo> mComponentToAppMap = new HashMap<>();
 
@@ -559,8 +561,10 @@
             return;
         }
         mHeader.setVisibility(View.VISIBLE);
-        int contentHeight = mHasPredictions ? mLauncher.getDeviceProfile().allAppsCellHeightPx : 0;
-        if (mHasPredictions && !mUsingTabs) {
+
+        boolean usePredictionRow = mHasPredictions && !mSearchModeWhileUsingTabs;
+        int contentHeight = usePredictionRow ? mLauncher.getDeviceProfile().allAppsCellHeightPx : 0;;
+        if (usePredictionRow && !mUsingTabs) {
             contentHeight += getResources()
                     .getDimensionPixelSize(R.dimen.all_apps_prediction_row_divider_height);
         }
@@ -584,6 +588,14 @@
         for (int i = 0; i < mAH.length; i++) {
             mAH[i].adapter.setLastSearchQuery(query);
         }
+        boolean hasQuery = !TextUtils.isEmpty(query);
+        if (mFloatingHeaderHandler != null && mUsingTabs && hasQuery) {
+            mSearchModeWhileUsingTabs = true;
+            rebindAdapters(false); // hide tabs
+        } else if (mSearchModeWhileUsingTabs && !hasQuery) {
+            mSearchModeWhileUsingTabs = false;
+            rebindAdapters(true); // show tabs
+        }
     }
 
     public void onSearchResultsChanged() {
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 12715cb..2b9cba3 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -301,7 +301,7 @@
         if (mSearchResults != f) {
             boolean same = mSearchResults != null && mSearchResults.equals(f);
             mSearchResults = f;
-            updateAdapterItems();
+            onAppsUpdated();
             return !same;
         }
         return false;
@@ -403,7 +403,7 @@
         mApps.clear();
 
         for (AppInfo app : mComponentToAppMap.values()) {
-            if (mItemFilter == null || mItemFilter.matches(app, null)) {
+            if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
                 mApps.add(app);
             }
         }