diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml index d402469833..34d4b231b1 100644 --- a/quickstep/res/layout/taskbar_all_apps.xml +++ b/quickstep/res/layout/taskbar_all_apps.xml @@ -33,6 +33,10 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> + + diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java index 0ea2aa0647..51fa4d9f3a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java @@ -44,9 +44,10 @@ public class TaskbarAllAppsContainerView extends } @Override - protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList mAppsList, + protected BaseAllAppsAdapter createAdapter( + AlphabeticalAppsList appsList, BaseAdapterProvider[] adapterProviders) { - return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList, + return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList, adapterProviders); } } diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml index 2ac7e63a15..d0d82d48bd 100644 --- a/res/layout/all_apps.xml +++ b/res/layout/all_apps.xml @@ -29,6 +29,10 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> + + diff --git a/res/layout/search_results_rv_layout.xml b/res/layout/search_results_rv_layout.xml new file mode 100644 index 0000000000..567cb5f4fc --- /dev/null +++ b/res/layout/search_results_rv_layout.xml @@ -0,0 +1,24 @@ + + + diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml index 0fe05ee721..635db141dd 100644 --- a/res/layout/secondary_launcher.xml +++ b/res/layout/secondary_launcher.xml @@ -59,6 +59,10 @@ layout="@layout/all_apps_bottom_sheet_background" android:visibility="gone" /> + + diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java similarity index 95% rename from src/com/android/launcher3/BaseRecyclerView.java rename to src/com/android/launcher3/FastScrollRecyclerView.java index 9369bdc2fd..a60d143c6e 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/FastScrollRecyclerView.java @@ -37,19 +37,19 @@ import com.android.launcher3.views.RecyclerViewFastScroller; *
  • Enable fast scroller. * */ -public abstract class BaseRecyclerView extends RecyclerView { +public abstract class FastScrollRecyclerView extends RecyclerView { protected RecyclerViewFastScroller mScrollbar; - public BaseRecyclerView(Context context) { + public FastScrollRecyclerView(Context context) { this(context, null); } - public BaseRecyclerView(Context context, AttributeSet attrs) { + public FastScrollRecyclerView(Context context, AttributeSet attrs) { this(context, attrs, 0); } - public BaseRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { + public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @@ -206,4 +206,4 @@ public abstract class BaseRecyclerView extends RecyclerView { } scrollToPosition(0); } -} \ No newline at end of file +} diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 4b42ecbae0..463280b958 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2750,7 +2750,7 @@ public class Launcher extends StatefulActivity packageName); if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) { - return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), + return getFirstMatch(Collections.singletonList(mAppsView.getActiveAppsRecyclerView()), preferredItem, packageAndUserAndApp); } else { List containers = new ArrayList<>(mWorkspace.getPanelCount() + 1); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index e279f59aaf..16a2823c4e 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -80,7 +80,7 @@ public class ActivityAllAppsContainerView mActivityContext.startActivitySafely(v, marketSearchIntent, null); for (int i = 0; i < mAH.size(); i++) { - mAH.get(i).adapter.setLastSearchQuery(query, marketSearchClickListener); + mAH.get(i).mAdapter.setLastSearchQuery(query, marketSearchClickListener); } mIsSearching = true; rebindAdapters(); @@ -142,7 +142,7 @@ public class ActivityAllAppsContainerView mHeaderThreshold) { bgVisible = false; @@ -242,7 +251,7 @@ public class ActivityAllAppsContainerView mAppsList, + protected BaseAllAppsAdapter createAdapter(AlphabeticalAppsList appsList, BaseAdapterProvider[] adapterProviders) { - return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList, + return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList, adapterProviders); } } diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 7dbe711716..18c6788397 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -37,8 +37,8 @@ import android.view.View; import androidx.recyclerview.widget.RecyclerView; -import com.android.launcher3.BaseRecyclerView; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.FastScrollRecyclerView; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -53,13 +53,13 @@ import java.util.List; /** * A RecyclerView with custom fast scroll support for the all apps view. */ -public class AllAppsRecyclerView extends BaseRecyclerView { - private static final String TAG = "AllAppsContainerView"; +public class AllAppsRecyclerView extends FastScrollRecyclerView { + protected static final String TAG = "AllAppsRecyclerView"; private static final boolean DEBUG = false; private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING); - private AlphabeticalAppsList mApps; - private final int mNumAppsPerRow; + protected AlphabeticalAppsList mApps; + protected final int mNumAppsPerRow; // The specific view heights that we use to calculate scroll private final SparseIntArray mViewHeights = new SparseIntArray(); @@ -74,8 +74,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView { }; // The empty-search result background - private AllAppsBackgroundDrawable mEmptySearchBackground; - private int mEmptySearchBackgroundTopOffset; + protected AllAppsBackgroundDrawable mEmptySearchBackground; + protected int mEmptySearchBackgroundTopOffset; private ArrayList mAutoSizedOverlays = new ArrayList<>(); @@ -112,7 +112,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { return mApps; } - private void updatePoolSize() { + protected void updatePoolSize() { DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile(); RecyclerView.RecycledViewPool pool = getRecycledViewPool(); int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx); @@ -137,8 +137,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView { Log.d(TAG, "onDraw at = " + System.currentTimeMillis()); } if (DEBUG_LATENCY) { - Log.d(SEARCH_LOGGING, - "-- Recycle view onDraw, time stamp = " + System.currentTimeMillis()); + Log.d(SEARCH_LOGGING, getClass().getSimpleName() + " onDraw; time stamp = " + + System.currentTimeMillis()); } super.onDraw(c); } @@ -223,8 +223,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { && mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) { mEmptySearchBackground.setHotspot(e.getX(), e.getY()); } - hideKeyboardAsync(ActivityContext.lookupContext(getContext()), - getApplicationWindowToken()); + hideKeyboardAsync(ActivityContext.lookupContext(getContext()), getApplicationWindowToken()); return result; } @@ -359,13 +358,6 @@ public class AllAppsRecyclerView extends BaseRecyclerView { } } - @Override - public boolean supportsFastScrolling() { - // Only allow fast scrolling when the user is not searching, since the results are not - // grouped in a meaningful order - return !mApps.hasFilter(); - } - @Override public int getCurrentScrollY() { // Return early if there are no items or we haven't been measured @@ -376,7 +368,7 @@ public class AllAppsRecyclerView extends BaseRecyclerView { // Calculate the y and offset for the item View child = getChildAt(0); - int position = getChildPosition(child); + int position = getChildAdapterPosition(child); if (position == NO_POSITION) { return -1; } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 637a4189b8..723bc65978 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -84,7 +84,8 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getRecyclerViewContainer().getTranslationY(); + return controller.mAppsView.getAppsRecyclerViewContainer() + .getTranslationY(); } else { return controller.getAppsViewPullbackTranslationY().get( controller.mAppsView); @@ -94,7 +95,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float translation) { if (controller.mIsTablet) { - controller.mAppsView.getRecyclerViewContainer().setTranslationY( + controller.mAppsView.getAppsRecyclerViewContainer().setTranslationY( translation); } else { controller.getAppsViewPullbackTranslationY().set(controller.mAppsView, @@ -109,7 +110,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getRecyclerViewContainer().getAlpha(); + return controller.mAppsView.getAppsRecyclerViewContainer().getAlpha(); } else { return controller.getAppsViewPullbackAlpha().getValue(); } @@ -118,7 +119,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float alpha) { if (controller.mIsTablet) { - controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha); + controller.mAppsView.getAppsRecyclerViewContainer().setAlpha(alpha); } else { controller.getAppsViewPullbackAlpha().setValue(alpha); } diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 7687fea85d..42374b894f 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -18,6 +18,8 @@ package com.android.launcher3.allapps; import android.content.Context; +import androidx.annotation.Nullable; + import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.AppInfo; @@ -71,6 +73,7 @@ public class AlphabeticalAppsList implement // The set of apps from the system private final List mApps = new ArrayList<>(); + @Nullable private final AllAppsStore mAllAppsStore; // The number of results in current adapter @@ -88,14 +91,16 @@ public class AlphabeticalAppsList implement private int mNumAppRowsInAdapter; private ItemInfoMatcher mItemFilter; - public AlphabeticalAppsList(Context context, AllAppsStore appsStore, + public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore, WorkAdapterProvider adapterProvider) { mAllAppsStore = appsStore; mActivityContext = ActivityContext.lookupContext(context); mAppNameComparator = new AppInfoComparator(context); mWorkAdapterProvider = adapterProvider; mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns; - mAllAppsStore.addUpdateListener(this); + if (mAllAppsStore != null) { + mAllAppsStore.addUpdateListener(this); + } } public void updateItemFilter(ItemInfoMatcher itemFilter) { @@ -168,9 +173,9 @@ public class AlphabeticalAppsList implement } /** - * Returns whether there are is a filter set. + * Returns whether there are search results which will hide the A-Z list. */ - public boolean hasFilter() { + public boolean hasSearchResults() { return !mSearchResults.isEmpty(); } @@ -178,7 +183,7 @@ public class AlphabeticalAppsList implement * Returns whether there are no filtered results. */ public boolean hasNoFilteredResults() { - return hasFilter() && mAccessibilityResultsCount == 0; + return hasSearchResults() && mAccessibilityResultsCount == 0; } /** @@ -196,13 +201,13 @@ public class AlphabeticalAppsList implement return true; } - public boolean appendSearchResults(ArrayList results) { - if (hasFilter() && results != null && results.size() > 0) { + /** Appends results to search. */ + public void appendSearchResults(ArrayList results) { + if (hasSearchResults() && results != null && results.size() > 0) { updateSearchAdapterItems(results, mSearchResults.size()); + mSearchResults.addAll(results); refreshRecyclerView(); - return true; } - return false; } void updateSearchAdapterItems(ArrayList list, int offset) { @@ -222,11 +227,14 @@ public class AlphabeticalAppsList implement */ @Override public void onAppsUpdated() { + if (mAllAppsStore == null) { + return; + } // Sort the list of apps mApps.clear(); for (AppInfo app : mAllAppsStore.getApps()) { - if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) { + if (mItemFilter == null || mItemFilter.matches(app, null) || hasSearchResults()) { mApps.add(app); } } @@ -296,7 +304,18 @@ public class AlphabeticalAppsList implement // Recreate the filtered and sectioned apps (for convenience for the grid layout) from the // ordered set of sections - if (!hasFilter()) { + if (hasSearchResults()) { + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + // Append the search market item + if (hasNoFilteredResults()) { + mSearchResults.add(AdapterItem.asEmptySearch(position++)); + } else { + mSearchResults.add(AdapterItem.asAllAppsDivider(position++)); + } + mSearchResults.add(AdapterItem.asMarketSearch(position++)); + } + updateSearchAdapterItems(mSearchResults, 0); + } else { mAccessibilityResultsCount = mApps.size(); if (mWorkAdapterProvider != null) { position += mWorkAdapterProvider.addWorkItems(mAdapterItems); @@ -323,18 +342,6 @@ public class AlphabeticalAppsList implement mAdapterItems.add(appItem); } - } else { - updateSearchAdapterItems(mSearchResults, 0); - if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - // Append the search market item - if (hasNoFilteredResults()) { - mAdapterItems.add(AdapterItem.asEmptySearch(position++)); - } else { - mAdapterItems.add(AdapterItem.asAllAppsDivider(position++)); - } - mAdapterItems.add(AdapterItem.asMarketSearch(position++)); - - } } if (mNumAppsPerRowAllApps != 0) { // Update the number of rows in the adapter after we do all the merging (otherwise, we diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index f913aa9093..6a4498917e 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -80,7 +80,7 @@ public abstract class BaseAllAppsContainerView