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

Commit c9d07b06 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Align widget picker bottom swipe transition with predictive back." into main

parents 247c6ac8 4d341404
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -207,10 +207,10 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
    }

    @Override
    protected void onScaleProgressChanged() {
        super.onScaleProgressChanged();
        mAppsView.setClipChildren(!mIsBackProgressing);
        mAppsView.getAppsRecyclerViewContainer().setClipChildren(!mIsBackProgressing);
    protected void onUserSwipeToDismissProgressChanged() {
        super.onUserSwipeToDismissProgressChanged();
        mAppsView.setClipChildren(!mIsDismissInProgress);
        mAppsView.getAppsRecyclerViewContainer().setClipChildren(!mIsDismissInProgress);
    }

    @Override
@@ -264,7 +264,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
        if (mAllAppsCallbacks.handleSearchBackInvoked()) {
            // We need to scale back taskbar all apps if we navigate back within search inside all
            // apps
            animateSlideInViewToNoScale();
            animateSwipeToDismissProgressToStart();
        } else {
            super.onBackInvoked();
        }
+24 −20
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
            };
    protected static final float TRANSLATION_SHIFT_CLOSED = 1f;
    protected static final float TRANSLATION_SHIFT_OPENED = 0f;
    private static final float VIEW_NO_SCALE = 1f;
    private static final int DEFAULT_DURATION = 300;

    protected final T mActivityContext;
@@ -129,9 +128,13 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
    protected @Nullable OnCloseListener mOnCloseBeginListener;
    protected List<OnCloseListener> mOnCloseListeners = new ArrayList<>();

    protected final AnimatedFloat mSlideInViewScale =
            new AnimatedFloat(this::onScaleProgressChanged, VIEW_NO_SCALE);
    protected boolean mIsBackProgressing;
    /**
     * How far through a "user initiated dismissal" the UI is. e.g. Predictive back, swipe to home,
     * 0 is regular state, 1 is fully dismissed.
     */
    protected final AnimatedFloat mSwipeToDismissProgress =
            new AnimatedFloat(this::onUserSwipeToDismissProgressChanged, 0f);
    protected boolean mIsDismissInProgress;
    private @Nullable Drawable mContentBackground;
    private @Nullable View mContentBackgroundParentView;

@@ -287,29 +290,30 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
        final float progress = backEvent.getProgress();
        float deceleratedProgress =
                Interpolators.PREDICTIVE_BACK_DECELERATED_EASE.getInterpolation(progress);
        mIsBackProgressing = progress > 0f;
        mSlideInViewScale.updateValue(PREDICTIVE_BACK_MIN_SCALE
                + (1 - PREDICTIVE_BACK_MIN_SCALE) * (1 - deceleratedProgress));
    }

    protected void onScaleProgressChanged() {
        float scaleProgress = mSlideInViewScale.value;
        SCALE_PROPERTY.set(this, scaleProgress);
        setClipChildren(!mIsBackProgressing);
        setClipToPadding(!mIsBackProgressing);
        mContent.setClipChildren(!mIsBackProgressing);
        mContent.setClipToPadding(!mIsBackProgressing);
        mSwipeToDismissProgress.updateValue(deceleratedProgress);
    }

    protected void onUserSwipeToDismissProgressChanged() {
        float progress = mSwipeToDismissProgress.value;
        mIsDismissInProgress = progress > 0f;

        float scale = PREDICTIVE_BACK_MIN_SCALE + (1 - PREDICTIVE_BACK_MIN_SCALE) * (1f - progress);
        SCALE_PROPERTY.set(this, scale);
        setClipChildren(!mIsDismissInProgress);
        setClipToPadding(!mIsDismissInProgress);
        mContent.setClipChildren(!mIsDismissInProgress);
        mContent.setClipToPadding(!mIsDismissInProgress);
        invalidate();
    }

    @Override
    public void onBackCancelled() {
        super.onBackCancelled();
        animateSlideInViewToNoScale();
        animateSwipeToDismissProgressToStart();
    }

    protected void animateSlideInViewToNoScale() {
        mSlideInViewScale.animateToValue(1f)
    protected void animateSwipeToDismissProgressToStart() {
        mSwipeToDismissProgress.animateToValue(0f)
                .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS)
                .start();
    }
@@ -340,7 +344,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
                mContentBackgroundParentView.getTop() + (int) mContent.getTranslationY(),
                mContentBackgroundParentView.getRight(),
                mContentBackgroundParentView.getBottom()
                        + (mIsBackProgressing ? getBottomOffsetPx() : 0));
                        + (mIsDismissInProgress ? getBottomOffsetPx() : 0));
        mContentBackground.draw(canvas);
    }

+3 −3
Original line number Diff line number Diff line
@@ -70,9 +70,9 @@ public class WidgetsEduView extends AbstractSlideInView<BaseActivity> implements
    }

    @Override
    protected void onScaleProgressChanged() {
        super.onScaleProgressChanged();
        setTranslationY(getMeasuredHeight() * (1 - mSlideInViewScale.value) / 2);
    protected void onUserSwipeToDismissProgressChanged() {
        super.onUserSwipeToDismissProgressChanged();
        setTranslationY(getMeasuredHeight() * (mSwipeToDismissProgress.value / 2));
    }

    private void show() {
+1 −1
Original line number Diff line number Diff line
@@ -280,6 +280,6 @@ public class WidgetsBottomSheet extends BaseWidgetSheet {
    @Override
    public void addHintCloseAnim(
            float distanceToMove, Interpolator interpolator, PendingAnimation target) {
        target.setInt(this, PADDING_BOTTOM, (int) (distanceToMove + mInsets.bottom), interpolator);
        target.addAnimatedFloat(mSwipeToDismissProgress, 0f, 1f, interpolator);
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.launcher3.widget.picker;

import static com.android.launcher3.Flags.enableCategorizedWidgetSuggestions;
import static com.android.launcher3.Flags.enableUnfoldedTwoPanePicker;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherPrefs.WIDGETS_EDUCATION_DIALOG_SEEN;
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_SEARCHED;
@@ -814,8 +813,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
    @Override
    public void addHintCloseAnim(
            float distanceToMove, Interpolator interpolator, PendingAnimation target) {
        target.setFloat(getRecyclerView(), VIEW_TRANSLATE_Y, -distanceToMove, interpolator);
        target.setViewAlpha(getRecyclerView(), 0.5f, interpolator);
        target.addAnimatedFloat(mSwipeToDismissProgress, 0f, 1f, interpolator);
    }

    @Override
@@ -911,7 +909,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet
    public void onBackInvoked() {
        if (mIsInSearchMode) {
            mSearchBar.reset();
            animateSlideInViewToNoScale();
            animateSwipeToDismissProgressToStart();
        } else {
            super.onBackInvoked();
        }
Loading