Merge "[Status Bar Refactor] 1/3: Move status bar window's animation controller into a method inside StatusBarWindowController, rather than being in StatusBar.java." into sc-v2-dev

This commit is contained in:
Caitlin Cassidy
2021-11-03 15:32:29 +00:00
committed by Android (Google) Code Review
2 changed files with 48 additions and 30 deletions

View File

@@ -2665,26 +2665,12 @@ public class StatusBar extends SystemUI implements
private ActivityLaunchAnimator.Controller wrapAnimationController( private ActivityLaunchAnimator.Controller wrapAnimationController(
ActivityLaunchAnimator.Controller animationController, boolean dismissShade) { ActivityLaunchAnimator.Controller animationController, boolean dismissShade) {
View rootView = animationController.getLaunchContainer().getRootView(); 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) { Optional<ActivityLaunchAnimator.Controller> controllerFromStatusBar =
@Override mStatusBarWindowController.wrapAnimationControllerIfInStatusBar(
public void onLaunchAnimationStart(boolean isExpandingFullyAbove) { rootView, animationController);
getDelegate().onLaunchAnimationStart(isExpandingFullyAbove); if (controllerFromStatusBar.isPresent()) {
mStatusBarWindowController.setLaunchAnimationRunning(true); return controllerFromStatusBar.get();
}
@Override
public void onLaunchAnimationEnd(boolean isExpandingFullyAbove) {
getDelegate().onLaunchAnimationEnd(isExpandingFullyAbove);
mStatusBarWindowController.setLaunchAnimationRunning(false);
}
};
} }
if (dismissShade && rootView == mNotificationShadeWindowView) { if (dismissShade && rootView == mNotificationShadeWindowView) {

View File

@@ -37,14 +37,19 @@ import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.IWindowManager; import android.view.IWindowManager;
import android.view.Surface; import android.view.Surface;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import com.android.internal.policy.SystemBarUtils; import com.android.internal.policy.SystemBarUtils;
import com.android.systemui.R; 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.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Main;
import java.util.Optional;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
@@ -64,6 +69,8 @@ public class StatusBarWindowController {
private final State mCurrentState = new State(); private final State mCurrentState = new State();
private final ViewGroup mStatusBarView; 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 final ViewGroup mLaunchAnimationContainer;
private WindowManager.LayoutParams mLp; private WindowManager.LayoutParams mLp;
private final WindowManager.LayoutParams mLpChanged; private final WindowManager.LayoutParams mLpChanged;
@@ -126,6 +133,41 @@ public class StatusBarWindowController {
calculateStatusBarLocationsForAllRotations(); 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) { private WindowManager.LayoutParams getBarLayoutParams(int rotation) {
WindowManager.LayoutParams lp = getBarLayoutParamsForRotation(rotation); WindowManager.LayoutParams lp = getBarLayoutParamsForRotation(rotation);
lp.paramsForRotation = new WindowManager.LayoutParams[4]; lp.paramsForRotation = new WindowManager.LayoutParams[4];
@@ -213,22 +255,12 @@ public class StatusBarWindowController {
apply(mCurrentState); 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 * 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 * window matches its parent height so that the animation is not clipped by the normal status
* bar height. * bar height.
*/ */
public void setLaunchAnimationRunning(boolean isLaunchAnimationRunning) { private void setLaunchAnimationRunning(boolean isLaunchAnimationRunning) {
if (isLaunchAnimationRunning == mCurrentState.mIsLaunchAnimationRunning) { if (isLaunchAnimationRunning == mCurrentState.mIsLaunchAnimationRunning) {
return; return;
} }