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

Commit 85a495f0 authored by Fengjiang Li's avatar Fengjiang Li
Browse files

[Predictive Back] If back swipe while widget picker is in search mode, we...

[Predictive Back] If back swipe while widget picker is in search mode, we should scale down the content view, rather than the bottom sheet

This will help indicate that we will be navigating within widget picker's bottom sheet.

Fix: 333524244
Test: manual - took a video
Flag: aconfig com.android.launcher3.enable_predictive_back_gesture TEAMFOOD
Change-Id: If29806a474d35c0fdd5789cb67fa62dfbb313313
parent 347cc489
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import static com.android.launcher3.LauncherAnimUtils.TABLET_BOTTOM_SHEET_SUCCES
import static com.android.launcher3.allapps.AllAppsTransitionController.REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS;
import static com.android.launcher3.util.ScrollableLayoutManager.PREDICTIVE_BACK_MIN_SCALE;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
@@ -135,6 +137,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
    protected final AnimatedFloat mSwipeToDismissProgress =
            new AnimatedFloat(this::onUserSwipeToDismissProgressChanged, 0f);
    protected boolean mIsDismissInProgress;
    protected View mViewToAnimateInSwipeToDismiss = this;
    private @Nullable Drawable mContentBackground;
    private @Nullable View mContentBackgroundParentView;

@@ -297,7 +300,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
        mIsDismissInProgress = progress > 0f;

        float scale = PREDICTIVE_BACK_MIN_SCALE + (1 - PREDICTIVE_BACK_MIN_SCALE) * (1f - progress);
        SCALE_PROPERTY.set(this, scale);
        SCALE_PROPERTY.set(mViewToAnimateInSwipeToDismiss, scale);
        setClipChildren(!mIsDismissInProgress);
        setClipToPadding(!mIsDismissInProgress);
        mContent.setClipChildren(!mIsDismissInProgress);
@@ -312,9 +315,32 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
    }

    protected void animateSwipeToDismissProgressToStart() {
        mSwipeToDismissProgress.animateToValue(0f)
                .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS)
                .start();
        ObjectAnimator objectAnimator = mSwipeToDismissProgress.animateToValue(0f)
                .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS);

        // If we are animating a different view, we should reset the animating view back to
        // AbstractSlideInView as it is the default view to animate.
        if (this != mViewToAnimateInSwipeToDismiss) {
            objectAnimator.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationCancel(Animator animator) {
                    mViewToAnimateInSwipeToDismiss = AbstractSlideInView.this;
                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    mViewToAnimateInSwipeToDismiss = AbstractSlideInView.this;
                }

                @Override
                public void onAnimationRepeat(Animator animator) {}

                @Override
                public void onAnimationStart(Animator animator) {}
            });
        }

        objectAnimator.start();
    }

    @Override
+12 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.view.animation.Interpolator;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.window.BackEvent;

import androidx.annotation.Nullable;
import androidx.annotation.Px;
@@ -899,6 +900,17 @@ public class WidgetsFullSheet extends BaseWidgetSheet
        return isFoldUnFold || useDifferentLayoutOnOrientationChange;
    }

    @Override
    public void onBackStarted(BackEvent backEvent) {
        super.onBackStarted(backEvent);
        // In widget search mode, we should scale down content inside widget bottom sheet, rather
        // than the whole bottom sheet, to indicate we will navigate back within the widget
        // bottom sheet.
        if (mIsInSearchMode) {
            mViewToAnimateInSwipeToDismiss = mContent;
        }
    }

    @Override
    public void onBackInvoked() {
        if (mIsInSearchMode) {