Merge branch 'android15-release' into merge-aosp15
This commit is contained in:
commit
eeb7416bfe
1401 files changed
+86072
-39248
No files matched your search
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.Flags.enableExpandingPauseWorkButton;
|
||||
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.MAIN;
|
||||
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_PRIVATE_SPACE_HEADER;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_DISABLED_CARD;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_EDU_CARD;
|
||||
import static com.android.launcher3.config.FeatureFlags.ALL_APPS_GONE_VISIBILITY;
|
||||
@@ -79,9 +82,13 @@ import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
|
||||
import com.android.launcher3.model.StringCache;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.Preconditions;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
@@ -93,6 +100,7 @@ import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -128,7 +136,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
public static final float PULL_MULTIPLIER = .02f;
|
||||
public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
|
||||
protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
|
||||
// As of this writing, search transition does not seem to work properly, so set duration to 0.
|
||||
// As of this writing, search transition does not seem to work properly, so set
|
||||
// duration to 0.
|
||||
private static final long DEFAULT_SEARCH_TRANSITION_DURATION_MS = 0;
|
||||
// Render the header protection at all times to debug clipping issues.
|
||||
private static final boolean DEBUG_HEADER_PROTECTION = false;
|
||||
@@ -138,7 +147,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected final List<AdapterHolder> mAH;
|
||||
protected final Predicate<ItemInfo> mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
Process.myUserHandle());
|
||||
protected final WorkProfileManager mWorkManager;
|
||||
protected WorkProfileManager mWorkManager;
|
||||
protected final PrivateProfileManager mPrivateProfileManager;
|
||||
protected final Point mFastScrollerOffset = new Point();
|
||||
protected final int mScrimColor;
|
||||
protected final float mHeaderThreshold;
|
||||
@@ -157,6 +167,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
};
|
||||
private final Paint mNavBarScrimPaint;
|
||||
private final int mHeaderProtectionColor;
|
||||
private final int mPrivateSpaceBottomExtraSpace;
|
||||
private final Path mTmpPath = new Path();
|
||||
private final RectF mTmpRectF = new RectF();
|
||||
protected AllAppsPagedView mViewPager;
|
||||
@@ -185,6 +196,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected SearchAdapterProvider<?> mMainAdapterProvider;
|
||||
private View mBottomSheetHandleArea;
|
||||
private boolean mHasWorkApps;
|
||||
private boolean mHasPrivateApps;
|
||||
private float[] mBottomSheetCornerRadii;
|
||||
private ScrimView mScrimView;
|
||||
private int mHeaderColor;
|
||||
@@ -218,7 +230,16 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
mWorkManager = new WorkProfileManager(
|
||||
mActivityContext.getSystemService(UserManager.class),
|
||||
this, mActivityContext.getStatsLogManager());
|
||||
this,
|
||||
mActivityContext.getStatsLogManager(),
|
||||
UserCache.INSTANCE.get(mActivityContext));
|
||||
mPrivateProfileManager = new PrivateProfileManager(
|
||||
mActivityContext.getSystemService(UserManager.class),
|
||||
this,
|
||||
mActivityContext.getStatsLogManager(),
|
||||
UserCache.INSTANCE.get(mActivityContext));
|
||||
mPrivateSpaceBottomExtraSpace = context.getResources().getDimensionPixelSize(
|
||||
R.dimen.ps_extra_bottom_padding);
|
||||
mAH = Arrays.asList(null, null, null);
|
||||
mNavBarScrimPaint = new Paint();
|
||||
mNavBarScrimPaint.setColor(Themes.getNavBarScrimColor(mActivityContext));
|
||||
@@ -261,7 +282,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
*/
|
||||
protected void initContent() {
|
||||
showFastScroller = PreferenceExtensionsKt.firstBlocking(pref2.getShowScrollbar());
|
||||
|
||||
|
||||
mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
|
||||
|
||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
|
||||
@@ -307,8 +328,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
0,
|
||||
0 // Bottom left
|
||||
};
|
||||
mBottomSheetBackgroundColor =
|
||||
ColorTokens.SurfaceDimColor.resolveColor(getContext());
|
||||
mBottomSheetBackgroundColor = ColorTokens.SurfaceDimColor.resolveColor(getContext());
|
||||
updateBackgroundVisibility(mActivityContext.getDeviceProfile());
|
||||
mSearchUiManager.initializeSearch(this);
|
||||
}
|
||||
@@ -399,7 +419,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mAllAppsTransitionController = allAppsTransitionController;
|
||||
}
|
||||
|
||||
private void animateToSearchState(boolean goingToSearch, long durationMs) {
|
||||
void animateToSearchState(boolean goingToSearch, long durationMs) {
|
||||
if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
|
||||
return;
|
||||
}
|
||||
@@ -412,7 +432,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mAllAppsTransitionController.animateAllAppsToNoScale();
|
||||
mFastScroller.setVisibility(showFastScroller ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
mSearchTransitionController.animateToSearchState(goingToSearch, durationMs,
|
||||
mSearchTransitionController.animateToState(goingToSearch, durationMs,
|
||||
/* onEndRunnable = */ () -> {
|
||||
mIsSearching = goingToSearch;
|
||||
updateSearchResultsVisibility();
|
||||
@@ -480,7 +500,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
* apps list.
|
||||
*/
|
||||
public void reset(boolean animate, boolean exitSearch) {
|
||||
if (!PreferenceExtensionsKt.firstBlocking (pref2.getRememberPosition ())) {
|
||||
if (!PreferenceExtensionsKt.firstBlocking(pref2.getRememberPosition())) {
|
||||
for (int i = 0; i < mAH.size(); i++) {
|
||||
if (mAH.get(i).mRecyclerView != null) {
|
||||
mAH.get(i).mRecyclerView.scrollToTop();
|
||||
@@ -497,17 +517,45 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
// Reset the base recycler view after transitioning home.
|
||||
updateHeaderScroll(0);
|
||||
if (exitSearch) {
|
||||
// Reset the search bar after transitioning home.
|
||||
// Reset the search bar and search RV after transitioning home.
|
||||
MAIN_EXECUTOR.getHandler().post(mSearchUiManager::resetSearch);
|
||||
// Animate to A-Z with 0 time to reset the animation with proper state
|
||||
// management.
|
||||
animateToSearchState(false, 0);
|
||||
}
|
||||
if (isSearching()) {
|
||||
mWorkManager.reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits search and returns to A-Z apps list. Scroll to the private space
|
||||
* header.
|
||||
*/
|
||||
public void resetAndScrollToPrivateSpaceHeader() {
|
||||
// Animate to A-Z with 0 time to reset the animation with proper state
|
||||
// management.
|
||||
// We can't rely on `animateToSearchState` with delay inside `resetSearch`
|
||||
// because that will
|
||||
// conflict with following scrolling to bottom, so we need it with 0 time here.
|
||||
animateToSearchState(false, 0);
|
||||
|
||||
MAIN_EXECUTOR.getHandler().post(() -> {
|
||||
// Reset the search bar after transitioning home.
|
||||
// When `resetSearch` is called after `animateToSearchState` is finished, the
|
||||
// inside
|
||||
// `animateToSearchState` with delay is a just no-op and return early.
|
||||
mSearchUiManager.resetSearch();
|
||||
// Switch to the main tab
|
||||
switchToTab(ActivityAllAppsContainerView.AdapterHolder.MAIN);
|
||||
// Scroll to bottom
|
||||
if (mPrivateProfileManager != null) {
|
||||
mPrivateProfileManager.scrollForHeaderToBeVisibleInContainer(
|
||||
getActiveAppsRecyclerView(),
|
||||
getPersonalAppList().getAdapterItems(),
|
||||
mPrivateProfileManager.getPsHeaderHeight(),
|
||||
mActivityContext.getDeviceProfile().allAppsCellHeightPx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
mSearchUiManager.preDispatchKeyEvent(event);
|
||||
@@ -569,12 +617,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FeatureFlags.ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES.get()) {
|
||||
RecyclerView.ItemDecoration decoration = getMainAdapterProvider().getDecorator();
|
||||
getSearchRecyclerView().removeItemDecoration(decoration);
|
||||
getSearchRecyclerView().addItemDecoration(decoration);
|
||||
}
|
||||
|
||||
// replaceAppsRVcontainer() needs to use both mUsingTabs value to remove the old
|
||||
// view AND
|
||||
// showTabs value to create new view. Hence the mUsingTabs new value assignment
|
||||
@@ -593,9 +635,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mainRecyclerView = (AllAppsRecyclerView) mViewPager.getChildAt(0);
|
||||
workRecyclerView = (AllAppsRecyclerView) mViewPager.getChildAt(1);
|
||||
mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, mPersonalMatcher);
|
||||
mAH.get(AdapterHolder.WORK).setup(workRecyclerView, mWorkManager.getMatcher());
|
||||
mAH.get(AdapterHolder.WORK).setup(workRecyclerView, mWorkManager.getItemInfoMatcher());
|
||||
workRecyclerView.setId(R.id.apps_list_view_work);
|
||||
if (FeatureFlags.ENABLE_EXPANDING_PAUSE_WORK_BUTTON.get()) {
|
||||
if (enableExpandingPauseWorkButton()
|
||||
|| FeatureFlags.ENABLE_EXPANDING_PAUSE_WORK_BUTTON.get()) {
|
||||
mAH.get(AdapterHolder.WORK).mRecyclerView.addOnScrollListener(
|
||||
mWorkManager.newScrollListener());
|
||||
}
|
||||
@@ -621,7 +664,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
} else {
|
||||
mainRecyclerView = findViewById(R.id.apps_list_view);
|
||||
workRecyclerView = null;
|
||||
mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, null);
|
||||
mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, mPersonalMatcher);
|
||||
mAH.get(AdapterHolder.WORK).mRecyclerView = null;
|
||||
}
|
||||
setUpCustomRecyclerViewPool(
|
||||
@@ -657,16 +700,18 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
private static void setUpCustomRecyclerViewPool(
|
||||
@NonNull AllAppsRecyclerView mainRecyclerView,
|
||||
@Nullable AllAppsRecyclerView workRecyclerView,
|
||||
@NonNull RecyclerView.RecycledViewPool recycledViewPool) {
|
||||
@NonNull AllAppsRecyclerViewPool recycledViewPool) {
|
||||
if (!ENABLE_ALL_APPS_RV_PREINFLATION.get()) {
|
||||
return;
|
||||
}
|
||||
final boolean hasWorkProfile = workRecyclerView != null;
|
||||
recycledViewPool.setHasWorkProfile(hasWorkProfile);
|
||||
mainRecyclerView.setRecycledViewPool(recycledViewPool);
|
||||
if (workRecyclerView != null) {
|
||||
workRecyclerView.setRecycledViewPool(recycledViewPool);
|
||||
}
|
||||
if (ALL_APPS_GONE_VISIBILITY.get()) {
|
||||
mainRecyclerView.updatePoolSize();
|
||||
mainRecyclerView.updatePoolSize(hasWorkProfile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,10 +801,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
protected void updateHeaderScroll(int scrolledOffset) {
|
||||
if (PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) return;
|
||||
if (PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar()))
|
||||
return;
|
||||
float prog1 = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
|
||||
int headerColor = getHeaderColor(prog1);
|
||||
int tabsAlpha = mHeader.getPeripheralProtectionHeight() == 0 ? 0
|
||||
int tabsAlpha = mHeader.getPeripheralProtectionHeight(/* expectedHeight */ false) == 0 ? 0
|
||||
: (int) (Utilities.boundToRange(
|
||||
(scrolledOffset + mHeader.mSnappedScrolledY) / mHeaderThreshold, 0f, 1f)
|
||||
* 255);
|
||||
@@ -861,7 +907,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
private void layoutBelowSearchContainer(View v, boolean includeTabsMargin) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams) || PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)
|
||||
|| PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -878,7 +925,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
private void alignParentTop(View v, boolean includeTabsMargin) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams) || PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)
|
||||
|| PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -891,7 +939,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
private void removeCustomRules(View v) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams) || PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)
|
||||
|| PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -912,7 +961,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
private void layoutWithoutSearchContainer(View v, boolean includeTabsMargin) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams) || PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)
|
||||
|| PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -930,7 +980,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
/** Creates the adapter provider for the main section. */
|
||||
protected SearchAdapterProvider<?> createMainAdapterProvider() {
|
||||
return new DefaultSearchAdapterProvider (mActivityContext);
|
||||
return new DefaultSearchAdapterProvider(mActivityContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -985,6 +1035,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return mWorkManager;
|
||||
}
|
||||
|
||||
/** Returns whether Private Profile has been setup. */
|
||||
public boolean hasPrivateProfile() {
|
||||
return mHasPrivateApps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceProfileChanged(DeviceProfile dp) {
|
||||
for (AdapterHolder holder : mAH) {
|
||||
@@ -1021,13 +1076,20 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mBottomSheetAlpha = mActivityContext.getDeviceProfile().isTablet ? 1f : alpha;
|
||||
}
|
||||
|
||||
private void onAppsUpdated() {
|
||||
mHasWorkApps = Stream.of(mAllAppsStore.getApps()).anyMatch(mWorkManager.getMatcher());
|
||||
@VisibleForTesting
|
||||
public void onAppsUpdated() {
|
||||
mHasWorkApps = Stream.of(mAllAppsStore.getApps())
|
||||
.anyMatch(mWorkManager.getItemInfoMatcher());
|
||||
mHasPrivateApps = Stream.of(mAllAppsStore.getApps())
|
||||
.anyMatch(mPrivateProfileManager.getItemInfoMatcher());
|
||||
if (!isSearching()) {
|
||||
rebindAdapters();
|
||||
if (mHasWorkApps) {
|
||||
mWorkManager.reset();
|
||||
}
|
||||
}
|
||||
if (mHasWorkApps) {
|
||||
mWorkManager.reset();
|
||||
}
|
||||
if (mHasPrivateApps) {
|
||||
mPrivateProfileManager.reset();
|
||||
}
|
||||
|
||||
mActivityContext.getStatsLogManager().logger()
|
||||
@@ -1099,6 +1161,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return getActiveAppsRecyclerView();
|
||||
}
|
||||
|
||||
/** The current focus change listener in the search container. */
|
||||
public OnFocusChangeListener getSearchFocusChangeListener() {
|
||||
return mAH.get(AdapterHolder.SEARCH).mOnFocusChangeListener;
|
||||
}
|
||||
|
||||
/** The current apps recycler view in the container. */
|
||||
private AllAppsRecyclerView getActiveAppsRecyclerView() {
|
||||
if (!mUsingTabs || isPersonalTab()) {
|
||||
@@ -1153,13 +1220,16 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
applyAdapterSideAndBottomPaddings(grid);
|
||||
|
||||
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
|
||||
mlp.leftMargin = insets.left;
|
||||
mlp.rightMargin = insets.right;
|
||||
// Ignore left/right insets on tablet because we are already centered in-screen.
|
||||
if (grid.isTablet) {
|
||||
mlp.leftMargin = mlp.rightMargin = 0;
|
||||
} else {
|
||||
mlp.leftMargin = insets.left;
|
||||
mlp.rightMargin = insets.right;
|
||||
}
|
||||
setLayoutParams(mlp);
|
||||
|
||||
if (grid.isVerticalBarLayout()) {
|
||||
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
|
||||
} else {
|
||||
if (!grid.isVerticalBarLayout() || FeatureFlags.enableResponsiveWorkspace()) {
|
||||
int topPadding = grid.allAppsPadding.top;
|
||||
if (isSearchBarFloating() && !grid.isTablet) {
|
||||
topPadding += getResources().getDimensionPixelSize(
|
||||
@@ -1167,7 +1237,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
setPadding(grid.allAppsLeftRightMargin, topPadding, grid.allAppsLeftRightMargin, 0);
|
||||
}
|
||||
|
||||
InsettableFrameLayout.dispatchInsets(this, insets);
|
||||
}
|
||||
|
||||
@@ -1222,7 +1291,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
int bottomPadding = Math.max(mInsets.bottom, mNavBarScrimHeight);
|
||||
mAH.forEach(adapterHolder -> {
|
||||
adapterHolder.mPadding.bottom = bottomPadding;
|
||||
adapterHolder.mPadding.left = adapterHolder.mPadding.right = grid.allAppsPadding.left + grid.allAppsPadding.right;
|
||||
adapterHolder.mPadding.left = adapterHolder.mPadding.right = grid.allAppsPadding.left
|
||||
+ grid.allAppsPadding.right;
|
||||
adapterHolder.applyPadding();
|
||||
});
|
||||
}
|
||||
@@ -1284,6 +1354,11 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setWorkManager(WorkProfileManager workManager) {
|
||||
mWorkManager = workManager;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean isPersonalTabVisible() {
|
||||
return isDescendantViewVisible(R.id.tab_personal);
|
||||
@@ -1298,6 +1373,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return mAH.get(SEARCH).mAppsList;
|
||||
}
|
||||
|
||||
public AlphabeticalAppsList<T> getPersonalAppList() {
|
||||
return mAH.get(MAIN).mAppsList;
|
||||
}
|
||||
|
||||
public FloatingHeaderView getFloatingHeaderView() {
|
||||
return mHeader;
|
||||
}
|
||||
@@ -1314,6 +1393,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
: mViewPager == null ? AdapterHolder.MAIN : mViewPager.getNextPage();
|
||||
}
|
||||
|
||||
public PrivateProfileManager getPrivateProfileManager() {
|
||||
return mPrivateProfileManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an update listener to animator that adds springs to the animation.
|
||||
*/
|
||||
@@ -1353,12 +1436,26 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
invalidateHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@link Animator.AnimatorListener} on {@link mAllAppsTransitionController}
|
||||
* to observe
|
||||
* animation of backing out of all apps search view to all apps view.
|
||||
*/
|
||||
public void setAllAppsSearchBackAnimatorListener(Animator.AnimatorListener listener) {
|
||||
Preconditions.assertNotNull(mAllAppsTransitionController);
|
||||
if (mAllAppsTransitionController == null) {
|
||||
return;
|
||||
}
|
||||
mAllAppsTransitionController.setAllAppsSearchBackAnimationListener(listener);
|
||||
}
|
||||
|
||||
public void setScrimView(ScrimView scrimView) {
|
||||
mScrimView = scrimView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOnScrimWithScale(Canvas canvas, float scale) {
|
||||
public void drawOnScrimWithScaleAndBottomOffset(
|
||||
Canvas canvas, float scale, @Px int bottomOffsetPx) {
|
||||
final View panel = mBottomSheetBackground;
|
||||
final boolean hasBottomSheet = panel.getVisibility() == VISIBLE;
|
||||
final float translationY = ((View) panel.getParent()).getTranslationY();
|
||||
@@ -1370,6 +1467,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
final float topWithScale = topNoScale + verticalScaleOffset;
|
||||
final float leftWithScale = panel.getLeft() + horizontalScaleOffset;
|
||||
final float rightWithScale = panel.getRight() - horizontalScaleOffset;
|
||||
final float bottomWithOffset = panel.getBottom() + bottomOffsetPx;
|
||||
// Draw full background panel for tablets.
|
||||
if (hasBottomSheet) {
|
||||
mHeaderPaint.setColor(mBottomSheetBackgroundColor);
|
||||
@@ -1379,7 +1477,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
leftWithScale,
|
||||
topWithScale,
|
||||
rightWithScale,
|
||||
panel.getBottom());
|
||||
bottomWithOffset);
|
||||
mTmpPath.reset();
|
||||
mTmpPath.addRoundRect(mTmpRectF, mBottomSheetCornerRadii, Direction.CW);
|
||||
canvas.drawPath(mTmpPath, mHeaderPaint);
|
||||
@@ -1420,7 +1518,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
// If tab exist (such as work profile), extend header with tab height
|
||||
final int tabsHeight = headerView.getPeripheralProtectionHeight();
|
||||
final int tabsHeight = headerView.getPeripheralProtectionHeight(/* expectedHeight */ false);
|
||||
if (mTabsProtectionAlpha > 0 && tabsHeight != 0) {
|
||||
if (DEBUG_HEADER_PROTECTION) {
|
||||
mHeaderPaint.setColor(Color.BLUE);
|
||||
@@ -1449,6 +1547,19 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The height of the header protection as if the user scrolled down the app
|
||||
* list.
|
||||
*/
|
||||
float getHeaderProtectionHeight() {
|
||||
float headerBottom = getHeaderBottom() - getTranslationY();
|
||||
if (mUsingTabs) {
|
||||
return headerBottom + mHeader.getPeripheralProtectionHeight(/* expectedHeight */ true);
|
||||
} else {
|
||||
return headerBottom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* redraws header protection
|
||||
*/
|
||||
@@ -1470,6 +1581,10 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return bottom + mHeader.getTop();
|
||||
}
|
||||
|
||||
boolean isUsingTabs() {
|
||||
return mUsingTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view that denotes the visible part of all apps container view.
|
||||
*/
|
||||
@@ -1499,6 +1614,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
final AlphabeticalAppsList<T> mAppsList;
|
||||
final Rect mPadding = new Rect();
|
||||
AllAppsRecyclerView mRecyclerView;
|
||||
private OnFocusChangeListener mOnFocusChangeListener;
|
||||
|
||||
AdapterHolder(int type, AlphabeticalAppsList<T> appsList) {
|
||||
mType = type;
|
||||
@@ -1521,9 +1637,15 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
// RecyclerView.
|
||||
mRecyclerView.setItemAnimator(null);
|
||||
onInitializeRecyclerView(mRecyclerView);
|
||||
FocusedItemDecorator focusedItemDecorator = new FocusedItemDecorator(mRecyclerView);
|
||||
// Use ViewGroupFocusHelper for SearchRecyclerView to draw focus outline for the
|
||||
// buttons in the view (e.g. query builder button and setting button)
|
||||
FocusedItemDecorator focusedItemDecorator = isSearch() ? new FocusedItemDecorator(
|
||||
new ViewGroupFocusHelper(mRecyclerView))
|
||||
: new FocusedItemDecorator(
|
||||
mRecyclerView);
|
||||
mRecyclerView.addItemDecoration(focusedItemDecorator);
|
||||
mAdapter.setIconFocusListener(focusedItemDecorator.getFocusListener());
|
||||
mOnFocusChangeListener = focusedItemDecorator.getFocusListener();
|
||||
mAdapter.setIconFocusListener(mOnFocusChangeListener);
|
||||
applyPadding();
|
||||
}
|
||||
|
||||
@@ -1532,6 +1654,14 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
int bottomOffset = 0;
|
||||
if (isWork() && mWorkManager.getWorkModeSwitch() != null) {
|
||||
bottomOffset = mInsets.bottom + mWorkManager.getWorkModeSwitch().getHeight();
|
||||
} else if (isMain() && mPrivateProfileManager != null) {
|
||||
Optional<AdapterItem> privateSpaceHeaderItem = mAppsList.getAdapterItems()
|
||||
.stream()
|
||||
.filter(item -> item.viewType == VIEW_TYPE_PRIVATE_SPACE_HEADER)
|
||||
.findFirst();
|
||||
if (privateSpaceHeaderItem.isPresent()) {
|
||||
bottomOffset = mPrivateSpaceBottomExtraSpace;
|
||||
}
|
||||
}
|
||||
if (isSearchBarFloating()) {
|
||||
bottomOffset += mSearchContainer.getHeight();
|
||||
@@ -1548,5 +1678,9 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
private boolean isSearch() {
|
||||
return mType == SEARCH;
|
||||
}
|
||||
|
||||
private boolean isMain() {
|
||||
return mType == MAIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user