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

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

Merge "Add LAUNCHER_ALL_APPS_SEARCH_BACK jank instrumentation" into main

parents 7d09d554 01cc2735
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -68,10 +68,13 @@ public class AllAppsState extends LauncherState {
    @Override
    public void onBackInvoked(Launcher launcher) {
        // In predictive back swipe, onBackInvoked() will be called after onBackStarted().
        // Because the 2nd InteractionJankMonitor.begin() will be ignore within timeout, it's safe
        // to call InteractionJankMonitorWrapper.begin here.
        InteractionJankMonitorWrapper.begin(launcher.getAppsView(),
                Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
        // In 3 button mode, onBackStarted() is not called but onBackInvoked() will be called.
        // Thus In onBackInvoked(), we should only begin instrumenting if we didn't call
        // onBackStarted() to start instrumenting CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK.
        if (!InteractionJankMonitorWrapper.isInstrumenting(Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK)) {
            InteractionJankMonitorWrapper.begin(
                    launcher.getAppsView(), Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
        }
        super.onBackInvoked(launcher);
    }

+5 −1
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ public class Launcher extends StatefulActivity<LauncherState>

            @Override
            public void onBackCancelled() {
                mStateManager.getState().onBackCancelled(Launcher.this);
                Launcher.this.onBackCancelled();
            }
        };
    }
@@ -2086,6 +2086,10 @@ public class Launcher extends StatefulActivity<LauncherState>
        mStateManager.getState().onBackInvoked(this);
    }

    protected void onBackCancelled() {
        mStateManager.getState().onBackCancelled(this);
    }

    protected void onScreenOnChanged(boolean isOn) {
        // Reset AllApps to its initial state only if we are not in the middle of
        // processing a multi-step drop
+13 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
@@ -1366,6 +1367,18 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
        invalidateHeader();
    }

    /**
     * Set {@link Animator.AnimatorListener} on {@link mAllAppsTransitionController} to observe
     * animation of backing out of all apps search view to all apps view.
     */
    public void setAllAppsSearchBackAnimatorListener(Animator.AnimatorListener listener) {
        Preconditions.assertNotNull(mAllAppsTransitionController);
        if (mAllAppsTransitionController == null) {
            return;
        }
        mAllAppsTransitionController.setAllAppsSearchBackAnimationListener(listener);
    }

    public void setScrimView(ScrimView scrimView) {
        mScrimView = scrimView;
    }
+21 −4
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.view.View;
import android.view.animation.Interpolator;

import androidx.annotation.FloatRange;
import androidx.annotation.Nullable;

import com.android.app.animation.Interpolators;
import com.android.launcher3.DeviceProfile;
@@ -167,6 +168,8 @@ public class AllAppsTransitionController
    private final AnimatedFloat mAllAppScale = new AnimatedFloat(this::onScaleProgressChanged);
    private final int mNavScrimFlag;

    @Nullable private Animator.AnimatorListener mAllAppsSearchBackAnimationListener;

    private boolean mIsVerticalLayout;

    // Animation in this class is controlled by a single variable {@link mProgress}.
@@ -312,11 +315,25 @@ public class AllAppsTransitionController
        }
    }

    /** Animate all apps view to 1f scale. */
    /** Set {@link Animator.AnimatorListener} for scaling all apps scale to 1 animation. */
    public void setAllAppsSearchBackAnimationListener(Animator.AnimatorListener listener) {
        mAllAppsSearchBackAnimationListener = listener;
    }

    /**
     * Animate all apps view to 1f scale. This is called when backing (exiting) from all apps
     * search view to all apps view.
     */
    public void animateAllAppsToNoScale() {
        mAllAppScale.animateToValue(1f)
                .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS)
                .start();
        if (mAllAppScale.isAnimating()) {
            return;
        }
        Animator animator = mAllAppScale.animateToValue(1f)
                .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS);
        if (mAllAppsSearchBackAnimationListener != null) {
            animator.addListener(mAllAppsSearchBackAnimationListener);
        }
        animator.start();
    }

    /**