Merge "[Status Bar Refactor] 3/3: Remove HeadsUpAppearanceController#destroy and migrate the controller to a ViewController model instead." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2ed5777693
@@ -39,6 +39,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll
|
||||
import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentScope;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
@@ -49,14 +50,15 @@ import javax.inject.Inject;
|
||||
* Controls the appearance of heads up notifications in the icon area and the header itself.
|
||||
*/
|
||||
@StatusBarFragmentScope
|
||||
public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
DarkIconDispatcher.DarkReceiver, NotificationWakeUpCoordinator.WakeUpListener {
|
||||
public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBarView>
|
||||
implements OnHeadsUpChangedListener,
|
||||
DarkIconDispatcher.DarkReceiver,
|
||||
NotificationWakeUpCoordinator.WakeUpListener {
|
||||
public static final int CONTENT_FADE_DURATION = 110;
|
||||
public static final int CONTENT_FADE_DELAY = 100;
|
||||
private final NotificationIconAreaController mNotificationIconAreaController;
|
||||
private final HeadsUpManagerPhone mHeadsUpManager;
|
||||
private final NotificationStackScrollLayoutController mStackScrollerController;
|
||||
private final HeadsUpStatusBarView mHeadsUpStatusBarView;
|
||||
private final View mCenteredIconView;
|
||||
private final View mClockView;
|
||||
private final View mOperatorNameView;
|
||||
@@ -125,13 +127,10 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
View clockView,
|
||||
View operatorNameView,
|
||||
View centeredIconView) {
|
||||
super(headsUpStatusBarView);
|
||||
mNotificationIconAreaController = notificationIconAreaController;
|
||||
mHeadsUpManager = headsUpManager;
|
||||
mHeadsUpManager.addListener(this);
|
||||
mHeadsUpStatusBarView = headsUpStatusBarView;
|
||||
mCenteredIconView = centeredIconView;
|
||||
headsUpStatusBarView.setOnDrawingRectChangedListener(
|
||||
() -> updateIsolatedIconLocation(true /* requireUpdate */));
|
||||
|
||||
// We may be mid-HUN-expansion when this controller is re-created (for example, if the user
|
||||
// has started pulling down the notification shade from the HUN and then the font size
|
||||
@@ -143,16 +142,12 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
|
||||
mStackScrollerController = stackScrollerController;
|
||||
mNotificationPanelViewController = notificationPanelViewController;
|
||||
notificationPanelViewController.addTrackingHeadsUpListener(mSetTrackingHeadsUp);
|
||||
notificationPanelViewController.setHeadsUpAppearanceController(this);
|
||||
mStackScrollerController.addOnExpandedHeightChangedListener(mSetExpandedHeight);
|
||||
mStackScrollerController.setHeadsUpAppearanceController(this);
|
||||
mClockView = clockView;
|
||||
mOperatorNameView = operatorNameView;
|
||||
mDarkIconDispatcher = Dependency.get(DarkIconDispatcher.class);
|
||||
mDarkIconDispatcher.addDarkReceiver(this);
|
||||
|
||||
mHeadsUpStatusBarView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
mView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
@@ -162,21 +157,32 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
// trigger scroller to notify the latest panel translation
|
||||
mStackScrollerController.requestLayout();
|
||||
}
|
||||
mHeadsUpStatusBarView.removeOnLayoutChangeListener(this);
|
||||
mView.removeOnLayoutChangeListener(this);
|
||||
}
|
||||
});
|
||||
mBypassController = bypassController;
|
||||
mStatusBarStateController = stateController;
|
||||
mWakeUpCoordinator = wakeUpCoordinator;
|
||||
wakeUpCoordinator.addListener(this);
|
||||
mCommandQueue = commandQueue;
|
||||
mKeyguardStateController = keyguardStateController;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mHeadsUpManager.addListener(this);
|
||||
mView.setOnDrawingRectChangedListener(
|
||||
() -> updateIsolatedIconLocation(true /* requireUpdate */));
|
||||
mWakeUpCoordinator.addListener(this);
|
||||
mNotificationPanelViewController.addTrackingHeadsUpListener(mSetTrackingHeadsUp);
|
||||
mNotificationPanelViewController.setHeadsUpAppearanceController(this);
|
||||
mStackScrollerController.addOnExpandedHeightChangedListener(mSetExpandedHeight);
|
||||
mDarkIconDispatcher.addDarkReceiver(this);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
@Override
|
||||
protected void onViewDetached() {
|
||||
mHeadsUpManager.removeListener(this);
|
||||
mHeadsUpStatusBarView.setOnDrawingRectChangedListener(null);
|
||||
mView.setOnDrawingRectChangedListener(null);
|
||||
mWakeUpCoordinator.removeListener(this);
|
||||
mNotificationPanelViewController.removeTrackingHeadsUpListener(mSetTrackingHeadsUp);
|
||||
mNotificationPanelViewController.setHeadsUpAppearanceController(null);
|
||||
@@ -186,7 +192,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
|
||||
private void updateIsolatedIconLocation(boolean requireStateUpdate) {
|
||||
mNotificationIconAreaController.setIsolatedIconLocation(
|
||||
mHeadsUpStatusBarView.getIconDrawingRect(), requireStateUpdate);
|
||||
mView.getIconDrawingRect(), requireStateUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,8 +206,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
if (shouldBeVisible()) {
|
||||
newEntry = mHeadsUpManager.getTopEntry();
|
||||
}
|
||||
NotificationEntry previousEntry = mHeadsUpStatusBarView.getShowingEntry();
|
||||
mHeadsUpStatusBarView.setEntry(newEntry);
|
||||
NotificationEntry previousEntry = mView.getShowingEntry();
|
||||
mView.setEntry(newEntry);
|
||||
if (newEntry != previousEntry) {
|
||||
boolean animateIsolation = false;
|
||||
if (newEntry == null) {
|
||||
@@ -226,8 +232,8 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
mShown = isShown;
|
||||
if (isShown) {
|
||||
updateParentClipping(false /* shouldClip */);
|
||||
mHeadsUpStatusBarView.setVisibility(View.VISIBLE);
|
||||
show(mHeadsUpStatusBarView);
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
show(mView);
|
||||
hide(mClockView, View.INVISIBLE);
|
||||
if (mCenteredIconView.getVisibility() != View.GONE) {
|
||||
hide(mCenteredIconView, View.INVISIBLE);
|
||||
@@ -243,21 +249,21 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
if (mOperatorNameView != null) {
|
||||
show(mOperatorNameView);
|
||||
}
|
||||
hide(mHeadsUpStatusBarView, View.GONE, () -> {
|
||||
hide(mView, View.GONE, () -> {
|
||||
updateParentClipping(true /* shouldClip */);
|
||||
});
|
||||
}
|
||||
// Show the status bar icons when the view gets shown / hidden
|
||||
if (mStatusBarStateController.getState() != StatusBarState.SHADE) {
|
||||
mCommandQueue.recomputeDisableFlags(
|
||||
mHeadsUpStatusBarView.getContext().getDisplayId(), false);
|
||||
mView.getContext().getDisplayId(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateParentClipping(boolean shouldClip) {
|
||||
ViewClippingUtil.setClippingDeactivated(
|
||||
mHeadsUpStatusBarView, !shouldClip, mParentClippingParams);
|
||||
mView, !shouldClip, mParentClippingParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -396,7 +402,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
mHeadsUpStatusBarView.onDarkChanged(area, darkIntensity, tint);
|
||||
mView.onDarkChanged(area, darkIntensity, tint);
|
||||
}
|
||||
|
||||
public void onStateChanged() {
|
||||
|
||||
@@ -664,7 +664,6 @@ public class StatusBar extends SystemUI implements
|
||||
private boolean mNoAnimationOnNextBarModeChange;
|
||||
private final SysuiStatusBarStateController mStatusBarStateController;
|
||||
|
||||
private HeadsUpAppearanceController mHeadsUpAppearanceController;
|
||||
private final ActivityLaunchAnimator mActivityLaunchAnimator;
|
||||
private NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider;
|
||||
protected StatusBarNotificationPresenter mPresenter;
|
||||
@@ -1164,17 +1163,6 @@ public class StatusBar extends SystemUI implements
|
||||
mNotificationPanelViewController.updatePanelExpansionAndVisibility();
|
||||
setBouncerShowingForStatusBarComponents(mBouncerShowing);
|
||||
|
||||
if (mHeadsUpAppearanceController != null) {
|
||||
// This view is being recreated, let's destroy the old one
|
||||
// TODO(b/205609837): Automatically destroy the old controller so that this
|
||||
// class doesn't need to hold a reference to the old one.
|
||||
mHeadsUpAppearanceController.destroy();
|
||||
}
|
||||
// TODO (b/136993073) Separate notification shade and status bar
|
||||
// TODO(b/205609837): Migrate this to StatusBarFragmentComponent.
|
||||
mHeadsUpAppearanceController =
|
||||
statusBarFragmentComponent.getHeadsUpAppearanceController();
|
||||
|
||||
mLightsOutNotifController.setLightsOutNotifView(
|
||||
mStatusBarView.findViewById(R.id.notification_lights_out));
|
||||
mNotificationShadeWindowViewController.setStatusBarView(mStatusBarView);
|
||||
|
||||
@@ -57,6 +57,7 @@ public interface StatusBarFragmentComponent {
|
||||
// No one accesses this controller, so we need to make sure we reference it here so it does
|
||||
// get initialized.
|
||||
getBatteryMeterViewController().init();
|
||||
getHeadsUpAppearanceController().init();
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -193,7 +193,9 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
||||
reset(mDarkIconDispatcher);
|
||||
reset(mPanelView);
|
||||
reset(mStackScrollerController);
|
||||
mHeadsUpAppearanceController.destroy();
|
||||
|
||||
mHeadsUpAppearanceController.onViewDetached();
|
||||
|
||||
verify(mHeadsUpManager).removeListener(any());
|
||||
verify(mDarkIconDispatcher).removeDarkReceiver((DarkIconDispatcher.DarkReceiver) any());
|
||||
verify(mPanelView).removeTrackingHeadsUpListener(any());
|
||||
|
||||
Reference in New Issue
Block a user