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

Commit 4f154e9c authored by Caitlin Cassidy's avatar Caitlin Cassidy
Browse files

[Status Bar Refactor] 1/3: Move status bar window's animation controller into

a method inside StatusBarWindowController, rather than being in
StatusBar.java.

Test: Test steps in ag/14294127 (specifically, that the updated
animation in b/183229367#comment11 still occurs)
Bug: 204583449

Change-Id: Ib4e8a18250db0cabed490fe286e8944262cc4f9c
parent fb12892a
Loading
Loading
Loading
Loading
+5 −19
Original line number Diff line number Diff line
@@ -2648,26 +2648,12 @@ public class StatusBar extends SystemUI implements
    private ActivityLaunchAnimator.Controller wrapAnimationController(
            ActivityLaunchAnimator.Controller animationController, boolean dismissShade) {
        View rootView = animationController.getLaunchContainer().getRootView();
        if (rootView == mStatusBarWindowView) {
            // We are animating a view in the status bar. We have to make sure that the status bar
            // window matches the full screen during the animation and that we are expanding the
            // view below the other status bar text.
            animationController.setLaunchContainer(
                    mStatusBarWindowController.getLaunchAnimationContainer());

            return new DelegateLaunchAnimatorController(animationController) {
                @Override
                public void onLaunchAnimationStart(boolean isExpandingFullyAbove) {
                    getDelegate().onLaunchAnimationStart(isExpandingFullyAbove);
                    mStatusBarWindowController.setLaunchAnimationRunning(true);
                }

                @Override
                public void onLaunchAnimationEnd(boolean isExpandingFullyAbove) {
                    getDelegate().onLaunchAnimationEnd(isExpandingFullyAbove);
                    mStatusBarWindowController.setLaunchAnimationRunning(false);
                }
            };
        Optional<ActivityLaunchAnimator.Controller> controllerFromStatusBar =
                mStatusBarWindowController.wrapAnimationControllerIfInStatusBar(
                        rootView, animationController);
        if (controllerFromStatusBar.isPresent()) {
            return controllerFromStatusBar.get();
        }

        if (dismissShade && rootView == mNotificationShadeWindowView) {
+43 −11
Original line number Diff line number Diff line
@@ -37,14 +37,19 @@ import android.util.Log;
import android.view.Gravity;
import android.view.IWindowManager;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.animation.DelegateLaunchAnimatorController;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;

import java.util.Optional;

import javax.inject.Inject;

/**
@@ -64,6 +69,8 @@ public class StatusBarWindowController {
    private final State mCurrentState = new State();

    private final ViewGroup mStatusBarView;
    // The container in which we should run launch animations started from the status bar and
    //   expanding into the opening window.
    private final ViewGroup mLaunchAnimationContainer;
    private WindowManager.LayoutParams mLp;
    private final WindowManager.LayoutParams mLpChanged;
@@ -126,6 +133,41 @@ public class StatusBarWindowController {
        calculateStatusBarLocationsForAllRotations();
    }

    /**
     * Provides an updated animation controller if we're animating a view in the status bar.
     *
     * This is needed because we have to make sure that the status bar window matches the full
     * screen during the animation and that we are expanding the view below the other status bar
     * text.
     *
     * @param rootView the root view of the animation
     * @param animationController the default animation controller to use
     * @return If the animation is on a view in the status bar, returns an Optional containing an
     *   updated animation controller that handles status-bar-related animation details. Returns an
     *   empty optional if the animation is *not* on a view in the status bar.
     */
    public Optional<ActivityLaunchAnimator.Controller> wrapAnimationControllerIfInStatusBar(
            View rootView, ActivityLaunchAnimator.Controller animationController) {
        if (rootView != mStatusBarView) {
            return Optional.empty();
        }

        animationController.setLaunchContainer(mLaunchAnimationContainer);
        return Optional.of(new DelegateLaunchAnimatorController(animationController) {
            @Override
            public void onLaunchAnimationStart(boolean isExpandingFullyAbove) {
                getDelegate().onLaunchAnimationStart(isExpandingFullyAbove);
                setLaunchAnimationRunning(true);
            }

            @Override
            public void onLaunchAnimationEnd(boolean isExpandingFullyAbove) {
                getDelegate().onLaunchAnimationEnd(isExpandingFullyAbove);
                setLaunchAnimationRunning(false);
            }
        });
    }

    private WindowManager.LayoutParams getBarLayoutParams(int rotation) {
        WindowManager.LayoutParams lp = getBarLayoutParamsForRotation(rotation);
        lp.paramsForRotation = new WindowManager.LayoutParams[4];
@@ -213,22 +255,12 @@ public class StatusBarWindowController {
        apply(mCurrentState);
    }

    /**
     * Return the container in which we should run launch animations started from the status bar and
     * expanding into the opening window.
     *
     * @see #setLaunchAnimationRunning
     */
    public ViewGroup getLaunchAnimationContainer() {
        return mLaunchAnimationContainer;
    }

    /**
     * Set whether a launch animation is currently running. If true, this will ensure that the
     * window matches its parent height so that the animation is not clipped by the normal status
     * bar height.
     */
    public void setLaunchAnimationRunning(boolean isLaunchAnimationRunning) {
    private void setLaunchAnimationRunning(boolean isLaunchAnimationRunning) {
        if (isLaunchAnimationRunning == mCurrentState.mIsLaunchAnimationRunning) {
            return;
        }