Merge "[Search] Show search suggestions with in Recyclerview" into sc-v2-dev am: 4112ae6a5b am: 7f355ff178

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/16172124

Change-Id: I4476210f378bdfe5e311ab8814db563524638880
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index a34baef..7f9f63e 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -43,15 +43,6 @@
 
         <include layout="@layout/all_apps_personal_work_tabs" />
 
-        <Button
-            android:id="@+id/all_apps_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:text="@string/all_apps_label"
-            android:background="@drawable/padded_rounded_action_button"
-            android:visibility="gone"/>
-
     </com.android.launcher3.allapps.FloatingHeaderView>
 
     <include layout="@layout/search_container_all_apps" />
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 874fe80..f089551 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -42,6 +42,7 @@
 import com.android.launcher3.BubbleTextView;
 import com.android.launcher3.R;
 import com.android.launcher3.model.data.AppInfo;
+import com.android.launcher3.model.data.ItemInfoWithIcon;
 import com.android.launcher3.util.PackageManagerHelper;
 
 import java.util.Arrays;
@@ -95,16 +96,15 @@
         // The type of this item
         public int viewType;
 
-        /** App-only properties */
-        // The section name of this app.  Note that there can be multiple items with different
+        // The section name of this item.  Note that there can be multiple items with different
         // sectionNames in the same section
         public String sectionName = null;
         // The row that this item shows up on
         public int rowIndex;
         // The index of this app in the row
         public int rowAppIndex;
-        // The associated AppInfo for the app
-        public AppInfo appInfo = null;
+        // The associated ItemInfoWithIcon for the item
+        public ItemInfoWithIcon itemInfo = null;
         // The index of this app not including sections
         public int appIndex = -1;
         // Search section associated to result
@@ -119,7 +119,7 @@
             item.viewType = VIEW_TYPE_ICON;
             item.position = pos;
             item.sectionName = sectionName;
-            item.appInfo = appInfo;
+            item.itemInfo = appInfo;
             item.appIndex = appIndex;
             return item;
         }
@@ -373,7 +373,7 @@
                 if (adapterProvider != null) {
                     return adapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType);
                 }
-                throw new RuntimeException("Unexpected view type");
+                throw new RuntimeException("Unexpected view type" + viewType);
         }
     }
 
@@ -382,10 +382,13 @@
         switch (holder.getItemViewType()) {
             case VIEW_TYPE_ICON:
                 AdapterItem adapterItem = mApps.getAdapterItems().get(position);
-                AppInfo info = adapterItem.appInfo;
                 BubbleTextView icon = (BubbleTextView) holder.itemView;
                 icon.reset();
-                icon.applyFromApplicationInfo(info);
+                if (adapterItem.itemInfo instanceof AppInfo) {
+                    icon.applyFromApplicationInfo((AppInfo) adapterItem.itemInfo);
+                } else {
+                    icon.applyFromItemInfoWithIcon(adapterItem.itemInfo);
+                }
                 break;
             case VIEW_TYPE_EMPTY_SEARCH:
                 TextView emptyViewText = (TextView) holder.itemView;
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 3ca0303..85ee636 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -47,7 +47,6 @@
         ValueAnimator.AnimatorUpdateListener, PluginListener<AllAppsRow>, Insettable,
         OnHeightUpdatedListener {
 
-    private static final long ALL_APPS_CONTENT_ANIM_DURATION = 150;
     private final Rect mRVClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
     private final Rect mHeaderClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
     private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
@@ -110,13 +109,6 @@
     private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS;
 
 
-    // members for handling suggestion state
-    private final ValueAnimator mAllAppsContentAnimator = ValueAnimator.ofFloat(0, 0);
-    private View mAllAppsButton;
-    private int mAllAppsContentFadeInOffset;
-    private boolean mInSuggestionMode = false;
-
-
     public FloatingHeaderView(@NonNull Context context) {
         this(context, null);
     }
@@ -127,20 +119,12 @@
                 .getDimensionPixelSize(R.dimen.all_apps_header_top_padding);
         mHeaderProtectionSupported = context.getResources().getBoolean(
                 R.bool.config_header_protection_supported);
-        mAllAppsContentFadeInOffset = context.getResources()
-                .getDimensionPixelSize(R.dimen.all_apps_content_fade_in_offset);
-        mAllAppsContentAnimator.setDuration(ALL_APPS_CONTENT_ANIM_DURATION);
-        mAllAppsContentAnimator.addUpdateListener(this::onAllAppsContentAnimationUpdate);
     }
 
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
         mTabLayout = findViewById(R.id.tabs);
-        mAllAppsButton = findViewById(R.id.all_apps_button);
-        if (mAllAppsButton != null) {
-            mAllAppsButton.setOnClickListener(this::onAllAppsButtonClicked);
-        }
 
         // Find all floating header rows.
         ArrayList<FloatingHeaderRow> rows = new ArrayList<>();
@@ -329,7 +313,6 @@
         }
 
         mTabLayout.setTranslationY(mTranslationY);
-        setSuggestionMode(false);
 
         int clipHeight = mHeaderTopPadding - getPaddingBottom();
         mRVClip.top = mTabsHidden ? clipHeight : 0;
@@ -365,7 +348,6 @@
             mTranslationY = 0;
             applyVerticalMove();
         }
-        setSuggestionMode(false);
         mHeaderCollapsed = false;
         mSnappedScrolledY = -mMaxTranslation;
         mCurrentRV.scrollToTop();
@@ -461,38 +443,6 @@
         }
         return Math.max(getHeight() - getPaddingTop() + mTranslationY, 0);
     }
-
-    /**
-     * When suggestion mode is enabled, hides AllApps content view and shows AllApps button.
-     */
-    public void setSuggestionMode(boolean isSuggestMode) {
-        if (mInSuggestionMode == isSuggestMode || mAllAppsButton == null) return;
-        if (!FeatureFlags.ENABLE_ONE_SEARCH.get()) return;
-        AllAppsContainerView allApps = (AllAppsContainerView) getParent();
-        mInSuggestionMode = isSuggestMode;
-        if (isSuggestMode) {
-            mTabLayout.setVisibility(GONE);
-            mAllAppsButton.setVisibility(VISIBLE);
-            allApps.getContentView().setVisibility(GONE);
-        } else {
-            mTabLayout.setVisibility(mTabsHidden ? GONE : VISIBLE);
-            mAllAppsButton.setVisibility(GONE);
-            allApps.getContentView().setVisibility(VISIBLE);
-        }
-    }
-
-    private void onAllAppsButtonClicked(View view) {
-        setSuggestionMode(false);
-        mAllAppsContentAnimator.start();
-    }
-
-    private void onAllAppsContentAnimationUpdate(ValueAnimator valueAnimator) {
-        float prog = valueAnimator.getAnimatedFraction();
-        View allAppsList = ((AllAppsContainerView) getParent()).getContentView();
-        allAppsList.setAlpha(255 * prog);
-        allAppsList.setTranslationY((1 - prog) * mAllAppsContentFadeInOffset);
-    }
-
 }