Merge "[Status Bar Refactor] Move some PanelView setters + getters into PanelViewController and out of PanelBar." into sc-v2-dev

This commit is contained in:
Caitlin Cassidy
2021-09-30 17:26:45 +00:00
committed by Android (Google) Code Review
6 changed files with 90 additions and 81 deletions

View File

@@ -334,6 +334,7 @@ public class NotificationPanelViewController extends PanelViewController {
private boolean mKeyguardUserSwitcherEnabled; private boolean mKeyguardUserSwitcherEnabled;
private boolean mDozing; private boolean mDozing;
private boolean mDozingOnDown; private boolean mDozingOnDown;
private boolean mBouncerShowing;
private int mBarState; private int mBarState;
private float mInitialHeightOnTouch; private float mInitialHeightOnTouch;
private float mInitialTouchX; private float mInitialTouchX;
@@ -404,7 +405,7 @@ public class NotificationPanelViewController extends PanelViewController {
private Runnable mHeadsUpExistenceChangedRunnable = () -> { private Runnable mHeadsUpExistenceChangedRunnable = () -> {
setHeadsUpAnimatingAway(false); setHeadsUpAnimatingAway(false);
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
}; };
// TODO (b/162832756): once migrated to the new pipeline, delete legacy group manager // TODO (b/162832756): once migrated to the new pipeline, delete legacy group manager
private NotificationGroupManagerLegacy mGroupManager; private NotificationGroupManagerLegacy mGroupManager;
@@ -3231,11 +3232,19 @@ public class NotificationPanelViewController extends PanelViewController {
public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
mHeadsUpAnimatingAway = headsUpAnimatingAway; mHeadsUpAnimatingAway = headsUpAnimatingAway;
mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway); mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway);
updateHeadsUpVisibility(); updateVisibility();
} }
private void updateHeadsUpVisibility() { /** Set whether the bouncer is showing. */
((PhoneStatusBarView) mBar).setHeadsUpVisible(mHeadsUpAnimatingAway || mHeadsUpPinnedMode); public void setBouncerShowing(boolean bouncerShowing) {
mBouncerShowing = bouncerShowing;
updateVisibility();
}
@Override
protected boolean shouldPanelBeVisible() {
boolean headsUpVisible = mHeadsUpAnimatingAway || mHeadsUpPinnedMode;
return headsUpVisible || isExpanded() || mBouncerShowing;
} }
@Override @Override
@@ -3645,6 +3654,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. * 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. * This is necessary to avoid shade expansion while/after the bouncer is dismissed.
@@ -4219,7 +4233,7 @@ public class NotificationPanelViewController extends PanelViewController {
} }
updateGestureExclusionRect(); updateGestureExclusionRect();
mHeadsUpPinnedMode = inPinnedMode; mHeadsUpPinnedMode = inPinnedMode;
updateHeadsUpVisibility(); updateVisibility();
mKeyguardStatusBarViewController.updateForHeadsUp(); mKeyguardStatusBarViewController.updateForHeadsUp();
} }

View File

