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 94% rename from src/com/android/launcher3/BaseRecyclerView.java rename to src/com/android/launcher3/FastScrollRecyclerView.java index b6d3fc5304..f117069144 100644 --- a/src/com/android/launcher3/BaseRecyclerView.java +++ b/src/com/android/launcher3/FastScrollRecyclerView.java @@ -23,6 +23,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.compat.AccessibilityManagerCompat; @@ -36,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); } @@ -65,6 +66,7 @@ public abstract class BaseRecyclerView extends RecyclerView { onUpdateScrollbar(0); } + @Nullable public RecyclerViewFastScroller getScrollbar() { return mScrollbar; } @@ -198,4 +200,4 @@ public abstract class BaseRecyclerView extends RecyclerView { } scrollToPosition(0); } -} \ No newline at end of file +} diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 47f2dd50aa..2368cf7ce1 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -82,7 +82,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(); @@ -101,7 +101,7 @@ public class ActivityAllAppsContainerView results) { - if (getApps().setSearchResults(results)) { + if (getSearchResultList().setSearchResults(results)) { for (int i = 0; i < mAH.size(); i++) { if (mAH.get(i).mRecyclerView != null) { mAH.get(i).mRecyclerView.onSearchResultsChanged(); @@ -148,7 +148,7 @@ public class ActivityAllAppsContainerView mHeaderThreshold) { bgVisible = false; @@ -248,7 +257,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 88e7fc0514..af17cf72e9 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -35,8 +35,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; @@ -50,13 +50,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(); @@ -91,8 +91,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView { }; // The empty-search result background - private AllAppsBackgroundDrawable mEmptySearchBackground; - private int mEmptySearchBackgroundTopOffset; + protected AllAppsBackgroundDrawable mEmptySearchBackground; + protected int mEmptySearchBackgroundTopOffset; public AllAppsRecyclerView(Context context) { this(context, null); @@ -127,7 +127,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); @@ -152,8 +152,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); } @@ -341,13 +341,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 @@ -358,7 +351,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; } @@ -448,14 +441,4 @@ public class AllAppsRecyclerView extends BaseRecyclerView { public boolean hasOverlappingRendering() { return false; } - - /** - * Returns distance between left and right app icons - */ - public int getTabWidth() { - DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile(); - int totalWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight(); - int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx; - return totalWidth - iconPadding - grid.allAppsIconDrawablePaddingPx; - } } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 3600bd26b1..a4a208533a 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -84,7 +84,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getRecyclerViewContainer().getTranslationY(); + return controller.mAppsView.getActiveRecyclerView().getTranslationY(); } else { return controller.getAppsViewPullbackTranslationY().get( controller.mAppsView); @@ -94,8 +94,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float translation) { if (controller.mIsTablet) { - controller.mAppsView.getRecyclerViewContainer().setTranslationY( - translation); + controller.mAppsView.getActiveRecyclerView().setTranslationY(translation); } else { controller.getAppsViewPullbackTranslationY().set(controller.mAppsView, translation); @@ -109,7 +108,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { if (controller.mIsTablet) { - return controller.mAppsView.getRecyclerViewContainer().getAlpha(); + return controller.mAppsView.getActiveRecyclerView().getAlpha(); } else { return controller.getAppsViewPullbackAlpha().getValue(); } @@ -118,7 +117,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float alpha) { if (controller.mIsTablet) { - controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha); + controller.mAppsView.getActiveRecyclerView().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 4ccfd39c12..45a567dd19 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -21,6 +21,7 @@ import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_SEARCH_ import android.content.Context; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.DiffUtil; import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem; @@ -72,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 @@ -89,14 +91,16 @@ public class AlphabeticalAppsList implement private int mNumAppRowsInAdapter; private Predicate 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(Predicate itemFilter) { @@ -162,9 +166,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(); } @@ -172,7 +176,7 @@ public class AlphabeticalAppsList implement * Returns whether there are no filtered results. */ public boolean hasNoFilteredResults() { - return hasFilter() && mAccessibilityResultsCount == 0; + return hasSearchResults() && mAccessibilityResultsCount == 0; } /** @@ -195,11 +199,14 @@ public class AlphabeticalAppsList implement */ @Override public void onAppsUpdated() { + if (mAllAppsStore == null) { + return; + } // Sort the list of apps mApps.clear(); Stream appSteam = Stream.of(mAllAppsStore.getApps()); - if (!hasFilter() && mItemFilter != null) { + if (!hasSearchResults() && mItemFilter != null) { appSteam = appSteam.filter(mItemFilter); } appSteam = appSteam.sorted(mAppNameComparator); @@ -240,7 +247,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()) { + mAdapterItems.addAll(mSearchResults); + if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { + // Append the search market item + if (hasNoFilteredResults()) { + mAdapterItems.add(new AdapterItem(VIEW_TYPE_EMPTY_SEARCH)); + } else { + mAdapterItems.add(new AdapterItem(VIEW_TYPE_ALL_APPS_DIVIDER)); + } + mAdapterItems.add(new AdapterItem(VIEW_TYPE_SEARCH_MARKET)); + } + } else { int position = 0; if (mWorkAdapterProvider != null) { position += mWorkAdapterProvider.addWorkItems(mAdapterItems); @@ -260,17 +278,6 @@ public class AlphabeticalAppsList implement } position++; } - } else { - mAdapterItems.addAll(mSearchResults); - if (!FeatureFlags.ENABLE_DEVICE_SEARCH.get()) { - // Append the search market item - if (hasNoFilteredResults()) { - mAdapterItems.add(new AdapterItem(VIEW_TYPE_EMPTY_SEARCH)); - } else { - mAdapterItems.add(new AdapterItem(VIEW_TYPE_ALL_APPS_DIVIDER)); - } - mAdapterItems.add(new AdapterItem(VIEW_TYPE_SEARCH_MARKET)); - } } mAccessibilityResultsCount = (int) mAdapterItems.stream() .filter(AdapterItem::isCountedForAccessibility).count(); diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index fc527976ab..2c04fc7753 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -63,6 +63,7 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.Themes; import com.android.launcher3.views.ActivityContext; +import com.android.launcher3.views.BaseDragLayer; import com.android.launcher3.views.RecyclerViewFastScroller; import com.android.launcher3.views.ScrimView; import com.android.launcher3.views.SpringRelativeLayout; @@ -83,7 +84,7 @@ public abstract class BaseAllAppsContainerView= 0 - && mActivityContext.getDragLayer().isEventOverView(rv.getScrollbar(), ev)) { + if (rv.getScrollbar() != null + && rv.getScrollbar().getThumbOffsetY() >= 0 + && dragLayer.isEventOverView(rv.getScrollbar(), ev)) { return false; } - return rv.shouldContainerScroll(ev, mActivityContext.getDragLayer()); + return rv.shouldContainerScroll(ev, dragLayer); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { AllAppsRecyclerView rv = getActiveRecyclerView(); - if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(), - mFastScrollerOffset)) { + if (rv != null && rv.getScrollbar() != null + && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(), mFastScrollerOffset)) { mTouchHandler = rv.getScrollbar(); } else { mTouchHandler = null; @@ -284,8 +289,8 @@ public abstract class BaseAllAppsContainerView