From a74a8595fbbc91b2288f932317f800006d7586b8 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 7 Apr 2022 16:19:26 +0100 Subject: [PATCH] Creaet separate pull back animation for AllApps - In tablet, only animate recyclerView on pullback to be consistent with widget bottom sheet, and avoid showing a gap below mAppsView Fix: 220345008 Test: manual on small and large screen Change-Id: I1f7d03b6bd16af7a91a51a0985ef163d9e365261 --- .../NavBarToHomeTouchController.java | 4 +-- .../allapps/AllAppsTransitionController.java | 32 ++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 86c42caa7b..4d3b05721c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -21,7 +21,7 @@ import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRES import static com.android.launcher3.LauncherAnimUtils.newCancelListener; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.NORMAL; -import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS; +import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PULL_BACK_PROGRESS; import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback; import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU; @@ -147,7 +147,7 @@ public class NavBarToHomeTouchController implements TouchController, AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_TASK_MENU); } else if (mStartState == ALL_APPS) { AllAppsTransitionController allAppsController = mLauncher.getAllAppsController(); - builder.setFloat(allAppsController, ALL_APPS_PROGRESS, + builder.setFloat(allAppsController, ALL_APPS_PULL_BACK_PROGRESS, -mPullbackDistance / allAppsController.getShiftRange(), PULLBACK_INTERPOLATOR); // Slightly fade out all apps content to further distinguish from scrolling. diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 14c67de6bc..8662d0067d 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -76,6 +76,21 @@ public class AllAppsTransitionController } }; + public static final FloatProperty ALL_APPS_PULL_BACK_PROGRESS = + new FloatProperty("allAppsPullBackProgress") { + + @Override + public Float get(AllAppsTransitionController controller) { + return controller.mPullBackProgress; + } + + @Override + public void setValue(AllAppsTransitionController controller, float progress) { + controller.setPullBackProgress(progress); + } + }; + + private ActivityAllAppsContainerView mAppsView; private final Launcher mLauncher; @@ -89,15 +104,17 @@ public class AllAppsTransitionController // When {@link mProgress} is 1, all apps container is pulled down. private float mShiftRange; // changes depending on the orientation private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent + private float mPullBackProgress; // [0, 1], mShiftRange * mPullBackProgress = shiftCurrent private ScrimView mScrimView; + private View mPullBackView; public AllAppsTransitionController(Launcher l) { mLauncher = l; DeviceProfile dp = mLauncher.getDeviceProfile(); setShiftRange(dp.allAppsShiftRange); mProgress = 1f; - + mPullBackProgress = 1f; mIsVerticalLayout = dp.isVerticalBarLayout(); mLauncher.addOnDeviceProfileChangeListener(this); } @@ -115,6 +132,8 @@ public class AllAppsTransitionController mLauncher.getHotseat().setTranslationY(0); mLauncher.getWorkspace().getPageIndicator().setTranslationY(0); } + + mPullBackView = dp.isTablet ? mAppsView.getRecyclerViewContainer() : mAppsView; } /** @@ -134,12 +153,19 @@ public class AllAppsTransitionController return mProgress; } + private void setPullBackProgress(float progress) { + mPullBackProgress = progress; + mPullBackView.setTranslationY(mPullBackProgress * mShiftRange); + } + /** * Sets the vertical transition progress to {@param state} and updates all the dependent UI * accordingly. */ @Override public void setState(LauncherState state) { + // Always reset pull back progress when switching states. + setPullBackProgress(0f); setProgress(state.getVerticalProgress(mLauncher)); setAlphas(state, new StateAnimationConfig(), NO_ANIM_PROPERTY_SETTER); onProgressAnimationEnd(); @@ -156,6 +182,8 @@ public class AllAppsTransitionController UiThreadHelper.hideKeyboardAsync(mLauncher, mLauncher.getAppsView().getWindowToken()); } + // Always reset pull back progress when switching states. + setPullBackProgress(0f); float targetProgress = toState.getVerticalProgress(mLauncher); if (Float.compare(mProgress, targetProgress) == 0) { setAlphas(toState, config, builder); @@ -217,6 +245,8 @@ public class AllAppsTransitionController | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); } mAppsView.setScrimView(scrimView); + mPullBackView = mLauncher.getDeviceProfile().isTablet + ? mAppsView.getRecyclerViewContainer() : mAppsView; } /**