@@ -33,8 +33,6 @@ public abstract class PanelBar extends FrameLayout {
private static final boolean SPEW = false; private static final boolean SPEW = false;
private static final String PANEL_BAR_SUPER_PARCELABLE = "panel_bar_super_parcelable"; private static final String PANEL_BAR_SUPER_PARCELABLE = "panel_bar_super_parcelable";
private static final String STATE = "state"; private static final String STATE = "state";
private boolean mBouncerShowing;
private boolean mExpanded;
protected float mPanelFraction; protected float mPanelFraction;
public static final void LOG(String fmt, Object... args) { public static final void LOG(String fmt, Object... args) {
@@ -99,33 +97,6 @@ public abstract class PanelBar extends FrameLayout {
pv.setBar(this); 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() { public boolean panelEnabled() {
return true; return true;
} }
@@ -183,9 +154,7 @@ public abstract class PanelBar extends FrameLayout {
boolean fullyClosed = true; boolean fullyClosed = true;
boolean fullyOpened = false; boolean fullyOpened = false;
if (SPEW) LOG("panelExpansionChanged: start state=%d, f=%.1f", mState, frac); if (SPEW) LOG("panelExpansionChanged: start state=%d, f=%.1f", mState, frac);
mExpanded = expanded;
mPanelFraction = frac; mPanelFraction = frac;
updateVisibility();
// adjust any other panels that may be partially visible // adjust any other panels that may be partially visible
if (expanded) { if (expanded) {
if (mState == STATE_CLOSED) { if (mState == STATE_CLOSED) {

View File

@@ -16,6 +16,9 @@
package com.android.systemui.statusbar.phone; 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.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE;
import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK; import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK;
import static com.android.systemui.classifier.Classifier.GENERIC; import static com.android.systemui.classifier.Classifier.GENERIC;
@@ -315,7 +318,7 @@ public abstract class PanelViewController {
} }
private void startOpening(MotionEvent event) { private void startOpening(MotionEvent event) {
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
maybeVibrateOnOpening(); maybeVibrateOnOpening();
//TODO: keyguard opens QS a different way; log that too? //TODO: keyguard opens QS a different way; log that too?
@@ -447,7 +450,7 @@ public abstract class PanelViewController {
protected void onTrackingStopped(boolean expand) { protected void onTrackingStopped(boolean expand) {
mTracking = false; mTracking = false;
mBar.onTrackingStopped(expand); mBar.onTrackingStopped(expand);
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
} }
protected void onTrackingStarted() { protected void onTrackingStarted() {
@@ -455,7 +458,7 @@ public abstract class PanelViewController {
mTracking = true; mTracking = true;
mBar.onTrackingStarted(); mBar.onTrackingStarted();
notifyExpandingStarted(); notifyExpandingStarted();
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
} }
/** /**
@@ -685,7 +688,7 @@ public abstract class PanelViewController {
} else { } else {
cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE); cancelJankMonitoring(CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
} }
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
} }
protected abstract boolean shouldUseDismissingAnimation(); protected abstract boolean shouldUseDismissingAnimation();
@@ -760,7 +763,7 @@ public abstract class PanelViewController {
mExpandedFraction = Math.min(1f, mExpandedFraction = Math.min(1f,
maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight); maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
onHeightUpdated(mExpandedHeight); onHeightUpdated(mExpandedHeight);
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
} }
/** /**
@@ -878,7 +881,7 @@ public abstract class PanelViewController {
if (mExpanding) { if (mExpanding) {
notifyExpandingFinished(); notifyExpandingFinished();
} }
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
// Wait for window manager to pickup the change, so we know the maximum height of the panel // Wait for window manager to pickup the change, so we know the maximum height of the panel
// then. // then.
@@ -916,7 +919,7 @@ public abstract class PanelViewController {
} }
if (mInstantExpanding) { if (mInstantExpanding) {
mInstantExpanding = false; mInstantExpanding = false;
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
} }
} }
@@ -1022,7 +1025,7 @@ public abstract class PanelViewController {
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
setAnimator(null); setAnimator(null);
onAnimationFinished.run(); onAnimationFinished.run();
notifyBarPanelExpansionChanged(); updatePanelExpansionAndVisibility();
} }
}); });
animator.start(); animator.start();
@@ -1059,19 +1062,39 @@ public abstract class PanelViewController {
return animator; 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) { if (mBar != null) {
mBar.panelExpansionChanged( mBar.panelExpansionChanged(mExpandedFraction, isExpanded());
mExpandedFraction,
mExpandedFraction > 0f || mInstantExpanding
|| isPanelVisibleBecauseOfHeadsUp() || mTracking
|| mHeightAnimator != null && !mIsSpringBackAnimation);
} }
updateVisibility();
for (int i = 0; i < mExpansionListeners.size(); i++) { for (int i = 0; i < mExpansionListeners.size(); i++) {
mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking); mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking);
} }
} }
public boolean isExpanded() {
return mExpandedFraction > 0f
|| mInstantExpanding
|| isPanelVisibleBecauseOfHeadsUp()
|| mTracking
|| mHeightAnimator != null
&& !mIsSpringBackAnimation;
}
public void addExpansionListener(PanelExpansionListener panelExpansionListener) { public void addExpansionListener(PanelExpansionListener panelExpansionListener) {
mExpansionListeners.add(panelExpansionListener); mExpansionListeners.add(panelExpansionListener);
} }

View File

@@ -402,16 +402,6 @@ public class PhoneStatusBarView extends PanelBar {
getPaddingBottom()); 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. */ /** An interface that will provide whether panel is enabled. */
interface PanelEnabledProvider { interface PanelEnabledProvider {
/** Returns true if the panel is enabled and false otherwise. */ /** Returns true if the panel is enabled and false otherwise. */

View File

@@ -61,6 +61,10 @@ class PhoneStatusBarViewController(
} }
} }
fun setImportantForAccessibility(mode: Int) {
mView.importantForAccessibility = mode
}
private class StatusBarViewsCenterProvider : UnfoldMoveFromCenterAnimator.ViewCenterProvider { private class StatusBarViewsCenterProvider : UnfoldMoveFromCenterAnimator.ViewCenterProvider {
override fun getViewCenter(view: View, outPoint: Point) = override fun getViewCenter(view: View, outPoint: Point) =
when (view.id) { when (view.id) {

View File

@@ -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_OPAQUE_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_SEMI_TRANSPARENT_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 androidx.lifecycle.Lifecycle.State.RESUMED;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME; import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
@@ -1188,22 +1190,13 @@ public class StatusBar extends SystemUI implements
); );
mBatteryMeterViewController.init(); mBatteryMeterViewController.init();
// CollapsedStatusBarFragment re-inflated PhoneStatusBarView and both of // Ensure we re-propagate panel expansion values to the panel controller and
// mStatusBarView.mExpanded and mStatusBarView.mBouncerShowing are false. // any listeners it may have, such as PanelBar. This will also ensure we
// PhoneStatusBarView's new instance will set to be gone in // re-display the notification panel if necessary (for example, if
// PanelBar.updateVisibility after calling mStatusBarView.setBouncerShowing // a heads-up notification was being displayed and should continue being
// that will trigger PanelBar.updateVisibility. If there is a heads up showing, // displayed).
// it needs to notify PhoneStatusBarView's new instance to update the correct mNotificationPanelViewController.updatePanelExpansionAndVisibility();
// status by calling mNotificationPanel.notifyBarPanelExpansionChanged(). setBouncerShowingForStatusBarComponents(mBouncerShowing);
if (mHeadsUpManager.hasPinnedHeadsUp()) {
mNotificationPanelViewController.notifyBarPanelExpansionChanged();
}
mStatusBarView.setBouncerShowing(mBouncerShowing);
if (oldStatusBarView != null) {
float fraction = oldStatusBarView.getExpansionFraction();
boolean expanded = oldStatusBarView.isExpanded();
mStatusBarView.panelExpansionChanged(fraction, expanded);
}
HeadsUpAppearanceController oldController = mHeadsUpAppearanceController; HeadsUpAppearanceController oldController = mHeadsUpAppearanceController;
if (mHeadsUpAppearanceController != null) { if (mHeadsUpAppearanceController != null) {
@@ -3531,7 +3524,7 @@ public class StatusBar extends SystemUI implements
mBouncerShowing = bouncerShowing; mBouncerShowing = bouncerShowing;
mKeyguardBypassController.setBouncerShowing(bouncerShowing); mKeyguardBypassController.setBouncerShowing(bouncerShowing);
mPulseExpansionHandler.setBouncerShowing(bouncerShowing); mPulseExpansionHandler.setBouncerShowing(bouncerShowing);
if (mStatusBarView != null) mStatusBarView.setBouncerShowing(bouncerShowing); setBouncerShowingForStatusBarComponents(bouncerShowing);
updateHideIconsForBouncer(true /* animate */); updateHideIconsForBouncer(true /* animate */);
mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */);
updateScrimController(); updateScrimController();
@@ -3540,6 +3533,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. * Collapses the notification shade if it is tracking or expanded.
*/ */
@@ -4212,10 +4222,9 @@ public class StatusBar extends SystemUI implements
} }
private void sendInitialExpansionAmount(ExpansionChangedListener expansionChangedListener) { private void sendInitialExpansionAmount(ExpansionChangedListener expansionChangedListener) {
if (mStatusBarView != null) { expansionChangedListener.onExpansionChanged(
expansionChangedListener.onExpansionChanged(mStatusBarView.getExpansionFraction(), mNotificationPanelViewController.getExpandedFraction(),
mStatusBarView.isExpanded()); mNotificationPanelViewController.isExpanded());
}
} }
public void removeExpansionChangedListener(@NonNull ExpansionChangedListener listener) { public void removeExpansionChangedListener(@NonNull ExpansionChangedListener listener) {