Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a74a8595 authored by Alex Chau's avatar Alex Chau
Browse files

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
parent d07ba1ca
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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.
+31 −1
Original line number Diff line number Diff line
@@ -76,6 +76,21 @@ public class AllAppsTransitionController
                }
            };

    public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PULL_BACK_PROGRESS =
            new FloatProperty<AllAppsTransitionController>("allAppsPullBackProgress") {

                @Override
                public Float get(AllAppsTransitionController controller) {
                    return controller.mPullBackProgress;
                }

                @Override
                public void setValue(AllAppsTransitionController controller, float progress) {
                    controller.setPullBackProgress(progress);
                }
            };


    private ActivityAllAppsContainerView<Launcher> 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;
    }

    /**