From 1f6a7b46be7cdce82e8928b2ed7f2125d842d521 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Tue, 22 Oct 2024 18:46:27 -0700 Subject: [PATCH] Adds all_apps_sheet_for_handheld flag. This flag causes All Apps to render on a background panel in handheld mode similarly to how it does on tablets. Demo: https://drive.google.com/file/d/11K8yueTb9Xr8oRJCM3TxcFH8V3rRFJrJ/view?usp=sharing&resourcekey=0-hMNEGzMQ5KC9D7may2Gb-g Bug: 374186088 Bug: 372618421 Test: Manual Flag: com.android.launcher3.all_apps_sheet_for_handheld Change-Id: Ie0b1e784d4330fd71f7f36f39e5dd85e8ee14933 --- aconfig/launcher.aconfig | 7 +++ .../uioverrides/states/AllAppsState.java | 12 ++--- src/com/android/launcher3/DeviceProfile.java | 7 ++- src/com/android/launcher3/LauncherState.java | 10 +++- .../allapps/ActivityAllAppsContainerView.java | 49 +++---------------- .../allapps/AllAppsTransitionController.java | 21 +++----- .../states/StateAnimationConfig.java | 4 +- .../touch/AllAppsSwipeController.java | 4 +- 8 files changed, 44 insertions(+), 70 deletions(-) diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig index 5101851d78..ee7e975de1 100644 --- a/aconfig/launcher.aconfig +++ b/aconfig/launcher.aconfig @@ -310,6 +310,13 @@ flag { bug: "346408388" } +flag { + name: "all_apps_sheet_for_handheld" + namespace: "launcher" + description: "All Apps will be presented on a bottom sheet in handheld mode" + bug: "374186088" +} + flag { name: "multiline_search_bar" namespace: "launcher" diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index 030a7acb48..d387794c20 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -118,7 +118,7 @@ public class AllAppsState extends LauncherState { @Override public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) { - if (launcher.getDeviceProfile().isTablet) { + if (launcher.getDeviceProfile().shouldShowAllAppsOnSheet()) { return getWorkspaceScaleAndTranslation(launcher); } else { ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW @@ -133,7 +133,7 @@ public class AllAppsState extends LauncherState { @Override protected float getDepthUnchecked(DEVICE_PROFILE_CONTEXT context) { - if (context.getDeviceProfile().isTablet) { + if (context.getDeviceProfile().shouldShowAllAppsOnSheet()) { return context.getDeviceProfile().bottomSheetDepth; } else { // The scrim fades in at approximately 50% of the swipe gesture. @@ -154,7 +154,7 @@ public class AllAppsState extends LauncherState { return new PageAlphaProvider(DECELERATE_2) { @Override public float getPageAlpha(int pageIndex) { - return launcher.getDeviceProfile().isTablet + return launcher.getDeviceProfile().shouldShowAllAppsOnSheet() ? superPageAlphaProvider.getPageAlpha(pageIndex) : 0; } @@ -164,8 +164,8 @@ public class AllAppsState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { int elements = ALL_APPS_CONTENT | FLOATING_SEARCH_BAR; - // Only add HOTSEAT_ICONS for tablets in ALL_APPS state. - if (launcher.getDeviceProfile().isTablet) { + // When All Apps is presented on a bottom sheet, HOTSEAT_ICONS are visible. + if (launcher.getDeviceProfile().shouldShowAllAppsOnSheet()) { elements |= HOTSEAT_ICONS; } return elements; @@ -202,7 +202,7 @@ public class AllAppsState extends LauncherState { @Override public int getWorkspaceScrimColor(Launcher launcher) { - return launcher.getDeviceProfile().isTablet + return launcher.getDeviceProfile().shouldShowAllAppsOnSheet() ? launcher.getResources().getColor(R.color.widgets_picker_scrim) : Themes.getAttrColor(launcher, R.attr.allAppsScrimColor); } diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 4305703fba..c25e8fb1a5 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -827,7 +827,7 @@ public class DeviceProfile { hotseatBorderSpace = cellLayoutBorderSpacePx.y; } - if (isTablet) { + if (shouldShowAllAppsOnSheet()) { allAppsPadding.top = mInsets.top; allAppsShiftRange = heightPx; } else { @@ -1516,6 +1516,11 @@ public class DeviceProfile { } } + /** Whether All Apps should be presented on a bottom sheet. */ + public boolean shouldShowAllAppsOnSheet() { + return isTablet || Flags.allAppsSheetForHandheld(); + } + private void setupAllAppsStyle(Context context) { TypedArray allAppsStyle = context.obtainStyledAttributes( inv.allAppsStyle != INVALID_RESOURCE_HANDLE ? inv.allAppsStyle diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 102189b530..7d5e481432 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -375,8 +375,14 @@ public abstract class LauncherState implements BaseState { } public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { - if ((this != NORMAL && this != HINT_STATE) - || !launcher.getDeviceProfile().shouldFadeAdjacentWorkspaceScreens()) { + DeviceProfile dp = launcher.getDeviceProfile(); + boolean shouldFadeAdjacentScreens = (this == NORMAL || this == HINT_STATE) + && dp.shouldFadeAdjacentWorkspaceScreens(); + // Avoid showing adjacent screens behind handheld All Apps sheet. + if (Flags.allAppsSheetForHandheld() && dp.isPhone && this == ALL_APPS) { + shouldFadeAdjacentScreens = true; + } + if (!shouldFadeAdjacentScreens) { return DEFAULT_ALPHA_PROVIDER; } final int centerPage = launcher.getWorkspace().getNextPage(); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 0dd2791f5b..4504b8e10b 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -47,7 +47,6 @@ import android.os.Parcelable; import android.os.Process; import android.os.UserManager; import android.util.AttributeSet; -import android.util.FloatProperty; import android.util.Log; import android.util.SparseArray; import android.view.KeyEvent; @@ -115,19 +114,6 @@ public class ActivityAllAppsContainerView ScrimView.ScrimDrawingController { - public static final FloatProperty> BOTTOM_SHEET_ALPHA = - new FloatProperty<>("bottomSheetAlpha") { - @Override - public Float get(ActivityAllAppsContainerView containerView) { - return containerView.mBottomSheetAlpha; - } - - @Override - public void setValue(ActivityAllAppsContainerView containerView, float v) { - containerView.setBottomSheetAlpha(v); - } - }; - 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"; @@ -191,8 +177,6 @@ public class ActivityAllAppsContainerView private ScrimView mScrimView; private int mHeaderColor; private int mBottomSheetBackgroundColor; - private float mBottomSheetAlpha = 1f; - private boolean mForceBottomSheetVisible; private int mTabsProtectionAlpha; @Nullable private AllAppsTransitionController mAllAppsTransitionController; @@ -351,20 +335,6 @@ public class ActivityAllAppsContainerView return mSearchUiManager; } - public View getBottomSheetBackground() { - return mBottomSheetBackground; - } - - /** - * Temporarily force the bottom sheet to be visible on non-tablets. - * - * @param force {@code true} means bottom sheet will be visible on phones until {@code reset()}. - */ - public void forceBottomSheetVisible(boolean force) { - mForceBottomSheetVisible = force; - updateBackgroundVisibility(mActivityContext.getDeviceProfile()); - } - public View getSearchView() { return mSearchContainer; } @@ -496,7 +466,7 @@ public class ActivityAllAppsContainerView if (mHeader != null && mHeader.getVisibility() == VISIBLE) { mHeader.reset(animate); } - forceBottomSheetVisible(false); + updateBackgroundVisibility(mActivityContext.getDeviceProfile()); // Reset the base recycler view after transitioning home. updateHeaderScroll(0); if (exitSearch) { @@ -1002,18 +972,13 @@ public class ActivityAllAppsContainerView } protected void updateBackgroundVisibility(DeviceProfile deviceProfile) { - boolean visible = deviceProfile.isTablet || mForceBottomSheetVisible; - mBottomSheetBackground.setVisibility(visible ? View.VISIBLE : View.GONE); - // Note: For tablets, the opaque background and header protection are added in drawOnScrim. + mBottomSheetBackground.setVisibility( + deviceProfile.shouldShowAllAppsOnSheet() ? View.VISIBLE : View.GONE); + // Note: The opaque sheet background and header protection are added in drawOnScrim. // For the taskbar entrypoint, the scrim is drawn by its abstract slide in view container, // so its header protection is derived from this scrim instead. } - private void setBottomSheetAlpha(float alpha) { - // Bottom sheet alpha is always 1 for tablets. - mBottomSheetAlpha = mActivityContext.getDeviceProfile().isTablet ? 1f : alpha; - } - @VisibleForTesting public void onAppsUpdated() { mHasWorkApps = Stream.of(mAllAppsStore.getApps()) @@ -1151,8 +1116,8 @@ public class ActivityAllAppsContainerView applyAdapterSideAndBottomPaddings(grid); MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams(); - // Ignore left/right insets on tablet because we are already centered in-screen. - if (grid.isTablet) { + // Ignore left/right insets on bottom sheet because we are already centered in-screen. + if (grid.shouldShowAllAppsOnSheet()) { mlp.leftMargin = mlp.rightMargin = 0; } else { mlp.leftMargin = insets.left; @@ -1398,7 +1363,7 @@ public class ActivityAllAppsContainerView // Draw full background panel for tablets. if (hasBottomSheet) { mHeaderPaint.setColor(mBottomSheetBackgroundColor); - mHeaderPaint.setAlpha((int) (255 * mBottomSheetAlpha)); + mHeaderPaint.setAlpha(255); mTmpRectF.set( leftWithScale, diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index c6852e015c..bd604eb08b 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -16,7 +16,6 @@ package com.android.launcher3.allapps; import static com.android.app.animation.Interpolators.DECELERATE_1_7; -import static com.android.app.animation.Interpolators.INSTANT; import static com.android.app.animation.Interpolators.LINEAR; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; @@ -28,7 +27,6 @@ import static com.android.launcher3.UtilitiesKt.CLIP_CHILDREN_FALSE_MODIFIER; import static com.android.launcher3.UtilitiesKt.modifyAttributesOnViewTree; import static com.android.launcher3.UtilitiesKt.restoreAttributesOnViewTree; import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER; -import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_BOTTOM_SHEET_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE; import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS; import static com.android.launcher3.util.SystemUiController.FLAG_DARK_NAV; @@ -106,7 +104,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { - if (controller.mIsTablet) { + if (controller.mShouldShowAllAppsOnSheet) { return controller.mAppsView.getActiveRecyclerView().getTranslationY(); } else { return controller.getAppsViewPullbackTranslationY().getValue(); @@ -115,7 +113,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float translation) { - if (controller.mIsTablet) { + if (controller.mShouldShowAllAppsOnSheet) { controller.mAppsView.getActiveRecyclerView().setTranslationY(translation); controller.getAppsViewPullbackTranslationY().setValue( ALL_APPS_PULL_BACK_TRANSLATION_DEFAULT); @@ -134,7 +132,7 @@ public class AllAppsTransitionController @Override public Float get(AllAppsTransitionController controller) { - if (controller.mIsTablet) { + if (controller.mShouldShowAllAppsOnSheet) { return controller.mAppsView.getActiveRecyclerView().getAlpha(); } else { return controller.getAppsViewPullbackAlpha().getValue(); @@ -143,7 +141,7 @@ public class AllAppsTransitionController @Override public void setValue(AllAppsTransitionController controller, float alpha) { - if (controller.mIsTablet) { + if (controller.mShouldShowAllAppsOnSheet) { controller.mAppsView.getActiveRecyclerView().setAlpha(alpha); controller.getAppsViewPullbackAlpha().setValue( ALL_APPS_PULL_BACK_ALPHA_DEFAULT); @@ -168,6 +166,7 @@ public class AllAppsTransitionController @Nullable private Animator.AnimatorListener mAllAppsSearchBackAnimationListener; private boolean mIsVerticalLayout; + private boolean mShouldShowAllAppsOnSheet; // Animation in this class is controlled by a single variable {@link mProgress}. // Visually, it represents top y coordinate of the all apps container if multiplied with @@ -183,8 +182,6 @@ public class AllAppsTransitionController private MultiValueAlpha mAppsViewAlpha; private MultiPropertyFactory mAppsViewTranslationY; - private boolean mIsTablet; - private boolean mHasScaleEffect; private final VibratorWrapper mVibratorWrapper; @@ -193,7 +190,7 @@ public class AllAppsTransitionController DeviceProfile dp = mLauncher.getDeviceProfile(); mProgress = 1f; mIsVerticalLayout = dp.isVerticalBarLayout(); - mIsTablet = dp.isTablet; + mShouldShowAllAppsOnSheet = dp.shouldShowAllAppsOnSheet(); mNavScrimFlag = Themes.getAttrBoolean(l, R.attr.isMainColorDark) ? FLAG_DARK_NAV : FLAG_LIGHT_NAV; @@ -217,7 +214,7 @@ public class AllAppsTransitionController mLauncher.getWorkspace().getPageIndicator().setTranslationY(0); } - mIsTablet = dp.isTablet; + mShouldShowAllAppsOnSheet = dp.shouldShowAllAppsOnSheet(); } /** @@ -395,10 +392,6 @@ public class AllAppsTransitionController setter.setFloat(getAppsViewPullbackAlpha(), MultiPropertyFactory.MULTI_PROPERTY_VALUE, hasAllAppsContent ? 1 : 0, allAppsFade); - setter.setFloat(mLauncher.getAppsView(), - ActivityAllAppsContainerView.BOTTOM_SHEET_ALPHA, hasAllAppsContent ? 1 : 0, - config.getInterpolator(ANIM_ALL_APPS_BOTTOM_SHEET_FADE, INSTANT)); - boolean shouldProtectHeader = !config.hasAnimationFlag(StateAnimationConfig.SKIP_SCRIM) && (ALL_APPS == state || mLauncher.getStateManager().getState() == ALL_APPS); mScrimView.setDrawingController(shouldProtectHeader ? mAppsView : null); diff --git a/src/com/android/launcher3/states/StateAnimationConfig.java b/src/com/android/launcher3/states/StateAnimationConfig.java index 0ca5afd1e8..2ffbbf400a 100644 --- a/src/com/android/launcher3/states/StateAnimationConfig.java +++ b/src/com/android/launcher3/states/StateAnimationConfig.java @@ -77,7 +77,6 @@ public class StateAnimationConfig { ANIM_WORKSPACE_PAGE_TRANSLATE_X, ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN, ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE, - ANIM_ALL_APPS_BOTTOM_SHEET_FADE, ANIM_ALL_APPS_KEYBOARD_FADE }) @Retention(RetentionPolicy.SOURCE) @@ -101,8 +100,7 @@ public class StateAnimationConfig { public static final int ANIM_WORKSPACE_PAGE_TRANSLATE_X = 15; public static final int ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN = 17; public static final int ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE = 18; - public static final int ANIM_ALL_APPS_BOTTOM_SHEET_FADE = 19; - public static final int ANIM_ALL_APPS_KEYBOARD_FADE = 20; + public static final int ANIM_ALL_APPS_KEYBOARD_FADE = 19; private static final int ANIM_TYPES_COUNT = 21; diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java index 9dcdf22852..107bcc1226 100644 --- a/src/com/android/launcher3/touch/AllAppsSwipeController.java +++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java @@ -198,7 +198,7 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { * Applies Animation config values for transition from all apps to home. */ public static void applyAllAppsToNormalConfig(Launcher launcher, StateAnimationConfig config) { - if (launcher.getDeviceProfile().isTablet) { + if (launcher.getDeviceProfile().shouldShowAllAppsOnSheet()) { config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.reverse(ALL_APPS_SCRIM_RESPONDER)); config.setInterpolator(ANIM_ALL_APPS_FADE, FINAL_FRAME); @@ -240,7 +240,7 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { */ public static void applyNormalToAllAppsAnimConfig( Launcher launcher, StateAnimationConfig config) { - if (launcher.getDeviceProfile().isTablet) { + if (launcher.getDeviceProfile().shouldShowAllAppsOnSheet()) { config.setInterpolator(ANIM_ALL_APPS_FADE, INSTANT); config.setInterpolator(ANIM_SCRIM_FADE, ALL_APPS_SCRIM_RESPONDER); if (!config.isUserControlled()) {