[Status Bar Refactor] Move some PanelView setters + getters into PanelViewController and out of PanelBar.
PanelBar and PanelView are unrelated (despite their names): PanelBar represents the status bar view, and PanelView represents the notification panel. So, methods regarding PanelView shouldn't live in PanelBar. This CL moves some of those methods out of PanelBar and into to PanelView's controller. Note: These methods are all intertwined, so they all need to be in 1 CL. Specific changes: - #shouldPanelBeVisible moved out of PanelBar into PanelViewController. - #setBouncerShowing moved out of PanelBar into StatusBar. That method adjusts visibility and accessibility for both PanelBar and PanelView, so it shouldn't live in PanelViewController (which is specific to PanelView only). StatusBar seemed like a semi-logical place for it. - #setHeadsUpVisible is no longer needed in PanelBar since it was only used to determine PanelView's visibility. Logic is moved to PanelViewController instead. - StatusBar uses PanelViewController to get expansionFraction and isExpanded values, instead of PanelBar. Test: 1) Modify display size while a heads up notification is showing and verify that the HUN remains visible and the status bar updates appropriately. 2) Rotate device while HUN is showing, same verification steps. (This tests no regression of b/80224819.) Test: Modify font size while the shade is open using `adb shell settings put system font_scale 0.8`. (This approximately tests no regression of b/110530608, since the repro steps in that bug are no longer applicable.) Test: atest SystemUITests Bug: 200063118 Change-Id: Idd9715992792b20002716332ccd7c15369183b5c
This commit is contained in:
@@ -334,6 +334,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
private boolean mKeyguardUserSwitcherEnabled;
|
||||
private boolean mDozing;
|
||||
private boolean mDozingOnDown;
|
||||
private boolean mBouncerShowing;
|
||||
private int mBarState;
|
||||
private float mInitialHeightOnTouch;
|
||||
private float mInitialTouchX;
|
||||
@@ -404,7 +405,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
|
||||
private Runnable mHeadsUpExistenceChangedRunnable = () -> {
|
||||
setHeadsUpAnimatingAway(false);
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
};
|
||||
// TODO (b/162832756): once migrated to the new pipeline, delete legacy group manager
|
||||
private NotificationGroupManagerLegacy mGroupManager;
|
||||
@@ -3228,11 +3229,19 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
|
||||
mHeadsUpAnimatingAway = headsUpAnimatingAway;
|
||||
mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway);
|
||||
updateHeadsUpVisibility();
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
private void updateHeadsUpVisibility() {
|
||||
((PhoneStatusBarView) mBar).setHeadsUpVisible(mHeadsUpAnimatingAway || mHeadsUpPinnedMode);
|
||||
/** Set whether the bouncer is showing. */
|
||||
public void setBouncerShowing(boolean bouncerShowing) {
|
||||
mBouncerShowing = bouncerShowing;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldPanelBeVisible() {
|
||||
boolean headsUpVisible = mHeadsUpAnimatingAway || mHeadsUpPinnedMode;
|
||||
return headsUpVisible || isExpanded() || mBouncerShowing;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3642,6 +3651,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
}
|
||||
}
|
||||
|
||||
/** */
|
||||
public void setImportantForAccessibility(int mode) {
|
||||
mView.setImportantForAccessibility(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not let the user drag the shade up and down for the current touch session.
|
||||
* This is necessary to avoid shade expansion while/after the bouncer is dismissed.
|
||||
@@ -4216,7 +4230,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
}
|
||||
updateGestureExclusionRect();
|
||||
mHeadsUpPinnedMode = inPinnedMode;
|
||||
updateHeadsUpVisibility();
|
||||
updateVisibility();
|
||||
mKeyguardStatusBarViewController.updateForHeadsUp();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ public abstract class PanelBar extends FrameLayout {
|
||||
private static final boolean SPEW = false;
|
||||
private static final String PANEL_BAR_SUPER_PARCELABLE = "panel_bar_super_parcelable";
|
||||
private static final String STATE = "state";
|
||||
private boolean mBouncerShowing;
|
||||
private boolean mExpanded;
|
||||
protected float mPanelFraction;
|
||||
|
||||
public static final void LOG(String fmt, Object... args) {
|
||||
@@ -99,33 +97,6 @@ public abstract class PanelBar extends FrameLayout {
|
||||
pv.setBar(this);
|
||||
}
|
||||
|
||||
public void setBouncerShowing(boolean showing) {
|
||||
mBouncerShowing = showing;
|
||||
int important = showing ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
||||
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
|
||||
|
||||
setImportantForAccessibility(important);
|
||||
updateVisibility();
|
||||
|
||||
if (mPanel != null) mPanel.getView().setImportantForAccessibility(important);
|
||||
}
|
||||
|
||||
public float getExpansionFraction() {
|
||||
return mPanelFraction;
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return mExpanded;
|
||||
}
|
||||
|
||||
protected void updateVisibility() {
|
||||
mPanel.getView().setVisibility(shouldPanelBeVisible() ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
|
||||
protected boolean shouldPanelBeVisible() {
|
||||
return mExpanded || mBouncerShowing;
|
||||
}
|
||||
|
||||
public boolean panelEnabled() {
|
||||
return true;
|
||||
}
|
||||
@@ -183,9 +154,7 @@ public abstract class PanelBar extends FrameLayout {
|
||||
boolean fullyClosed = true;
|
||||
boolean fullyOpened = false;
|
||||
if (SPEW) LOG("panelExpansionChanged: start state=%d, f=%.1f", mState, frac);
|
||||
mExpanded = expanded;
|
||||
mPanelFraction = frac;
|
||||
updateVisibility();
|
||||
// adjust any other panels that may be partially visible
|
||||
if (expanded) {
|
||||
if (mState == STATE_CLOSED) {
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE;
|
||||
import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
|
||||
import static com.android.systemui.classifier.Classifier.GENERIC;
|
||||
@@ -315,7 +318,7 @@ public abstract class PanelViewController {
|
||||
}
|
||||
|
||||
private void startOpening(MotionEvent event) {
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
maybeVibrateOnOpening();
|
||||
|
||||
//TODO: keyguard opens QS a different way; log that too?
|
||||
@@ -447,7 +450,7 @@ public abstract class PanelViewController {
|
||||
protected void onTrackingStopped(boolean expand) {
|
||||
mTracking = false;
|
||||
mBar.onTrackingStopped(expand);
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
}
|
||||
|
||||
protected void onTrackingStarted() {
|
||||
@@ -455,7 +458,7 @@ public abstract class PanelViewController {
|
||||
mTracking = true;
|
||||
mBar.onTrackingStarted();
|
||||
notifyExpandingStarted();
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -685,7 +688,7 @@ public abstract class PanelViewController {
|
||||
} else {
|
||||
cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
|
||||
}
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
}
|
||||
|
||||
protected abstract boolean shouldUseDismissingAnimation();
|
||||
@@ -760,7 +763,7 @@ public abstract class PanelViewController {
|
||||
mExpandedFraction = Math.min(1f,
|
||||
maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
|
||||
onHeightUpdated(mExpandedHeight);
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,7 +881,7 @@ public abstract class PanelViewController {
|
||||
if (mExpanding) {
|
||||
notifyExpandingFinished();
|
||||
}
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
|
||||
// Wait for window manager to pickup the change, so we know the maximum height of the panel
|
||||
// then.
|
||||
@@ -916,7 +919,7 @@ public abstract class PanelViewController {
|
||||
}
|
||||
if (mInstantExpanding) {
|
||||
mInstantExpanding = false;
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1022,7 +1025,7 @@ public abstract class PanelViewController {
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
setAnimator(null);
|
||||
onAnimationFinished.run();
|
||||
notifyBarPanelExpansionChanged();
|
||||
updatePanelExpansionAndVisibility();
|
||||
}
|
||||
});
|
||||
animator.start();
|
||||
@@ -1059,19 +1062,39 @@ public abstract class PanelViewController {
|
||||
return animator;
|
||||
}
|
||||
|
||||
protected void notifyBarPanelExpansionChanged() {
|
||||
/** Update the visibility of {@link PanelView} if necessary. */
|
||||
public void updateVisibility() {
|
||||
mView.setVisibility(shouldPanelBeVisible() ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
|
||||
/** Returns true if {@link PanelView} should be visible. */
|
||||
abstract boolean shouldPanelBeVisible();
|
||||
|
||||
/**
|
||||
* Updates the panel expansion and {@link PanelView} visibility if necessary.
|
||||
*
|
||||
* TODO(b/200063118): Could public calls to this method be replaced with calls to
|
||||
* {@link #updateVisibility()}? That would allow us to make this method private.
|
||||
*/
|
||||
public void updatePanelExpansionAndVisibility() {
|
||||
if (mBar != null) {
|
||||
mBar.panelExpansionChanged(
|
||||
mExpandedFraction,
|
||||
mExpandedFraction > 0f || mInstantExpanding
|
||||
|| isPanelVisibleBecauseOfHeadsUp() || mTracking
|
||||
|| mHeightAnimator != null && !mIsSpringBackAnimation);
|
||||
mBar.panelExpansionChanged(mExpandedFraction, isExpanded());
|
||||
}
|
||||
updateVisibility();
|
||||
for (int i = 0; i < mExpansionListeners.size(); i++) {
|
||||
mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return mExpandedFraction > 0f
|
||||
|| mInstantExpanding
|
||||
|| isPanelVisibleBecauseOfHeadsUp()
|
||||
|| mTracking
|
||||
|| mHeightAnimator != null
|
||||
&& !mIsSpringBackAnimation;
|
||||
}
|
||||
|
||||
public void addExpansionListener(PanelExpansionListener panelExpansionListener) {
|
||||
mExpansionListeners.add(panelExpansionListener);
|
||||
}
|
||||
|
||||
@@ -402,16 +402,6 @@ public class PhoneStatusBarView extends PanelBar {
|
||||
getPaddingBottom());
|
||||
}
|
||||
|
||||
public void setHeadsUpVisible(boolean headsUpVisible) {
|
||||
mHeadsUpVisible = headsUpVisible;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldPanelBeVisible() {
|
||||
return mHeadsUpVisible || super.shouldPanelBeVisible();
|
||||
}
|
||||
|
||||
/** An interface that will provide whether panel is enabled. */
|
||||
interface PanelEnabledProvider {
|
||||
/** Returns true if the panel is enabled and false otherwise. */
|
||||
|
||||
@@ -61,6 +61,10 @@ class PhoneStatusBarViewController(
|
||||
}
|
||||
}
|
||||
|
||||
fun setImportantForAccessibility(mode: Int) {
|
||||
mView.importantForAccessibility = mode
|
||||
}
|
||||
|
||||
private class StatusBarViewsCenterProvider : UnfoldMoveFromCenterAnimator.ViewCenterProvider {
|
||||
override fun getViewCenter(view: View, outPoint: Point) =
|
||||
when (view.id) {
|
||||
|
||||
@@ -26,6 +26,8 @@ import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_OPAQUE_STATUS_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS;
|
||||
|
||||
import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
|
||||
import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
|
||||
import static androidx.lifecycle.Lifecycle.State.RESUMED;
|
||||
|
||||
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
|
||||
@@ -1180,22 +1182,13 @@ public class StatusBar extends SystemUI implements
|
||||
);
|
||||
mBatteryMeterViewController.init();
|
||||
|
||||
// CollapsedStatusBarFragment re-inflated PhoneStatusBarView and both of
|
||||
// mStatusBarView.mExpanded and mStatusBarView.mBouncerShowing are false.
|
||||
// PhoneStatusBarView's new instance will set to be gone in
|
||||
// PanelBar.updateVisibility after calling mStatusBarView.setBouncerShowing
|
||||
// that will trigger PanelBar.updateVisibility. If there is a heads up showing,
|
||||
// it needs to notify PhoneStatusBarView's new instance to update the correct
|
||||
// status by calling mNotificationPanel.notifyBarPanelExpansionChanged().
|
||||
if (mHeadsUpManager.hasPinnedHeadsUp()) {
|
||||
mNotificationPanelViewController.notifyBarPanelExpansionChanged();
|
||||
}
|
||||
mStatusBarView.setBouncerShowing(mBouncerShowing);
|
||||
if (oldStatusBarView != null) {
|
||||
float fraction = oldStatusBarView.getExpansionFraction();
|
||||
boolean expanded = oldStatusBarView.isExpanded();
|
||||
mStatusBarView.panelExpansionChanged(fraction, expanded);
|
||||
}
|
||||
// Ensure we re-propagate panel expansion values to the panel controller and
|
||||
// any listeners it may have, such as PanelBar. This will also ensure we
|
||||
// re-display the notification panel if necessary (for example, if
|
||||
// a heads-up notification was being displayed and should continue being
|
||||
// displayed).
|
||||
mNotificationPanelViewController.updatePanelExpansionAndVisibility();
|
||||
setBouncerShowingForStatusBarComponents(mBouncerShowing);
|
||||
|
||||
HeadsUpAppearanceController oldController = mHeadsUpAppearanceController;
|
||||
if (mHeadsUpAppearanceController != null) {
|
||||
@@ -3522,7 +3515,7 @@ public class StatusBar extends SystemUI implements
|
||||
mBouncerShowing = bouncerShowing;
|
||||
mKeyguardBypassController.setBouncerShowing(bouncerShowing);
|
||||
mPulseExpansionHandler.setBouncerShowing(bouncerShowing);
|
||||
if (mStatusBarView != null) mStatusBarView.setBouncerShowing(bouncerShowing);
|
||||
setBouncerShowingForStatusBarComponents(bouncerShowing);
|
||||
updateHideIconsForBouncer(true /* animate */);
|
||||
mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */);
|
||||
updateScrimController();
|
||||
@@ -3531,6 +3524,23 @@ public class StatusBar extends SystemUI implements
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Propagate the bouncer state to status bar components.
|
||||
*
|
||||
* Separate from {@link #setBouncerShowing} because we sometimes re-create the status bar and
|
||||
* should update only the status bar components.
|
||||
*/
|
||||
private void setBouncerShowingForStatusBarComponents(boolean bouncerShowing) {
|
||||
int importance = bouncerShowing
|
||||
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
||||
: IMPORTANT_FOR_ACCESSIBILITY_AUTO;
|
||||
if (mPhoneStatusBarViewController != null) {
|
||||
mPhoneStatusBarViewController.setImportantForAccessibility(importance);
|
||||
}
|
||||
mNotificationPanelViewController.setImportantForAccessibility(importance);
|
||||
mNotificationPanelViewController.setBouncerShowing(bouncerShowing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapses the notification shade if it is tracking or expanded.
|
||||
*/
|
||||
@@ -4200,10 +4210,9 @@ public class StatusBar extends SystemUI implements
|
||||
}
|
||||
|
||||
private void sendInitialExpansionAmount(ExpansionChangedListener expansionChangedListener) {
|
||||
if (mStatusBarView != null) {
|
||||
expansionChangedListener.onExpansionChanged(mStatusBarView.getExpansionFraction(),
|
||||
mStatusBarView.isExpanded());
|
||||
}
|
||||
expansionChangedListener.onExpansionChanged(
|
||||
mNotificationPanelViewController.getExpandedFraction(),
|
||||
mNotificationPanelViewController.isExpanded());
|
||||
}
|
||||
|
||||
public void removeExpansionChangedListener(@NonNull ExpansionChangedListener listener) {
|
||||
|
||||
Reference in New Issue
Block a user