Merge "Revert "Refactors Search results into separate RV for Toast."" into tm-dev am: fa693be19f am: 34fc3c4aee am: 98d71a1b3c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18011182 Change-Id: Ibeade0ca5baf819c2ea7eef57b39780664aa543c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -33,10 +33,6 @@
|
|||||||
layout="@layout/all_apps_bottom_sheet_background"
|
layout="@layout/all_apps_bottom_sheet_background"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/search_results_rv_layout"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/all_apps_rv_layout"
|
layout="@layout/all_apps_rv_layout"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|||||||
+2
-3
@@ -44,10 +44,9 @@ public class TaskbarAllAppsContainerView extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseAllAppsAdapter<TaskbarAllAppsContext> createAdapter(
|
protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<TaskbarAllAppsContext> mAppsList,
|
||||||
AlphabeticalAppsList<TaskbarAllAppsContext> appsList,
|
|
||||||
BaseAdapterProvider[] adapterProviders) {
|
BaseAdapterProvider[] adapterProviders) {
|
||||||
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
|
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
|
||||||
adapterProviders);
|
adapterProviders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,6 @@
|
|||||||
layout="@layout/all_apps_bottom_sheet_background"
|
layout="@layout/all_apps_bottom_sheet_background"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/search_results_rv_layout"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/all_apps_rv_layout"
|
layout="@layout/all_apps_rv_layout"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2022 The Android Open Source Project
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
<com.android.launcher3.allapps.SearchRecyclerView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/search_results_list_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:descendantFocusability="afterDescendants"
|
|
||||||
android:focusable="true" />
|
|
||||||
@@ -59,10 +59,6 @@
|
|||||||
layout="@layout/all_apps_bottom_sheet_background"
|
layout="@layout/all_apps_bottom_sheet_background"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/search_results_rv_layout"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/all_apps_rv_layout"
|
layout="@layout/all_apps_rv_layout"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|||||||
+5
-5
@@ -37,19 +37,19 @@ import com.android.launcher3.views.RecyclerViewFastScroller;
|
|||||||
* <li> Enable fast scroller.
|
* <li> Enable fast scroller.
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public abstract class FastScrollRecyclerView extends RecyclerView {
|
public abstract class BaseRecyclerView extends RecyclerView {
|
||||||
|
|
||||||
protected RecyclerViewFastScroller mScrollbar;
|
protected RecyclerViewFastScroller mScrollbar;
|
||||||
|
|
||||||
public FastScrollRecyclerView(Context context) {
|
public BaseRecyclerView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastScrollRecyclerView(Context context, AttributeSet attrs) {
|
public BaseRecyclerView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastScrollRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public BaseRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,4 +206,4 @@ public abstract class FastScrollRecyclerView extends RecyclerView {
|
|||||||
}
|
}
|
||||||
scrollToPosition(0);
|
scrollToPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2750,7 +2750,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
|||||||
packageName);
|
packageName);
|
||||||
|
|
||||||
if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) {
|
if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) {
|
||||||
return getFirstMatch(Collections.singletonList(mAppsView.getActiveAppsRecyclerView()),
|
return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()),
|
||||||
preferredItem, packageAndUserAndApp);
|
preferredItem, packageAndUserAndApp);
|
||||||
} else {
|
} else {
|
||||||
List<ViewGroup> containers = new ArrayList<>(mWorkspace.getPanelCount() + 1);
|
List<ViewGroup> containers = new ArrayList<>(mWorkspace.getPanelCount() + 1);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
OnClickListener marketSearchClickListener = (v) -> mActivityContext.startActivitySafely(v,
|
OnClickListener marketSearchClickListener = (v) -> mActivityContext.startActivitySafely(v,
|
||||||
marketSearchIntent, null);
|
marketSearchIntent, null);
|
||||||
for (int i = 0; i < mAH.size(); i++) {
|
for (int i = 0; i < mAH.size(); i++) {
|
||||||
mAH.get(i).mAdapter.setLastSearchQuery(query, marketSearchClickListener);
|
mAH.get(i).adapter.setLastSearchQuery(query, marketSearchClickListener);
|
||||||
}
|
}
|
||||||
mIsSearching = true;
|
mIsSearching = true;
|
||||||
rebindAdapters();
|
rebindAdapters();
|
||||||
@@ -142,7 +142,7 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if (!mUsingTabs && isSearching()) {
|
if (!mUsingTabs && mIsSearching) {
|
||||||
return getContext().getString(R.string.all_apps_search_results);
|
return getContext().getString(R.string.all_apps_search_results);
|
||||||
} else {
|
} else {
|
||||||
return super.getDescription();
|
return super.getDescription();
|
||||||
@@ -150,13 +150,8 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldShowTabs() {
|
protected boolean showTabs() {
|
||||||
return super.shouldShowTabs() && !isSearching();
|
return super.showTabs() && !mIsSearching;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSearching() {
|
|
||||||
return mIsSearching;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -178,19 +173,15 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected View replaceAppsRVContainer(boolean showTabs) {
|
protected View replaceRVContainer(boolean showTabs) {
|
||||||
View rvContainer = super.replaceAppsRVContainer(showTabs);
|
View rvContainer = super.replaceRVContainer(showTabs);
|
||||||
|
|
||||||
removeCustomRules(rvContainer);
|
removeCustomRules(rvContainer);
|
||||||
removeCustomRules(getSearchRecyclerView());
|
|
||||||
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
|
||||||
alignParentTop(rvContainer, showTabs);
|
alignParentTop(rvContainer, showTabs);
|
||||||
alignParentTop(getSearchRecyclerView(), showTabs);
|
|
||||||
layoutAboveSearchContainer(rvContainer);
|
layoutAboveSearchContainer(rvContainer);
|
||||||
layoutAboveSearchContainer(getSearchRecyclerView());
|
|
||||||
} else {
|
} else {
|
||||||
layoutBelowSearchContainer(rvContainer, showTabs);
|
layoutBelowSearchContainer(rvContainer, showTabs);
|
||||||
layoutBelowSearchContainer(getSearchRecyclerView(), showTabs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rvContainer;
|
return rvContainer;
|
||||||
@@ -217,7 +208,7 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
|
|
||||||
float prog = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
|
float prog = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
|
||||||
boolean bgVisible = mSearchUiManager.getBackgroundVisibility();
|
boolean bgVisible = mSearchUiManager.getBackgroundVisibility();
|
||||||
if (scrolledOffset == 0 && !isSearching()) {
|
if (scrolledOffset == 0 && !mIsSearching) {
|
||||||
bgVisible = true;
|
bgVisible = true;
|
||||||
} else if (scrolledOffset > mHeaderThreshold) {
|
} else if (scrolledOffset > mHeaderThreshold) {
|
||||||
bgVisible = false;
|
bgVisible = false;
|
||||||
@@ -251,7 +242,7 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
int topMargin = getContext().getResources().getDimensionPixelSize(
|
int topMargin = getContext().getResources().getDimensionPixelSize(
|
||||||
R.dimen.all_apps_header_top_margin);
|
R.dimen.all_apps_header_top_margin);
|
||||||
if (includeTabsMargin) {
|
if (includeTabsMargin) {
|
||||||
topMargin += getContext().getResources().getDimensionPixelSize(
|
topMargin = topMargin + getContext().getResources().getDimensionPixelSize(
|
||||||
R.dimen.all_apps_header_pill_height);
|
R.dimen.all_apps_header_pill_height);
|
||||||
}
|
}
|
||||||
layoutParams.topMargin = topMargin;
|
layoutParams.topMargin = topMargin;
|
||||||
@@ -292,9 +283,9 @@ public class ActivityAllAppsContainerView<T extends Context & AppLauncher
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList,
|
protected BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<T> mAppsList,
|
||||||
BaseAdapterProvider[] adapterProviders) {
|
BaseAdapterProvider[] adapterProviders) {
|
||||||
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
|
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), mAppsList,
|
||||||
adapterProviders);
|
adapterProviders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ import android.view.View;
|
|||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.android.launcher3.BaseRecyclerView;
|
||||||
import com.android.launcher3.DeviceProfile;
|
import com.android.launcher3.DeviceProfile;
|
||||||
import com.android.launcher3.FastScrollRecyclerView;
|
|
||||||
import com.android.launcher3.LauncherAppState;
|
import com.android.launcher3.LauncherAppState;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
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.
|
* A RecyclerView with custom fast scroll support for the all apps view.
|
||||||
*/
|
*/
|
||||||
public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
public class AllAppsRecyclerView extends BaseRecyclerView {
|
||||||
protected static final String TAG = "AllAppsRecyclerView";
|
private static final String TAG = "AllAppsContainerView";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING);
|
private static final boolean DEBUG_LATENCY = Utilities.isPropertyEnabled(SEARCH_LOGGING);
|
||||||
|
|
||||||
protected AlphabeticalAppsList<?> mApps;
|
private AlphabeticalAppsList<?> mApps;
|
||||||
protected final int mNumAppsPerRow;
|
private final int mNumAppsPerRow;
|
||||||
|
|
||||||
// The specific view heights that we use to calculate scroll
|
// The specific view heights that we use to calculate scroll
|
||||||
private final SparseIntArray mViewHeights = new SparseIntArray();
|
private final SparseIntArray mViewHeights = new SparseIntArray();
|
||||||
@@ -74,8 +74,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// The empty-search result background
|
// The empty-search result background
|
||||||
protected AllAppsBackgroundDrawable mEmptySearchBackground;
|
private AllAppsBackgroundDrawable mEmptySearchBackground;
|
||||||
protected int mEmptySearchBackgroundTopOffset;
|
private int mEmptySearchBackgroundTopOffset;
|
||||||
|
|
||||||
private ArrayList<View> mAutoSizedOverlays = new ArrayList<>();
|
private ArrayList<View> mAutoSizedOverlays = new ArrayList<>();
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
|||||||
return mApps;
|
return mApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updatePoolSize() {
|
private void updatePoolSize() {
|
||||||
DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
|
DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
|
||||||
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
|
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
|
||||||
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
|
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
|
||||||
@@ -137,8 +137,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
|||||||
Log.d(TAG, "onDraw at = " + System.currentTimeMillis());
|
Log.d(TAG, "onDraw at = " + System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
if (DEBUG_LATENCY) {
|
if (DEBUG_LATENCY) {
|
||||||
Log.d(SEARCH_LOGGING, getClass().getSimpleName() + " onDraw; time stamp = "
|
Log.d(SEARCH_LOGGING,
|
||||||
+ System.currentTimeMillis());
|
"-- Recycle view onDraw, time stamp = " + System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
super.onDraw(c);
|
super.onDraw(c);
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
|||||||
&& mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) {
|
&& mEmptySearchBackground != null && mEmptySearchBackground.getAlpha() > 0) {
|
||||||
mEmptySearchBackground.setHotspot(e.getX(), e.getY());
|
mEmptySearchBackground.setHotspot(e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
hideKeyboardAsync(ActivityContext.lookupContext(getContext()), getApplicationWindowToken());
|
hideKeyboardAsync(ActivityContext.lookupContext(getContext()),
|
||||||
|
getApplicationWindowToken());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +359,13 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public int getCurrentScrollY() {
|
public int getCurrentScrollY() {
|
||||||
// Return early if there are no items or we haven't been measured
|
// Return early if there are no items or we haven't been measured
|
||||||
@@ -368,7 +376,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
|
|||||||
|
|
||||||
// Calculate the y and offset for the item
|
// Calculate the y and offset for the item
|
||||||
View child = getChildAt(0);
|
View child = getChildAt(0);
|
||||||
int position = getChildAdapterPosition(child);
|
int position = getChildPosition(child);
|
||||||
if (position == NO_POSITION) {
|
if (position == NO_POSITION) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ public class AllAppsTransitionController
|
|||||||
@Override
|
@Override
|
||||||
public Float get(AllAppsTransitionController controller) {
|
public Float get(AllAppsTransitionController controller) {
|
||||||
if (controller.mIsTablet) {
|
if (controller.mIsTablet) {
|
||||||
return controller.mAppsView.getAppsRecyclerViewContainer()
|
return controller.mAppsView.getRecyclerViewContainer().getTranslationY();
|
||||||
.getTranslationY();
|
|
||||||
} else {
|
} else {
|
||||||
return controller.getAppsViewPullbackTranslationY().get(
|
return controller.getAppsViewPullbackTranslationY().get(
|
||||||
controller.mAppsView);
|
controller.mAppsView);
|
||||||
@@ -95,7 +94,7 @@ public class AllAppsTransitionController
|
|||||||
@Override
|
@Override
|
||||||
public void setValue(AllAppsTransitionController controller, float translation) {
|
public void setValue(AllAppsTransitionController controller, float translation) {
|
||||||
if (controller.mIsTablet) {
|
if (controller.mIsTablet) {
|
||||||
controller.mAppsView.getAppsRecyclerViewContainer().setTranslationY(
|
controller.mAppsView.getRecyclerViewContainer().setTranslationY(
|
||||||
translation);
|
translation);
|
||||||
} else {
|
} else {
|
||||||
controller.getAppsViewPullbackTranslationY().set(controller.mAppsView,
|
controller.getAppsViewPullbackTranslationY().set(controller.mAppsView,
|
||||||
@@ -110,7 +109,7 @@ public class AllAppsTransitionController
|
|||||||
@Override
|
@Override
|
||||||
public Float get(AllAppsTransitionController controller) {
|
public Float get(AllAppsTransitionController controller) {
|
||||||
if (controller.mIsTablet) {
|
if (controller.mIsTablet) {
|
||||||
return controller.mAppsView.getAppsRecyclerViewContainer().getAlpha();
|
return controller.mAppsView.getRecyclerViewContainer().getAlpha();
|
||||||
} else {
|
} else {
|
||||||
return controller.getAppsViewPullbackAlpha().getValue();
|
return controller.getAppsViewPullbackAlpha().getValue();
|
||||||
}
|
}
|
||||||
@@ -119,7 +118,7 @@ public class AllAppsTransitionController
|
|||||||
@Override
|
@Override
|
||||||
public void setValue(AllAppsTransitionController controller, float alpha) {
|
public void setValue(AllAppsTransitionController controller, float alpha) {
|
||||||
if (controller.mIsTablet) {
|
if (controller.mIsTablet) {
|
||||||
controller.mAppsView.getAppsRecyclerViewContainer().setAlpha(alpha);
|
controller.mAppsView.getRecyclerViewContainer().setAlpha(alpha);
|
||||||
} else {
|
} else {
|
||||||
controller.getAppsViewPullbackAlpha().setValue(alpha);
|
controller.getAppsViewPullbackAlpha().setValue(alpha);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package com.android.launcher3.allapps;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
|
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
|
||||||
import com.android.launcher3.config.FeatureFlags;
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
import com.android.launcher3.model.data.AppInfo;
|
import com.android.launcher3.model.data.AppInfo;
|
||||||
@@ -69,7 +67,6 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
|
|
||||||
// The set of apps from the system
|
// The set of apps from the system
|
||||||
private final List<AppInfo> mApps = new ArrayList<>();
|
private final List<AppInfo> mApps = new ArrayList<>();
|
||||||
@Nullable
|
|
||||||
private final AllAppsStore mAllAppsStore;
|
private final AllAppsStore mAllAppsStore;
|
||||||
|
|
||||||
// The number of results in current adapter
|
// The number of results in current adapter
|
||||||
@@ -87,16 +84,14 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
private int mNumAppRowsInAdapter;
|
private int mNumAppRowsInAdapter;
|
||||||
private ItemInfoMatcher mItemFilter;
|
private ItemInfoMatcher mItemFilter;
|
||||||
|
|
||||||
public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore,
|
public AlphabeticalAppsList(Context context, AllAppsStore appsStore,
|
||||||
WorkAdapterProvider adapterProvider) {
|
WorkAdapterProvider adapterProvider) {
|
||||||
mAllAppsStore = appsStore;
|
mAllAppsStore = appsStore;
|
||||||
mActivityContext = ActivityContext.lookupContext(context);
|
mActivityContext = ActivityContext.lookupContext(context);
|
||||||
mAppNameComparator = new AppInfoComparator(context);
|
mAppNameComparator = new AppInfoComparator(context);
|
||||||
mWorkAdapterProvider = adapterProvider;
|
mWorkAdapterProvider = adapterProvider;
|
||||||
mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
|
mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
|
||||||
if (mAllAppsStore != null) {
|
mAllAppsStore.addUpdateListener(this);
|
||||||
mAllAppsStore.addUpdateListener(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateItemFilter(ItemInfoMatcher itemFilter) {
|
public void updateItemFilter(ItemInfoMatcher itemFilter) {
|
||||||
@@ -169,9 +164,9 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether there are search results which will hide the A-Z list.
|
* Returns whether there are is a filter set.
|
||||||
*/
|
*/
|
||||||
public boolean hasSearchResults() {
|
public boolean hasFilter() {
|
||||||
return !mSearchResults.isEmpty();
|
return !mSearchResults.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +174,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
* Returns whether there are no filtered results.
|
* Returns whether there are no filtered results.
|
||||||
*/
|
*/
|
||||||
public boolean hasNoFilteredResults() {
|
public boolean hasNoFilteredResults() {
|
||||||
return hasSearchResults() && mAccessibilityResultsCount == 0;
|
return hasFilter() && mAccessibilityResultsCount == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,13 +192,13 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Appends results to search. */
|
public boolean appendSearchResults(ArrayList<AdapterItem> results) {
|
||||||
public void appendSearchResults(ArrayList<AdapterItem> results) {
|
if (hasFilter() && results != null && results.size() > 0) {
|
||||||
if (hasSearchResults() && results != null && results.size() > 0) {
|
|
||||||
updateSearchAdapterItems(results, mSearchResults.size());
|
updateSearchAdapterItems(results, mSearchResults.size());
|
||||||
mSearchResults.addAll(results);
|
|
||||||
refreshRecyclerView();
|
refreshRecyclerView();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSearchAdapterItems(ArrayList<AdapterItem> list, int offset) {
|
void updateSearchAdapterItems(ArrayList<AdapterItem> list, int offset) {
|
||||||
@@ -223,14 +218,11 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onAppsUpdated() {
|
public void onAppsUpdated() {
|
||||||
if (mAllAppsStore == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Sort the list of apps
|
// Sort the list of apps
|
||||||
mApps.clear();
|
mApps.clear();
|
||||||
|
|
||||||
for (AppInfo app : mAllAppsStore.getApps()) {
|
for (AppInfo app : mAllAppsStore.getApps()) {
|
||||||
if (mItemFilter == null || mItemFilter.matches(app, null) || hasSearchResults()) {
|
if (mItemFilter == null || mItemFilter.matches(app, null) || hasFilter()) {
|
||||||
mApps.add(app);
|
mApps.add(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,18 +292,7 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
|
// Recreate the filtered and sectioned apps (for convenience for the grid layout) from the
|
||||||
// ordered set of sections
|
// ordered set of sections
|
||||||
|
|
||||||
if (hasSearchResults()) {
|
if (!hasFilter()) {
|
||||||
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();
|
mAccessibilityResultsCount = mApps.size();
|
||||||
if (mWorkAdapterProvider != null) {
|
if (mWorkAdapterProvider != null) {
|
||||||
position += mWorkAdapterProvider.addWorkItems(mAdapterItems);
|
position += mWorkAdapterProvider.addWorkItems(mAdapterItems);
|
||||||
@@ -337,6 +318,18 @@ public class AlphabeticalAppsList<T extends Context & ActivityContext> implement
|
|||||||
|
|
||||||
mAdapterItems.add(appItem);
|
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) {
|
if (mNumAppsPerRowAllApps != 0) {
|
||||||
// Update the number of rows in the adapter after we do all the merging (otherwise, we
|
// Update the number of rows in the adapter after we do all the merging (otherwise, we
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
OnDeviceProfileChangeListener, OnActivePageChangedListener,
|
OnDeviceProfileChangeListener, OnActivePageChangedListener,
|
||||||
ScrimView.ScrimDrawingController {
|
ScrimView.ScrimDrawingController {
|
||||||
|
|
||||||
protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
|
private static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
|
||||||
|
|
||||||
public static final float PULL_MULTIPLIER = .02f;
|
public static final float PULL_MULTIPLIER = .02f;
|
||||||
public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
|
public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
|
||||||
@@ -109,7 +109,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
private int mNavBarScrimHeight = 0;
|
private int mNavBarScrimHeight = 0;
|
||||||
|
|
||||||
private AllAppsPagedView mViewPager;
|
private AllAppsPagedView mViewPager;
|
||||||
private SearchRecyclerView mSearchRecyclerView;
|
|
||||||
|
|
||||||
protected FloatingHeaderView mHeader;
|
protected FloatingHeaderView mHeader;
|
||||||
private View mBottomSheetBackground;
|
private View mBottomSheetBackground;
|
||||||
@@ -142,10 +141,9 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
mActivityContext.getSystemService(UserManager.class),
|
mActivityContext.getSystemService(UserManager.class),
|
||||||
this,
|
this,
|
||||||
Utilities.getPrefs(mActivityContext));
|
Utilities.getPrefs(mActivityContext));
|
||||||
mAH = Arrays.asList(null, null, null);
|
mAH = Arrays.asList(null, null);
|
||||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
|
mAH.set(AdapterHolder.MAIN, new AdapterHolder(false /* isWork */));
|
||||||
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
|
mAH.set(AdapterHolder.WORK, new AdapterHolder(true /* isWork */));
|
||||||
mAH.set(AdapterHolder.SEARCH, new AdapterHolder(AdapterHolder.SEARCH));
|
|
||||||
|
|
||||||
mNavBarScrimPaint = new Paint();
|
mNavBarScrimPaint = new Paint();
|
||||||
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
|
mNavBarScrimPaint.setColor(Themes.getAttrColor(context, R.attr.allAppsNavBarScrimColor));
|
||||||
@@ -177,7 +175,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
Bundle state = (Bundle) sparseArray.get(R.id.work_tab_state_id, null);
|
Bundle state = (Bundle) sparseArray.get(R.id.work_tab_state_id, null);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
int currentPage = state.getInt(BUNDLE_KEY_CURRENT_PAGE, 0);
|
int currentPage = state.getInt(BUNDLE_KEY_CURRENT_PAGE, 0);
|
||||||
if (currentPage == AdapterHolder.WORK && mViewPager != null) {
|
if (currentPage != 0 && mViewPager != null) {
|
||||||
mViewPager.setCurrentPage(currentPage);
|
mViewPager.setCurrentPage(currentPage);
|
||||||
rebindAdapters();
|
rebindAdapters();
|
||||||
} else {
|
} else {
|
||||||
@@ -200,7 +198,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
*/
|
*/
|
||||||
public void setOnIconLongClickListener(OnLongClickListener listener) {
|
public void setOnIconLongClickListener(OnLongClickListener listener) {
|
||||||
for (AdapterHolder holder : mAH) {
|
for (AdapterHolder holder : mAH) {
|
||||||
holder.mAdapter.setOnIconLongClickListener(listener);
|
holder.adapter.setOnIconLongClickListener(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +213,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
@Override
|
@Override
|
||||||
public void onDeviceProfileChanged(DeviceProfile dp) {
|
public void onDeviceProfileChanged(DeviceProfile dp) {
|
||||||
for (AdapterHolder holder : mAH) {
|
for (AdapterHolder holder : mAH) {
|
||||||
holder.mAdapter.setAppsPerRow(dp.numShownAllAppsColumns);
|
holder.adapter.setAppsPerRow(dp.numShownAllAppsColumns);
|
||||||
if (holder.mRecyclerView != null) {
|
if (holder.mRecyclerView != null) {
|
||||||
// Remove all views and clear the pool, while keeping the data same. After this
|
// Remove all views and clear the pool, while keeping the data same. After this
|
||||||
// call, all the viewHolders will be recreated.
|
// call, all the viewHolders will be recreated.
|
||||||
@@ -239,7 +237,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mHasWorkApps = hasWorkApps;
|
mHasWorkApps = hasWorkApps;
|
||||||
if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasSearchResults()) {
|
if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasFilter()) {
|
||||||
rebindAdapters();
|
rebindAdapters();
|
||||||
if (hasWorkApps) {
|
if (hasWorkApps) {
|
||||||
mWorkManager.reset();
|
mWorkManager.reset();
|
||||||
@@ -258,11 +256,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
if (mActivityContext.getDragLayer().isEventOverView(mBottomSheetHandleArea, ev)) {
|
if (mActivityContext.getDragLayer().isEventOverView(mBottomSheetHandleArea, ev)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isSearching()) {
|
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||||
return mAH.get(AdapterHolder.SEARCH).mRecyclerView
|
|
||||||
.shouldContainerScroll(ev, mActivityContext.getDragLayer());
|
|
||||||
}
|
|
||||||
AllAppsRecyclerView rv = getActiveAppsRecyclerView();
|
|
||||||
if (rv == null) {
|
if (rv == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -276,7 +270,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
AllAppsRecyclerView rv = getActiveAppsRecyclerView();
|
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||||
if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
|
if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
|
||||||
mFastScrollerOffset)) {
|
mFastScrollerOffset)) {
|
||||||
mTouchHandler = rv.getScrollbar();
|
mTouchHandler = rv.getScrollbar();
|
||||||
@@ -293,7 +287,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent ev) {
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
AllAppsRecyclerView rv = getActiveAppsRecyclerView();
|
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||||
if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
|
if (rv != null && rv.getScrollbar().isHitInParent(ev.getX(), ev.getY(),
|
||||||
mFastScrollerOffset)) {
|
mFastScrollerOffset)) {
|
||||||
mTouchHandler = rv.getScrollbar();
|
mTouchHandler = rv.getScrollbar();
|
||||||
@@ -326,8 +320,8 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
return getContext().getString(R.string.all_apps_button_label);
|
return getContext().getString(R.string.all_apps_button_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The current apps recycler view in the container (may be hidden for search results). */
|
/** The current recycler view visible in the container. */
|
||||||
public AllAppsRecyclerView getActiveAppsRecyclerView() {
|
public AllAppsRecyclerView getActiveRecyclerView() {
|
||||||
if (!mUsingTabs || isPersonalTab()) {
|
if (!mUsingTabs || isPersonalTab()) {
|
||||||
return mAH.get(AdapterHolder.MAIN).mRecyclerView;
|
return mAH.get(AdapterHolder.MAIN).mRecyclerView;
|
||||||
} else {
|
} else {
|
||||||
@@ -376,15 +370,12 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
// This is a focus listener that proxies focus from a view into the list view. This is to
|
// This is a focus listener that proxies focus from a view into the list view. This is to
|
||||||
// work around the search box from getting first focus and showing the cursor.
|
// work around the search box from getting first focus and showing the cursor.
|
||||||
setOnFocusChangeListener((v, hasFocus) -> {
|
setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
if (hasFocus && getActiveAppsRecyclerView() != null) {
|
if (hasFocus && getActiveRecyclerView() != null) {
|
||||||
getActiveAppsRecyclerView().requestFocus();
|
getActiveRecyclerView().requestFocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mHeader = findViewById(R.id.all_apps_header);
|
mHeader = findViewById(R.id.all_apps_header);
|
||||||
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
|
|
||||||
mAH.get(AdapterHolder.SEARCH).setup(mSearchRecyclerView,
|
|
||||||
/* Filter out A-Z apps */ (itemInfo, componentName) -> false);
|
|
||||||
rebindAdapters(true /* force */);
|
rebindAdapters(true /* force */);
|
||||||
|
|
||||||
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
|
mBottomSheetBackground = findViewById(R.id.bottom_sheet_background);
|
||||||
@@ -447,19 +438,13 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void rebindAdapters(boolean force) {
|
protected void rebindAdapters(boolean force) {
|
||||||
updateSearchResultsVisibility();
|
boolean showTabs = showTabs();
|
||||||
|
|
||||||
boolean showTabs = shouldShowTabs();
|
|
||||||
if (showTabs == mUsingTabs && !force) {
|
if (showTabs == mUsingTabs && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mUsingTabs = showTabs;
|
mUsingTabs = showTabs;
|
||||||
|
replaceRVContainer(mUsingTabs);
|
||||||
|
|
||||||
if (isSearching()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceAppsRVContainer(mUsingTabs);
|
|
||||||
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
|
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
|
||||||
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
|
mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
|
||||||
|
|
||||||
@@ -494,17 +479,6 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
|
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSearchResultsVisibility() {
|
|
||||||
if (isSearching()) {
|
|
||||||
getSearchRecyclerView().setVisibility(VISIBLE);
|
|
||||||
getAppsRecyclerViewContainer().setVisibility(GONE);
|
|
||||||
} else {
|
|
||||||
getSearchRecyclerView().setVisibility(GONE);
|
|
||||||
getAppsRecyclerViewContainer().setVisibility(VISIBLE);
|
|
||||||
}
|
|
||||||
mHeader.setActiveRV(getCurrentPage());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDeviceManagementResources() {
|
private void setDeviceManagementResources() {
|
||||||
if (mActivityContext.getStringCache() != null) {
|
if (mActivityContext.getStringCache() != null) {
|
||||||
Button personalTab = findViewById(R.id.tab_personal);
|
Button personalTab = findViewById(R.id.tab_personal);
|
||||||
@@ -515,23 +489,18 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldShowTabs() {
|
protected boolean showTabs() {
|
||||||
return mHasWorkApps;
|
return mHasWorkApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isSearching() {
|
protected View replaceRVContainer(boolean showTabs) {
|
||||||
return false;
|
for (AdapterHolder adapterHolder : mAH) {
|
||||||
}
|
|
||||||
|
|
||||||
protected View replaceAppsRVContainer(boolean showTabs) {
|
|
||||||
for (int i = AdapterHolder.MAIN; i <= AdapterHolder.WORK; i++) {
|
|
||||||
AdapterHolder adapterHolder = mAH.get(i);
|
|
||||||
if (adapterHolder.mRecyclerView != null) {
|
if (adapterHolder.mRecyclerView != null) {
|
||||||
adapterHolder.mRecyclerView.setLayoutManager(null);
|
adapterHolder.mRecyclerView.setLayoutManager(null);
|
||||||
adapterHolder.mRecyclerView.setAdapter(null);
|
adapterHolder.mRecyclerView.setAdapter(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
View oldView = getAppsRecyclerViewContainer();
|
View oldView = getRecyclerViewContainer();
|
||||||
int index = indexOfChild(oldView);
|
int index = indexOfChild(oldView);
|
||||||
removeView(oldView);
|
removeView(oldView);
|
||||||
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
|
int layout = showTabs ? R.layout.all_apps_tabs : R.layout.all_apps_rv_layout;
|
||||||
@@ -552,17 +521,13 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
return newView;
|
return newView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getAppsRecyclerViewContainer() {
|
public View getRecyclerViewContainer() {
|
||||||
return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
|
return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchRecyclerView getSearchRecyclerView() {
|
|
||||||
return mSearchRecyclerView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivePageChanged(int currentActivePage) {
|
public void onActivePageChanged(int currentActivePage) {
|
||||||
mHeader.setActiveRV(currentActivePage);
|
mHeader.setMainActive(currentActivePage == AdapterHolder.MAIN);
|
||||||
if (mAH.get(currentActivePage).mRecyclerView != null) {
|
if (mAH.get(currentActivePage).mRecyclerView != null) {
|
||||||
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar();
|
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar();
|
||||||
}
|
}
|
||||||
@@ -591,8 +556,8 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
return isDescendantViewVisible(R.id.tab_work);
|
return isDescendantViewVisible(R.id.tab_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlphabeticalAppsList<T> getSearchResultList() {
|
public AlphabeticalAppsList<T> getApps() {
|
||||||
return mAH.get(AdapterHolder.SEARCH).mAppsList;
|
return mAH.get(AdapterHolder.MAIN).mAppsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FloatingHeaderView getFloatingHeaderView() {
|
public FloatingHeaderView getFloatingHeaderView() {
|
||||||
@@ -601,19 +566,17 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public View getContentView() {
|
public View getContentView() {
|
||||||
return mViewPager == null ? getActiveAppsRecyclerView() : mViewPager;
|
return mViewPager == null ? getActiveRecyclerView() : mViewPager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The current page visible in all apps. */
|
/** The current page visible in all apps. */
|
||||||
public int getCurrentPage() {
|
public int getCurrentPage() {
|
||||||
return isSearching()
|
return mViewPager != null ? mViewPager.getCurrentPage() : AdapterHolder.MAIN;
|
||||||
? AdapterHolder.SEARCH
|
|
||||||
: mViewPager == null ? AdapterHolder.MAIN : mViewPager.getCurrentPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The scroll bar for the active recycler view. */
|
/** The scroll bar for the active recycler view. */
|
||||||
public RecyclerViewFastScroller getScrollBar() {
|
public RecyclerViewFastScroller getScrollBar() {
|
||||||
AllAppsRecyclerView rv = getActiveAppsRecyclerView();
|
AllAppsRecyclerView rv = getActiveRecyclerView();
|
||||||
return rv == null ? null : rv.getScrollbar();
|
return rv == null ? null : rv.getScrollbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,9 +585,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
mHeader.setup(
|
mHeader.setup(
|
||||||
mAH.get(AdapterHolder.MAIN).mRecyclerView,
|
mAH.get(AdapterHolder.MAIN).mRecyclerView,
|
||||||
mAH.get(AdapterHolder.WORK).mRecyclerView,
|
mAH.get(AdapterHolder.WORK).mRecyclerView,
|
||||||
(SearchRecyclerView) mAH.get(AdapterHolder.SEARCH).mRecyclerView,
|
mAH.get(AdapterHolder.WORK).mRecyclerView == null);
|
||||||
getCurrentPage(),
|
|
||||||
/* tabsHidden= */ mAH.get(AdapterHolder.WORK).mRecyclerView == null);
|
|
||||||
|
|
||||||
int padding = mHeader.getMaxTranslation();
|
int padding = mHeader.getMaxTranslation();
|
||||||
for (int i = 0; i < mAH.size(); i++) {
|
for (int i = 0; i < mAH.size(); i++) {
|
||||||
@@ -735,48 +696,39 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
return ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, blendRatio);
|
return ColorUtils.blendARGB(mScrimColor, mHeaderProtectionColor, blendRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> mAppsList,
|
protected abstract BaseAllAppsAdapter getAdapter(AlphabeticalAppsList<T> mAppsList,
|
||||||
BaseAdapterProvider[] adapterProviders);
|
BaseAdapterProvider[] adapterProviders);
|
||||||
|
|
||||||
protected int getHeaderBottom() {
|
protected int getHeaderBottom() {
|
||||||
return (int) getTranslationY();
|
return (int) getTranslationY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a view that denotes the visible part of all apps container view.
|
|
||||||
*/
|
|
||||||
public View getVisibleContainerView() {
|
|
||||||
return mActivityContext.getDeviceProfile().isTablet ? mBottomSheetBackground : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Holds a {@link BaseAllAppsAdapter} and related fields. */
|
/** Holds a {@link BaseAllAppsAdapter} and related fields. */
|
||||||
public class AdapterHolder {
|
public class AdapterHolder {
|
||||||
public static final int MAIN = 0;
|
public static final int MAIN = 0;
|
||||||
public static final int WORK = 1;
|
public static final int WORK = 1;
|
||||||
public static final int SEARCH = 2;
|
|
||||||
|
|
||||||
private final int mType;
|
private final boolean mIsWork;
|
||||||
public final BaseAllAppsAdapter<T> mAdapter;
|
public final BaseAllAppsAdapter<T> adapter;
|
||||||
final RecyclerView.LayoutManager mLayoutManager;
|
final RecyclerView.LayoutManager mLayoutManager;
|
||||||
final AlphabeticalAppsList<T> mAppsList;
|
final AlphabeticalAppsList<T> mAppsList;
|
||||||
final Rect mPadding = new Rect();
|
final Rect mPadding = new Rect();
|
||||||
AllAppsRecyclerView mRecyclerView;
|
AllAppsRecyclerView mRecyclerView;
|
||||||
boolean mVerticalFadingEdge;
|
boolean mVerticalFadingEdge;
|
||||||
|
|
||||||
AdapterHolder(int type) {
|
AdapterHolder(boolean isWork) {
|
||||||
mType = type;
|
mIsWork = isWork;
|
||||||
mAppsList = new AlphabeticalAppsList<>(mActivityContext,
|
mAppsList = new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore,
|
||||||
isSearch() ? null : mAllAppsStore,
|
isWork ? mWorkManager.getAdapterProvider() : null);
|
||||||
isWork() ? mWorkManager.getAdapterProvider() : null);
|
|
||||||
|
|
||||||
BaseAdapterProvider[] adapterProviders =
|
BaseAdapterProvider[] adapterProviders =
|
||||||
isWork() ? new BaseAdapterProvider[]{mMainAdapterProvider,
|
isWork ? new BaseAdapterProvider[]{mMainAdapterProvider,
|
||||||
mWorkManager.getAdapterProvider()}
|
mWorkManager.getAdapterProvider()}
|
||||||
: new BaseAdapterProvider[]{mMainAdapterProvider};
|
: new BaseAdapterProvider[]{mMainAdapterProvider};
|
||||||
|
|
||||||
mAdapter = createAdapter(mAppsList, adapterProviders);
|
adapter = getAdapter(mAppsList, adapterProviders);
|
||||||
mAppsList.setAdapter(mAdapter);
|
mAppsList.setAdapter(adapter);
|
||||||
mLayoutManager = mAdapter.getLayoutManager();
|
mLayoutManager = adapter.getLayoutManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(@NonNull View rv, @Nullable ItemInfoMatcher matcher) {
|
void setup(@NonNull View rv, @Nullable ItemInfoMatcher matcher) {
|
||||||
@@ -785,14 +737,14 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
|
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
|
||||||
mRecyclerView.setApps(mAppsList);
|
mRecyclerView.setApps(mAppsList);
|
||||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||||
mRecyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(adapter);
|
||||||
mRecyclerView.setHasFixedSize(true);
|
mRecyclerView.setHasFixedSize(true);
|
||||||
// No animations will occur when changes occur to the items in this RecyclerView.
|
// No animations will occur when changes occur to the items in this RecyclerView.
|
||||||
mRecyclerView.setItemAnimator(null);
|
mRecyclerView.setItemAnimator(null);
|
||||||
mRecyclerView.addOnScrollListener(mScrollListener);
|
mRecyclerView.addOnScrollListener(mScrollListener);
|
||||||
FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView);
|
FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView);
|
||||||
mRecyclerView.addItemDecoration(focusedItemDecorator);
|
mRecyclerView.addItemDecoration(focusedItemDecorator);
|
||||||
mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
|
adapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
|
||||||
applyVerticalFadingEdgeEnabled(mVerticalFadingEdge);
|
applyVerticalFadingEdgeEnabled(mVerticalFadingEdge);
|
||||||
applyPadding();
|
applyPadding();
|
||||||
}
|
}
|
||||||
@@ -800,7 +752,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
void applyPadding() {
|
void applyPadding() {
|
||||||
if (mRecyclerView != null) {
|
if (mRecyclerView != null) {
|
||||||
int bottomOffset = 0;
|
int bottomOffset = 0;
|
||||||
if (isWork() && mWorkManager.getWorkModeSwitch() != null) {
|
if (mIsWork && mWorkManager.getWorkModeSwitch() != null) {
|
||||||
bottomOffset = mInsets.bottom + mWorkManager.getWorkModeSwitch().getHeight();
|
bottomOffset = mInsets.bottom + mWorkManager.getWorkModeSwitch().getHeight();
|
||||||
}
|
}
|
||||||
mRecyclerView.setPadding(mPadding.left, mPadding.top, mPadding.right,
|
mRecyclerView.setPadding(mPadding.left, mPadding.top, mPadding.right,
|
||||||
@@ -810,15 +762,15 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
|||||||
|
|
||||||
private void applyVerticalFadingEdgeEnabled(boolean enabled) {
|
private void applyVerticalFadingEdgeEnabled(boolean enabled) {
|
||||||
mVerticalFadingEdge = enabled;
|
mVerticalFadingEdge = enabled;
|
||||||
mRecyclerView.setVerticalFadingEdgeEnabled(!mUsingTabs && mVerticalFadingEdge);
|
mAH.get(AdapterHolder.MAIN).mRecyclerView.setVerticalFadingEdgeEnabled(!mUsingTabs
|
||||||
}
|
&& mVerticalFadingEdge);
|
||||||
|
|
||||||
private boolean isWork() {
|
|
||||||
return mType == WORK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSearch() {
|
|
||||||
return mType == SEARCH;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a view that denotes the visible part of all apps container view.
|
||||||
|
*/
|
||||||
|
public View getVisibleContainerView() {
|
||||||
|
return mActivityContext.getDeviceProfile().isTablet ? mBottomSheetBackground : this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import com.android.launcher3.DeviceProfile;
|
import com.android.launcher3.DeviceProfile;
|
||||||
import com.android.launcher3.Insettable;
|
import com.android.launcher3.Insettable;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.allapps.BaseAllAppsContainerView.AdapterHolder;
|
|
||||||
import com.android.launcher3.config.FeatureFlags;
|
import com.android.launcher3.config.FeatureFlags;
|
||||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||||
import com.android.launcher3.views.ActivityContext;
|
import com.android.launcher3.views.ActivityContext;
|
||||||
@@ -91,8 +90,8 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
protected ViewGroup mTabLayout;
|
protected ViewGroup mTabLayout;
|
||||||
private AllAppsRecyclerView mMainRV;
|
private AllAppsRecyclerView mMainRV;
|
||||||
private AllAppsRecyclerView mWorkRV;
|
private AllAppsRecyclerView mWorkRV;
|
||||||
private SearchRecyclerView mSearchRV;
|
|
||||||
private AllAppsRecyclerView mCurrentRV;
|
private AllAppsRecyclerView mCurrentRV;
|
||||||
|
private ViewGroup mParent;
|
||||||
public boolean mHeaderCollapsed;
|
public boolean mHeaderCollapsed;
|
||||||
protected int mSnappedScrolledY;
|
protected int mSnappedScrolledY;
|
||||||
private int mTranslationY;
|
private int mTranslationY;
|
||||||
@@ -101,6 +100,7 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
|
|
||||||
protected boolean mTabsHidden;
|
protected boolean mTabsHidden;
|
||||||
protected int mMaxTranslation;
|
protected int mMaxTranslation;
|
||||||
|
private boolean mMainRVActive = true;
|
||||||
|
|
||||||
private boolean mCollapsed = false;
|
private boolean mCollapsed = false;
|
||||||
|
|
||||||
@@ -232,8 +232,7 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
return super.getFocusedChild();
|
return super.getFocusedChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(AllAppsRecyclerView mainRV, AllAppsRecyclerView workRV, SearchRecyclerView searchRV,
|
void setup(AllAppsRecyclerView mainRV, AllAppsRecyclerView workRV, boolean tabsHidden) {
|
||||||
int activeRV, boolean tabsHidden) {
|
|
||||||
for (FloatingHeaderRow row : mAllRows) {
|
for (FloatingHeaderRow row : mAllRows) {
|
||||||
row.setup(this, mAllRows, tabsHidden);
|
row.setup(this, mAllRows, tabsHidden);
|
||||||
}
|
}
|
||||||
@@ -243,8 +242,8 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE);
|
mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE);
|
||||||
mMainRV = setupRV(mMainRV, mainRV);
|
mMainRV = setupRV(mMainRV, mainRV);
|
||||||
mWorkRV = setupRV(mWorkRV, workRV);
|
mWorkRV = setupRV(mWorkRV, workRV);
|
||||||
mSearchRV = (SearchRecyclerView) setupRV(mSearchRV, searchRV);
|
mParent = (ViewGroup) mMainRV.getParent();
|
||||||
setActiveRV(activeRV);
|
setMainActive(mMainRVActive || mWorkRV == null);
|
||||||
reset(false);
|
reset(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,10 +267,9 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveRV(int rvType) {
|
public void setMainActive(boolean active) {
|
||||||
mCurrentRV =
|
mCurrentRV = active ? mMainRV : mWorkRV;
|
||||||
rvType == AdapterHolder.MAIN ? mMainRV
|
mMainRVActive = active;
|
||||||
: rvType == AdapterHolder.WORK ? mWorkRV : mSearchRV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxTranslation() {
|
public int getMaxTranslation() {
|
||||||
@@ -334,15 +332,10 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
mHeaderClip.top = clipTop;
|
mHeaderClip.top = clipTop;
|
||||||
// clipping on a draw might cause additional redraw
|
// clipping on a draw might cause additional redraw
|
||||||
setClipBounds(mHeaderClip);
|
setClipBounds(mHeaderClip);
|
||||||
if (mMainRV != null) {
|
mMainRV.setClipBounds(mRVClip);
|
||||||
mMainRV.setClipBounds(mRVClip);
|
|
||||||
}
|
|
||||||
if (mWorkRV != null) {
|
if (mWorkRV != null) {
|
||||||
mWorkRV.setClipBounds(mRVClip);
|
mWorkRV.setClipBounds(mRVClip);
|
||||||
}
|
}
|
||||||
if (mSearchRV != null) {
|
|
||||||
mSearchRV.setClipBounds(mRVClip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -409,8 +402,8 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void calcOffset(Point p) {
|
private void calcOffset(Point p) {
|
||||||
p.x = getLeft() - mCurrentRV.getLeft() - ((ViewGroup) mCurrentRV.getParent()).getLeft();
|
p.x = getLeft() - mCurrentRV.getLeft() - mParent.getLeft();
|
||||||
p.y = getTop() - mCurrentRV.getTop() - ((ViewGroup) mCurrentRV.getParent()).getTop();
|
p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasVisibleContent() {
|
public boolean hasVisibleContent() {
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.android.launcher3.allapps;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
|
|
||||||
/** A RecyclerView for AllApps Search results. */
|
|
||||||
public class SearchRecyclerView extends AllAppsRecyclerView {
|
|
||||||
private static final String TAG = "SearchRecyclerView";
|
|
||||||
|
|
||||||
public SearchRecyclerView(Context context) {
|
|
||||||
this(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchRecyclerView(Context context, AttributeSet attrs) {
|
|
||||||
this(context, attrs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
||||||
this(context, attrs, defStyleAttr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchRecyclerView(Context context, AttributeSet attrs, int defStyleAttr,
|
|
||||||
int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updatePoolSize() {
|
|
||||||
RecycledViewPool pool = getRecycledViewPool();
|
|
||||||
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, mNumAppsPerRow);
|
|
||||||
// TODO(b/206905515): Add maxes for other View types.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supportsFastScrolling() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -71,7 +71,7 @@ public class WorkEduCard extends FrameLayout implements
|
|||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
findViewById(R.id.action_btn).setOnClickListener(this);
|
findViewById(R.id.action_btn).setOnClickListener(this);
|
||||||
MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
|
MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
|
||||||
lp.width = mActivityContext.getAppsView().getActiveAppsRecyclerView().getTabWidth();
|
lp.width = mActivityContext.getAppsView().getActiveRecyclerView().getTabWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
|
|||||||
private final AllAppsSearchBarController mSearchBarController;
|
private final AllAppsSearchBarController mSearchBarController;
|
||||||
private final SpannableStringBuilder mSearchQueryBuilder;
|
private final SpannableStringBuilder mSearchQueryBuilder;
|
||||||
|
|
||||||
private AlphabeticalAppsList<?> mSearchResultsList;
|
private AlphabeticalAppsList<?> mApps;
|
||||||
private ActivityAllAppsContainerView<?> mAppsView;
|
private ActivityAllAppsContainerView<?> mAppsView;
|
||||||
|
|
||||||
// The amount of pixels to shift down and overlap with the rest of the content.
|
// The amount of pixels to shift down and overlap with the rest of the content.
|
||||||
@@ -102,8 +102,8 @@ public class AppsSearchContainerLayout extends ExtendedEditText
|
|||||||
// Update the width to match the grid padding
|
// Update the width to match the grid padding
|
||||||
DeviceProfile dp = mLauncher.getDeviceProfile();
|
DeviceProfile dp = mLauncher.getDeviceProfile();
|
||||||
int myRequestedWidth = getSize(widthMeasureSpec);
|
int myRequestedWidth = getSize(widthMeasureSpec);
|
||||||
int rowWidth = myRequestedWidth - mAppsView.getActiveAppsRecyclerView().getPaddingLeft()
|
int rowWidth = myRequestedWidth - mAppsView.getActiveRecyclerView().getPaddingLeft()
|
||||||
- mAppsView.getActiveAppsRecyclerView().getPaddingRight();
|
- mAppsView.getActiveRecyclerView().getPaddingRight();
|
||||||
|
|
||||||
int cellWidth = DeviceProfile.calculateCellWidth(rowWidth,
|
int cellWidth = DeviceProfile.calculateCellWidth(rowWidth,
|
||||||
dp.cellLayoutBorderSpacePx.x, dp.numShownHotseatIcons);
|
dp.cellLayoutBorderSpacePx.x, dp.numShownHotseatIcons);
|
||||||
@@ -131,7 +131,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeSearch(ActivityAllAppsContainerView<?> appsView) {
|
public void initializeSearch(ActivityAllAppsContainerView<?> appsView) {
|
||||||
mSearchResultsList = appsView.getSearchResultList();
|
mApps = appsView.getApps();
|
||||||
mAppsView = appsView;
|
mAppsView = appsView;
|
||||||
mSearchBarController.initialize(
|
mSearchBarController.initialize(
|
||||||
new DefaultAppSearchAlgorithm(getContext()),
|
new DefaultAppSearchAlgorithm(getContext()),
|
||||||
@@ -170,7 +170,7 @@ public class AppsSearchContainerLayout extends ExtendedEditText
|
|||||||
@Override
|
@Override
|
||||||
public void onSearchResult(String query, ArrayList<AdapterItem> items) {
|
public void onSearchResult(String query, ArrayList<AdapterItem> items) {
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
mSearchResultsList.setSearchResults(items);
|
mApps.setSearchResults(items);
|
||||||
notifyResultChanged();
|
notifyResultChanged();
|
||||||
mAppsView.setLastSearchQuery(query);
|
mAppsView.setLastSearchQuery(query);
|
||||||
}
|
}
|
||||||
@@ -179,14 +179,14 @@ public class AppsSearchContainerLayout extends ExtendedEditText
|
|||||||
@Override
|
@Override
|
||||||
public void onAppendSearchResult(String query, ArrayList<AdapterItem> items) {
|
public void onAppendSearchResult(String query, ArrayList<AdapterItem> items) {
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
mSearchResultsList.appendSearchResults(items);
|
mApps.appendSearchResults(items);
|
||||||
notifyResultChanged();
|
notifyResultChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSearchResult() {
|
public void clearSearchResult() {
|
||||||
if (mSearchResultsList.setSearchResults(null)) {
|
if (mApps.setSearchResults(null)) {
|
||||||
notifyResultChanged();
|
notifyResultChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
|||||||
|
|
||||||
case TestProtocol.REQUEST_APPS_LIST_SCROLL_Y: {
|
case TestProtocol.REQUEST_APPS_LIST_SCROLL_Y: {
|
||||||
return getLauncherUIProperty(Bundle::putInt,
|
return getLauncherUIProperty(Bundle::putInt,
|
||||||
l -> l.getAppsView().getActiveAppsRecyclerView().getCurrentScrollY());
|
l -> l.getAppsView().getActiveRecyclerView().getCurrentScrollY());
|
||||||
}
|
}
|
||||||
|
|
||||||
case TestProtocol.REQUEST_WIDGETS_SCROLL_Y: {
|
case TestProtocol.REQUEST_WIDGETS_SCROLL_Y: {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.launcher3.FastScrollRecyclerView;
|
import com.android.launcher3.BaseRecyclerView;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
import com.android.launcher3.graphics.FastScrollThumbDrawable;
|
import com.android.launcher3.graphics.FastScrollThumbDrawable;
|
||||||
@@ -127,7 +127,7 @@ public class RecyclerViewFastScroller extends View {
|
|||||||
private String mPopupSectionName;
|
private String mPopupSectionName;
|
||||||
private Insets mSystemGestureInsets;
|
private Insets mSystemGestureInsets;
|
||||||
|
|
||||||
protected FastScrollRecyclerView mRv;
|
protected BaseRecyclerView mRv;
|
||||||
private RecyclerView.OnScrollListener mOnScrollListener;
|
private RecyclerView.OnScrollListener mOnScrollListener;
|
||||||
|
|
||||||
private int mDownX;
|
private int mDownX;
|
||||||
@@ -172,7 +172,7 @@ public class RecyclerViewFastScroller extends View {
|
|||||||
ta.recycle();
|
ta.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRecyclerView(FastScrollRecyclerView rv, TextView popupView) {
|
public void setRecyclerView(BaseRecyclerView rv, TextView popupView) {
|
||||||
if (mRv != null && mOnScrollListener != null) {
|
if (mRv != null && mOnScrollListener != null) {
|
||||||
mRv.removeOnScrollListener(mOnScrollListener);
|
mRv.removeOnScrollListener(mOnScrollListener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener;
|
import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener;
|
||||||
|
|
||||||
|
import com.android.launcher3.BaseRecyclerView;
|
||||||
import com.android.launcher3.DeviceProfile;
|
import com.android.launcher3.DeviceProfile;
|
||||||
import com.android.launcher3.FastScrollRecyclerView;
|
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.views.ActivityContext;
|
import com.android.launcher3.views.ActivityContext;
|
||||||
import com.android.launcher3.widget.model.WidgetListSpaceEntry;
|
import com.android.launcher3.widget.model.WidgetListSpaceEntry;
|
||||||
@@ -41,7 +41,7 @@ import com.android.launcher3.widget.picker.WidgetsSpaceViewHolderBinder.EmptySpa
|
|||||||
/**
|
/**
|
||||||
* The widgets recycler view.
|
* The widgets recycler view.
|
||||||
*/
|
*/
|
||||||
public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnItemTouchListener {
|
public class WidgetsRecyclerView extends BaseRecyclerView implements OnItemTouchListener {
|
||||||
|
|
||||||
private WidgetsListAdapter mAdapter;
|
private WidgetsListAdapter mAdapter;
|
||||||
|
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ public abstract class AbstractLauncherUiTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int getAllAppsScroll(Launcher launcher) {
|
protected int getAllAppsScroll(Launcher launcher) {
|
||||||
return launcher.getAppsView().getActiveAppsRecyclerView().getCurrentScrollY();
|
return launcher.getAppsView().getActiveRecyclerView().getCurrentScrollY();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLauncherIntegrity(
|
private void checkLauncherIntegrity(
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
|||||||
executeOnLauncher(l -> {
|
executeOnLauncher(l -> {
|
||||||
ActivityAllAppsContainerView<?> allApps = l.getAppsView();
|
ActivityAllAppsContainerView<?> allApps = l.getAppsView();
|
||||||
assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
|
assertEquals("Work tab is not focused", allApps.getCurrentPage(), WORK_PAGE);
|
||||||
View workPausedCard = allApps.getActiveAppsRecyclerView()
|
View workPausedCard = allApps.getActiveRecyclerView().findViewHolderForAdapterPosition(
|
||||||
.findViewHolderForAdapterPosition(0).itemView;
|
0).itemView;
|
||||||
workPausedCard.findViewById(R.id.enable_work_apps).performClick();
|
workPausedCard.findViewById(R.id.enable_work_apps).performClick();
|
||||||
});
|
});
|
||||||
waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
|
waitForLauncherCondition("Work profile toggle ON failed", launcher -> {
|
||||||
@@ -155,7 +155,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
waitForLauncherCondition("Work profile education not shown",
|
waitForLauncherCondition("Work profile education not shown",
|
||||||
l -> l.getAppsView().getActiveAppsRecyclerView()
|
l -> l.getAppsView().getActiveRecyclerView()
|
||||||
.findViewHolderForAdapterPosition(0).itemView instanceof WorkEduCard,
|
.findViewHolderForAdapterPosition(0).itemView instanceof WorkEduCard,
|
||||||
LauncherInstrumentation.WAIT_TIME_MS);
|
LauncherInstrumentation.WAIT_TIME_MS);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user