diff options
25 files changed, 812 insertions, 391 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java index fb2ddc15bab1..233667335b72 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java @@ -93,7 +93,7 @@ public class DebugDrawable extends Drawable { drawDebugInfo(canvas, (int) mLockIconViewController.getTop(), Color.GRAY, "mLockIconViewController.getTop()"); - if (mNotificationPanelViewController.getKeyguardShowing()) { + if (mNotificationPanelViewController.isKeyguardShowing()) { // Notifications have the space between those two lines. drawDebugInfo(canvas, mNotificationStackScrollLayoutController.getTop() diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index bf93c1020982..9a209486b27d 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -249,7 +249,7 @@ import javax.inject.Provider; import kotlinx.coroutines.CoroutineDispatcher; @CentralSurfacesComponent.CentralSurfacesScope -public final class NotificationPanelViewController implements Dumpable { +public final class NotificationPanelViewController implements ShadeSurface, Dumpable { public static final String TAG = NotificationPanelView.class.getSimpleName(); public static final float FLING_MAX_LENGTH_SECONDS = 0.6f; @@ -440,8 +440,6 @@ public final class NotificationPanelViewController implements Dumpable { new KeyguardClockPositionAlgorithm.Result(); private boolean mIsExpanding; - private String mHeaderDebugInfo; - /** * Indicates drag starting height when swiping down or up on heads-up notifications. * This usually serves as a threshold from when shade expansion should really start. Otherwise @@ -457,6 +455,10 @@ public final class NotificationPanelViewController implements Dumpable { private boolean mHeadsUpAnimatingAway; private final FalsingManager mFalsingManager; private final FalsingCollector mFalsingCollector; + private final ShadeHeadsUpTrackerImpl mShadeHeadsUpTracker = new ShadeHeadsUpTrackerImpl(); + private final ShadeFoldAnimator mShadeFoldAnimator = new ShadeFoldAnimatorImpl(); + private final ShadeNotificationPresenterImpl mShadeNotificationPresenter = + new ShadeNotificationPresenterImpl(); private boolean mShowIconsWhenExpanded; private int mIndicationBottomPadding; @@ -627,7 +629,7 @@ public final class NotificationPanelViewController implements Dumpable { () -> mKeyguardBottomArea.setVisibility(View.GONE); private final Runnable mHeadsUpExistenceChangedRunnable = () -> { setHeadsUpAnimatingAway(false); - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); }; private final Runnable mMaybeHideExpandedRunnable = () -> { if (getExpandedFraction() == 0.0f) { @@ -859,7 +861,7 @@ public final class NotificationPanelViewController implements Dumpable { mMainDispatcher = mainDispatcher; mAccessibilityManager = accessibilityManager; mView.setAccessibilityPaneTitle(determineAccessibilityPaneTitle()); - setPanelAlpha(255, false /* animate */); + setAlpha(255, false /* animate */); mCommandQueue = commandQueue; mDisplayId = displayId; mPulseExpansionHandler = pulseExpansionHandler; @@ -1043,7 +1045,8 @@ public final class NotificationPanelViewController implements Dumpable { mOnEmptySpaceClickListener); mQsController.initNotificationStackScrollLayoutController(); mShadeExpansionStateManager.addQsExpansionListener(this::onQsExpansionChanged); - addTrackingHeadsUpListener(mNotificationStackScrollLayoutController::setTrackingHeadsUp); + mShadeHeadsUpTracker.addTrackingHeadsUpListener( + mNotificationStackScrollLayoutController::setTrackingHeadsUp); setKeyguardBottomArea(mView.findViewById(R.id.keyguard_bottom_area)); initBottomArea(); @@ -1203,6 +1206,7 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public void updateResources() { final boolean newSplitShadeEnabled = LargeScreenUtils.shouldUseSplitNotificationShade(mResources); @@ -1383,7 +1387,7 @@ public final class NotificationPanelViewController implements Dumpable { if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request"); } - if (getKeyguardShowing() && !mKeyguardBypassController.getBypassEnabled()) { + if (isKeyguardShowing() && !mKeyguardBypassController.getBypassEnabled()) { mNotificationStackScrollLayoutController.setMaxDisplayedNotifications( mMaxAllowedKeyguardNotifications); mNotificationStackScrollLayoutController.setKeyguardBottomPaddingForDebug( @@ -1544,7 +1548,7 @@ public final class NotificationPanelViewController implements Dumpable { updateClock(); } - public KeyguardClockPositionAlgorithm.Result getClockPositionResult() { + KeyguardClockPositionAlgorithm.Result getClockPositionResult() { return mClockPositionResult; } @@ -1655,7 +1659,7 @@ public final class NotificationPanelViewController implements Dumpable { // overlap. return true; } - if (hasPulsingNotifications()) { + if (mNotificationListContainer.hasPulsingNotifications()) { // Pulsing notification appears on the right. Move clock left to avoid overlap. return false; } @@ -1785,27 +1789,28 @@ public final class NotificationPanelViewController implements Dumpable { } } - public void animateToFullShade(long delay) { + @Override + public void transitionToExpandedShade(long delay) { mNotificationStackScrollLayoutController.goToFullShade(delay); mView.requestLayout(); mAnimateNextPositionUpdate = true; } - /** Animate QS closing. */ - public void animateCloseQs(boolean animateAway) { + @Override + public void animateCollapseQs(boolean fullyCollapse) { if (mSplitShadeEnabled) { - collapsePanel(true, false, 1.0f); + collapse(true, false, 1.0f); } else { - mQsController.animateCloseQs(animateAway); + mQsController.animateCloseQs(fullyCollapse); } - } + @Override public void resetViews(boolean animate) { mGutsManager.closeAndSaveGuts(true /* leavebehind */, true /* force */, true /* controls */, -1 /* x */, -1 /* y */, true /* resetMenu */); if (animate && !isFullyCollapsed()) { - animateCloseQs(true); + animateCollapseQs(true); } else { closeQsIfPossible(); } @@ -1814,8 +1819,8 @@ public final class NotificationPanelViewController implements Dumpable { mNotificationStackScrollLayoutController.resetScrollPosition(); } - /** Collapses the panel. */ - public void collapsePanel(boolean animate, boolean delayed, float speedUpFactor) { + @Override + public void collapse(boolean animate, boolean delayed, float speedUpFactor) { boolean waiting = false; if (animate && !isFullyCollapsed()) { collapse(delayed, speedUpFactor); @@ -1833,8 +1838,9 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public void collapse(boolean delayed, float speedUpFactor) { - if (!canPanelBeCollapsed()) { + if (!canBeCollapsed()) { return; } @@ -1843,7 +1849,7 @@ public final class NotificationPanelViewController implements Dumpable { setShowShelfOnly(true); } debugLog("collapse: %s", this); - if (canPanelBeCollapsed()) { + if (canBeCollapsed()) { cancelHeightAnimator(); notifyExpandingStarted(); @@ -1874,11 +1880,13 @@ public final class NotificationPanelViewController implements Dumpable { endClosing(); } + @Override public void cancelAnimation() { mView.animate().cancel(); } - public void expandWithQs() { + @Override + public void expandToQs() { if (mQsController.isExpansionEnabled()) { mQsController.setExpandImmediate(true); setShowShelfOnly(true); @@ -1901,15 +1909,9 @@ public final class NotificationPanelViewController implements Dumpable { } } - /** - * Expand shade so that notifications are visible. - * Non-split shade: just expanding shade or collapsing QS when they're expanded. - * Split shade: only expanding shade, notifications are always visible - * - * Called when `adb shell cmd statusbar expand-notifications` is executed. - */ - public void expandShadeToNotifications() { - if (mSplitShadeEnabled && (isShadeFullyOpen() || isExpanding())) { + @Override + public void expandToNotifications() { + if (mSplitShadeEnabled && (isShadeFullyExpanded() || isExpanding())) { return; } if (mQsController.getExpanded()) { @@ -2046,7 +2048,7 @@ public final class NotificationPanelViewController implements Dumpable { } else { mQsController.cancelJankMonitoring(); } - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); mNotificationStackScrollLayoutController.setPanelFlinging(false); } @@ -2120,12 +2122,12 @@ public final class NotificationPanelViewController implements Dumpable { } /** Return whether a touch is near the gesture handle at the bottom of screen */ - public boolean isInGestureNavHomeHandleArea(float x, float y) { + boolean isInGestureNavHomeHandleArea(float x, float y) { return mIsGestureNavigation && y > mView.getHeight() - mNavigationBarBottomHeight; } - /** Input focus transfer is about to happen. */ - public void startWaitingForOpenPanelGesture() { + @Override + public void startWaitingForExpandGesture() { if (!isFullyCollapsed()) { return; } @@ -2134,21 +2136,8 @@ public final class NotificationPanelViewController implements Dumpable { updatePanelExpanded(); } - /** - * Called when this view is no longer waiting for input focus transfer. - * - * There are two scenarios behind this function call. First, input focus transfer - * has successfully happened and this view already received synthetic DOWN event. - * (mExpectingSynthesizedDown == false). Do nothing. - * - * Second, before input focus transfer finished, user may have lifted finger - * in previous window and this window never received synthetic DOWN event. - * (mExpectingSynthesizedDown == true). - * In this case, we use the velocity to trigger fling event. - * - * @param velocity unit is in px / millis - */ - public void stopWaitingForOpenPanelGesture(boolean cancel, final float velocity) { + @Override + public void stopWaitingForExpandGesture(boolean cancel, final float velocity) { if (mExpectingSynthesizedDown) { mExpectingSynthesizedDown = false; if (cancel) { @@ -2233,7 +2222,7 @@ public final class NotificationPanelViewController implements Dumpable { * as the shade ends up in its half-expanded state (with QQS above), it is back at 100% scale. * Without this, the shade would collapse, and stay squished. */ - public void adjustBackAnimationScale(float expansionFraction) { + void adjustBackAnimationScale(float expansionFraction) { if (expansionFraction > 0.0f) { // collapsing float animatedFraction = expansionFraction * mCurrentBackProgress; applyBackScaling(animatedFraction); @@ -2244,11 +2233,12 @@ public final class NotificationPanelViewController implements Dumpable { } //TODO(b/270981268): allow cancelling back animation mid-flight - /** Called when Back gesture has been committed (i.e. a back event has definitely occurred) */ + @Override public void onBackPressed() { closeQsIfPossible(); } - /** Sets back progress. */ + + @Override public void onBackProgressed(float progressFraction) { // TODO: non-linearly transform progress fraction into squish amount (ease-in, linear out) mCurrentBackProgress = progressFraction; @@ -2256,16 +2246,17 @@ public final class NotificationPanelViewController implements Dumpable { } /** Resets back progress. */ - public void resetBackTransformation() { + private void resetBackTransformation() { mCurrentBackProgress = 0.0f; applyBackScaling(0.0f); } - /** Scales multiple elements in tandem to achieve the illusion of the QS+Shade shrinking - * as a single visual element (used by the Predictive Back Gesture preview animation). - * fraction = 0 implies "no scaling", and 1 means "scale down to minimum size (90%)". + /** + * Scales multiple elements in tandem to achieve the illusion of the QS+Shade shrinking + * as a single visual element (used by the Predictive Back Gesture preview animation). + * fraction = 0 implies "no scaling", and 1 means "scale down to minimum size (90%)". */ - public void applyBackScaling(float fraction) { + private void applyBackScaling(float fraction) { if (mNotificationContainerParent == null) { return; } @@ -2273,15 +2264,6 @@ public final class NotificationPanelViewController implements Dumpable { mNotificationContainerParent.applyBackScaling(scale, mSplitShadeEnabled); mScrimController.applyBackScaling(scale); } - /** */ - public float getLockscreenShadeDragProgress() { - // mTransitioningToFullShadeProgress > 0 means we're doing regular lockscreen to shade - // transition. If that's not the case we should follow QS expansion fraction for when - // user is pulling from the same top to go directly to expanded QS - return mQsController.getTransitioningToFullShadeProgress() > 0 - ? mLockscreenShadeTransitionController.getQSDragProgress() - : mQsController.computeExpansionFraction(); - } String determineAccessibilityPaneTitle() { if (mQsController != null && mQsController.isCustomizing()) { @@ -2304,8 +2286,8 @@ public final class NotificationPanelViewController implements Dumpable { } /** Returns the topPadding of notifications when on keyguard not respecting QS expansion. */ - public int getKeyguardNotificationStaticPadding() { - if (!getKeyguardShowing()) { + int getKeyguardNotificationStaticPadding() { + if (!isKeyguardShowing()) { return 0; } if (!mKeyguardBypassController.getBypassEnabled()) { @@ -2322,15 +2304,15 @@ public final class NotificationPanelViewController implements Dumpable { } } - public boolean getKeyguardShowing() { + boolean isKeyguardShowing() { return mBarState == KEYGUARD; } - public float getKeyguardNotificationTopPadding() { + float getKeyguardNotificationTopPadding() { return mKeyguardNotificationTopPadding; } - public float getKeyguardNotificationBottomPadding() { + float getKeyguardNotificationBottomPadding() { return mKeyguardNotificationBottomPadding; } @@ -2338,17 +2320,14 @@ public final class NotificationPanelViewController implements Dumpable { mNotificationStackScrollLayoutController.updateTopPadding( mQsController.calculateNotificationsTopPadding(mIsExpanding, getKeyguardNotificationStaticPadding(), mExpandedFraction), animate); - if (getKeyguardShowing() + if (isKeyguardShowing() && mKeyguardBypassController.getBypassEnabled()) { // update the position of the header mQsController.updateExpansion(); } } - /** - * Set the alpha and translationY of the keyguard elements which only show on the lockscreen, - * but not in shade locked / shade. This is used when dragging down to the full shade. - */ + @Override public void setKeyguardTransitionProgress(float keyguardAlpha, int keyguardTranslationY) { mKeyguardOnlyContentAlpha = Interpolators.ALPHA_IN.getInterpolation(keyguardAlpha); mKeyguardOnlyTransitionTranslationY = keyguardTranslationY; @@ -2360,17 +2339,13 @@ public final class NotificationPanelViewController implements Dumpable { updateClock(); } - /** - * Sets the alpha value to be set on the keyguard status bar. - * - * @param alpha value between 0 and 1. -1 if the value is to be reset. - */ + @Override public void setKeyguardStatusBarAlpha(float alpha) { mKeyguardStatusBarViewController.setAlpha(alpha); } /** */ - public float getKeyguardOnlyContentAlpha() { + float getKeyguardOnlyContentAlpha() { return mKeyguardOnlyContentAlpha; } @@ -2451,7 +2426,7 @@ public final class NotificationPanelViewController implements Dumpable { float qsExpansionFraction; if (mSplitShadeEnabled) { qsExpansionFraction = 1; - } else if (getKeyguardShowing()) { + } else if (isKeyguardShowing()) { // On Keyguard, interpolate the QS expansion linearly to the panel expansion qsExpansionFraction = expandedHeight / (getMaxPanelHeight()); } else { @@ -2588,31 +2563,19 @@ public final class NotificationPanelViewController implements Dumpable { } setShowShelfOnly(false); mQsController.setTwoFingerExpandPossible(false); - updateTrackingHeadsUp(null); + mShadeHeadsUpTracker.updateTrackingHeadsUp(null); mExpandingFromHeadsUp = false; setPanelScrimMinFraction(0.0f); // Reset status bar alpha so alpha can be calculated upon updating view state. setKeyguardStatusBarAlpha(-1f); } - private void updateTrackingHeadsUp(@Nullable ExpandableNotificationRow pickedChild) { - mTrackedHeadsUpNotification = pickedChild; - for (int i = 0; i < mTrackingHeadsUpListeners.size(); i++) { - Consumer<ExpandableNotificationRow> listener = mTrackingHeadsUpListeners.get(i); - listener.accept(pickedChild); - } - } - - @Nullable - public ExpandableNotificationRow getTrackedHeadsUpNotification() { - return mTrackedHeadsUpNotification; - } - private void setListening(boolean listening) { mKeyguardStatusBarViewController.setBatteryListening(listening); mQsController.setListening(listening); } + @Override public void expand(boolean animate) { if (isFullyCollapsed() || isCollapsing()) { mInstantExpanding = true; @@ -2626,7 +2589,7 @@ public final class NotificationPanelViewController implements Dumpable { if (mExpanding) { notifyExpandingFinished(); } - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); // Wait for window manager to pickup the change, so we know the maximum height of the // panel then. this.mView.getViewTreeObserver().addOnGlobalLayoutListener( @@ -2666,7 +2629,8 @@ public final class NotificationPanelViewController implements Dumpable { mTouchSlopExceeded = isTouchSlopExceeded; } - public void setOverExpansion(float overExpansion) { + @VisibleForTesting + void setOverExpansion(float overExpansion) { if (overExpansion == mOverExpansion) { return; } @@ -2706,20 +2670,20 @@ public final class NotificationPanelViewController implements Dumpable { mTracking = true; mTrackingStartedListener.onTrackingStarted(); notifyExpandingStarted(); - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); mScrimController.onTrackingStarted(); if (mQsController.getFullyExpanded()) { mQsController.setExpandImmediate(true); setShowShelfOnly(true); } mNotificationStackScrollLayoutController.onPanelTrackingStarted(); - cancelPendingPanelCollapse(); + cancelPendingCollapse(); } private void onTrackingStopped(boolean expand) { mFalsingCollector.onTrackingStopped(); mTracking = false; - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); if (expand) { mNotificationStackScrollLayoutController.setOverScrollAmount(0.0f, true /* onTop */, true /* animate */); @@ -2805,6 +2769,7 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public void setIsLaunchAnimationRunning(boolean running) { boolean wasRunning = mIsLaunchAnimationRunning; mIsLaunchAnimationRunning = running; @@ -2829,6 +2794,7 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public void onScreenTurningOn() { mKeyguardStatusViewController.dozeTimeTick(); } @@ -2864,7 +2830,8 @@ public final class NotificationPanelViewController implements Dumpable { } } - public void setPanelAlpha(int alpha, boolean animate) { + @Override + public void setAlpha(int alpha, boolean animate) { if (mPanelAlpha != alpha) { mPanelAlpha = alpha; PropertyAnimator.setProperty(mView, mPanelAlphaAnimator, alpha, alpha == 255 @@ -2873,17 +2840,18 @@ public final class NotificationPanelViewController implements Dumpable { } } - public void setPanelAlphaEndAction(Runnable r) { + @Override + public void setAlphaChangeAnimationEndAction(Runnable r) { mPanelAlphaEndAction = r; } - public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { + private void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) { mHeadsUpAnimatingAway = headsUpAnimatingAway; mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway); updateVisibility(); } - /** Set whether the bouncer is showing. */ + @Override public void setBouncerShowing(boolean bouncerShowing) { mBouncerShowing = bouncerShowing; updateVisibility(); @@ -2894,7 +2862,7 @@ public final class NotificationPanelViewController implements Dumpable { return headsUpVisible || isExpanded() || mBouncerShowing; } - public void setHeadsUpManager(HeadsUpManagerPhone headsUpManager) { + private void setHeadsUpManager(HeadsUpManagerPhone headsUpManager) { mHeadsUpManager = headsUpManager; mHeadsUpManager.addListener(mOnHeadsUpChangedListener); mHeadsUpTouchHelper = new HeadsUpTouchHelper(headsUpManager, @@ -2938,6 +2906,7 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public int getBarState() { return mBarState; } @@ -2987,7 +2956,8 @@ public final class NotificationPanelViewController implements Dumpable { && mBarState == StatusBarState.SHADE; } - public boolean hideStatusBarIconsWhenExpanded() { + @Override + public boolean shouldHideStatusBarIconsWhenExpanded() { if (mIsLaunchAnimationRunning) { return mHideIconsDuringLaunchAnimation; } @@ -2998,6 +2968,7 @@ public final class NotificationPanelViewController implements Dumpable { return !mShowIconsWhenExpanded; } + @Override public void setTouchAndAnimationDisabled(boolean disabled) { mTouchDisabled = disabled; if (mTouchDisabled) { @@ -3010,12 +2981,7 @@ public final class NotificationPanelViewController implements Dumpable { mNotificationStackScrollLayoutController.setAnimationsEnabled(!disabled); } - /** - * Sets the dozing state. - * - * @param dozing {@code true} when dozing. - * @param animate if transition should be animated. - */ + @Override public void setDozing(boolean dozing, boolean animate) { if (dozing == mDozing) return; mView.setDozing(dozing); @@ -3040,6 +3006,7 @@ public final class NotificationPanelViewController implements Dumpable { updateKeyguardStatusViewAlignment(animate); } + @Override public void setPulsing(boolean pulsing) { mPulsing = pulsing; final boolean @@ -3058,6 +3025,7 @@ public final class NotificationPanelViewController implements Dumpable { updateKeyguardStatusViewAlignment(/* animate= */ true); } + @Override public void setAmbientIndicationTop(int ambientIndicationTop, boolean ambientTextVisible) { int ambientIndicationBottomPadding = 0; if (ambientTextVisible) { @@ -3070,6 +3038,7 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public void dozeTimeTick() { mLockIconViewController.dozeTimeTick(); mKeyguardStatusViewController.dozeTimeTick(); @@ -3078,15 +3047,17 @@ public final class NotificationPanelViewController implements Dumpable { } } - public void setStatusAccessibilityImportance(int mode) { + void setStatusAccessibilityImportance(int mode) { mKeyguardStatusViewController.setStatusAccessibilityImportance(mode); } //TODO(b/254875405): this should be removed. + @Override public KeyguardBottomAreaView getKeyguardBottomAreaView() { return mKeyguardBottomArea; } + @Override public void applyLaunchAnimationProgress(float linearProgress) { boolean hideIcons = LaunchAnimator.getProgress(ActivityLaunchAnimator.TIMINGS, linearProgress, ANIMATION_DELAY_ICON_FADE_IN, 100) == 0.0f; @@ -3098,20 +3069,43 @@ public final class NotificationPanelViewController implements Dumpable { } } - public void addTrackingHeadsUpListener(Consumer<ExpandableNotificationRow> listener) { - mTrackingHeadsUpListeners.add(listener); - } + private class ShadeHeadsUpTrackerImpl implements ShadeHeadsUpTracker { + @Override + public void addTrackingHeadsUpListener(Consumer<ExpandableNotificationRow> listener) { + mTrackingHeadsUpListeners.add(listener); + } - public void removeTrackingHeadsUpListener(Consumer<ExpandableNotificationRow> listener) { - mTrackingHeadsUpListeners.remove(listener); + @Override + public void removeTrackingHeadsUpListener(Consumer<ExpandableNotificationRow> listener) { + mTrackingHeadsUpListeners.remove(listener); + } + + @Override + public void setHeadsUpAppearanceController( + HeadsUpAppearanceController headsUpAppearanceController) { + mHeadsUpAppearanceController = headsUpAppearanceController; + } + + @Override + @Nullable public ExpandableNotificationRow getTrackedHeadsUpNotification() { + return mTrackedHeadsUpNotification; + } + + private void updateTrackingHeadsUp(@Nullable ExpandableNotificationRow pickedChild) { + mTrackedHeadsUpNotification = pickedChild; + for (int i = 0; i < mTrackingHeadsUpListeners.size(); i++) { + Consumer<ExpandableNotificationRow> listener = mTrackingHeadsUpListeners.get(i); + listener.accept(pickedChild); + } + } } - public void setHeadsUpAppearanceController( - HeadsUpAppearanceController headsUpAppearanceController) { - mHeadsUpAppearanceController = headsUpAppearanceController; + @Override + public ShadeHeadsUpTracker getShadeHeadsUpTracker() { + return mShadeHeadsUpTracker; } - /** Called before animating Keyguard dismissal, i.e. the animation dismissing the bouncer. */ + @Override public void startBouncerPreHideAnimation() { if (mKeyguardQsUserSwitchController != null) { mKeyguardQsUserSwitchController.setKeyguardQsUserSwitchVisibility( @@ -3129,74 +3123,90 @@ public final class NotificationPanelViewController implements Dumpable { } } - /** Updates the views to the initial state for the fold to AOD animation. */ - public void prepareFoldToAodAnimation() { - // Force show AOD UI even if we are not locked - showAodUi(); - - // Move the content of the AOD all the way to the left - // so we can animate to the initial position - final int translationAmount = mView.getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_start); - mView.setTranslationX(-translationAmount); - mView.setAlpha(0); + @Override + public ShadeFoldAnimator getShadeFoldAnimator() { + return mShadeFoldAnimator; } - /** - * Starts fold to AOD animation. - * - * @param startAction invoked when the animation starts. - * @param endAction invoked when the animation finishes, also if it was cancelled. - * @param cancelAction invoked when the animation is cancelled, before endAction. - */ - public void startFoldToAodAnimation(Runnable startAction, Runnable endAction, - Runnable cancelAction) { - final ViewPropertyAnimator viewAnimator = mView.animate(); - viewAnimator.cancel(); - viewAnimator - .translationX(0) - .alpha(1f) - .setDuration(ANIMATION_DURATION_FOLD_TO_AOD) - .setInterpolator(EMPHASIZED_DECELERATE) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationStart(Animator animation) { - startAction.run(); - } + private final class ShadeFoldAnimatorImpl implements ShadeFoldAnimator { + /** Updates the views to the initial state for the fold to AOD animation. */ + @Override + public void prepareFoldToAodAnimation() { + // Force show AOD UI even if we are not locked + showAodUi(); - @Override - public void onAnimationCancel(Animator animation) { - cancelAction.run(); - } + // Move the content of the AOD all the way to the left + // so we can animate to the initial position + final int translationAmount = mView.getResources().getDimensionPixelSize( + R.dimen.below_clock_padding_start); + mView.setTranslationX(-translationAmount); + mView.setAlpha(0); + } - @Override - public void onAnimationEnd(Animator animation) { - endAction.run(); + /** + * Starts fold to AOD animation. + * + * @param startAction invoked when the animation starts. + * @param endAction invoked when the animation finishes, also if it was cancelled. + * @param cancelAction invoked when the animation is cancelled, before endAction. + */ + @Override + public void startFoldToAodAnimation(Runnable startAction, Runnable endAction, + Runnable cancelAction) { + final ViewPropertyAnimator viewAnimator = mView.animate(); + viewAnimator.cancel(); + viewAnimator + .translationX(0) + .alpha(1f) + .setDuration(ANIMATION_DURATION_FOLD_TO_AOD) + .setInterpolator(EMPHASIZED_DECELERATE) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + startAction.run(); + } - viewAnimator.setListener(null); - viewAnimator.setUpdateListener(null); - } - }) - .setUpdateListener(anim -> - mKeyguardStatusViewController.animateFoldToAod(anim.getAnimatedFraction())) - .start(); - } + @Override + public void onAnimationCancel(Animator animation) { + cancelAction.run(); + } + + @Override + public void onAnimationEnd(Animator animation) { + endAction.run(); + + viewAnimator.setListener(null); + viewAnimator.setUpdateListener(null); + } + }) + .setUpdateListener(anim -> + mKeyguardStatusViewController.animateFoldToAod( + anim.getAnimatedFraction())) + .start(); + } - /** Cancels fold to AOD transition and resets view state. */ - public void cancelFoldToAodAnimation() { - cancelAnimation(); - resetAlpha(); - resetTranslation(); + /** Cancels fold to AOD transition and resets view state. */ + @Override + public void cancelFoldToAodAnimation() { + cancelAnimation(); + resetAlpha(); + resetTranslation(); + } + + /** Returns the NotificationPanelView. */ + @Override + public ViewGroup getView() { + // TODO(b/254878364): remove this method, or at least reduce references to it. + return mView; + } } + @Override 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. - */ + @Override public void blockExpansionForCurrentTouch() { mBlockingExpansionForCurrentTouch = mTracking; } @@ -3238,7 +3248,6 @@ public final class NotificationPanelViewController implements Dumpable { ipw.print("mDisplayRightInset="); ipw.println(mDisplayRightInset); ipw.print("mDisplayLeftInset="); ipw.println(mDisplayLeftInset); ipw.print("mIsExpanding="); ipw.println(mIsExpanding); - ipw.print("mHeaderDebugInfo="); ipw.println(mHeaderDebugInfo); ipw.print("mHeadsUpStartHeight="); ipw.println(mHeadsUpStartHeight); ipw.print("mListenForHeadsUp="); ipw.println(mListenForHeadsUp); ipw.print("mNavigationBarBottomHeight="); ipw.println(mNavigationBarBottomHeight); @@ -3327,37 +3336,41 @@ public final class NotificationPanelViewController implements Dumpable { ).printTableData(ipw); } + private final class ShadeNotificationPresenterImpl implements ShadeNotificationPresenter{ + @Override + public RemoteInputController.Delegate createRemoteInputDelegate() { + return mNotificationStackScrollLayoutController.createDelegate(); + } - public RemoteInputController.Delegate createRemoteInputDelegate() { - return mNotificationStackScrollLayoutController.createDelegate(); - } - - public boolean hasPulsingNotifications() { - return mNotificationListContainer.hasPulsingNotifications(); - } + @Override + public boolean hasPulsingNotifications() { + return mNotificationListContainer.hasPulsingNotifications(); + } - public ActivatableNotificationView getActivatedChild() { - return mNotificationStackScrollLayoutController.getActivatedChild(); - } + @Override + public ActivatableNotificationView getActivatedChild() { + return mNotificationStackScrollLayoutController.getActivatedChild(); + } - public void setActivatedChild(ActivatableNotificationView o) { - mNotificationStackScrollLayoutController.setActivatedChild(o); + @Override + public void setActivatedChild(ActivatableNotificationView o) { + mNotificationStackScrollLayoutController.setActivatedChild(o); + } } - public void runAfterAnimationFinished(Runnable r) { - mNotificationStackScrollLayoutController.runAfterAnimationFinished(r); + @Override + public ShadeNotificationPresenter getShadeNotificationPresenter() { + return mShadeNotificationPresenter; } - /** - * Initialize objects instead of injecting to avoid circular dependencies. - * - * @param hideExpandedRunnable a runnable to run when we need to hide the expanded panel. - */ + @Override public void initDependencies( CentralSurfaces centralSurfaces, GestureRecorder recorder, Runnable hideExpandedRunnable, - NotificationShelfController notificationShelfController) { + NotificationShelfController notificationShelfController, + HeadsUpManagerPhone headsUpManager) { + setHeadsUpManager(headsUpManager); // TODO(b/254859580): this can be injected. mCentralSurfaces = centralSurfaces; @@ -3369,14 +3382,17 @@ public final class NotificationPanelViewController implements Dumpable { updateMaxDisplayedNotifications(true); } + @Override public void resetTranslation() { mView.setTranslationX(0f); } + @Override public void resetAlpha() { mView.setAlpha(1f); } + @Override public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) { mView.animate().cancel(); return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration( @@ -3384,6 +3400,7 @@ public final class NotificationPanelViewController implements Dumpable { endAction); } + @Override public void resetViewGroupFade() { ViewGroupFadeHelper.reset(mView); } @@ -3396,14 +3413,11 @@ public final class NotificationPanelViewController implements Dumpable { mView.getViewTreeObserver().removeOnGlobalLayoutListener(listener); } - public void setHeaderDebugInfo(String text) { - if (DEBUG_DRAWABLE) mHeaderDebugInfo = text; - } - - public String getHeaderDebugInfo() { - return mHeaderDebugInfo; + String getHeaderDebugInfo() { + return "USER " + mHeadsUpManager.getUser(); } + @Override public void onThemeChanged() { mConfigurationListener.onThemeChanged(); } @@ -3413,22 +3427,17 @@ public final class NotificationPanelViewController implements Dumpable { return mTouchHandler; } + @Override public NotificationStackScrollLayoutController getNotificationStackScrollLayoutController() { return mNotificationStackScrollLayoutController; } - public void disable(int state1, int state2, boolean animated) { + @Override + public void disableHeader(int state1, int state2, boolean animated) { mShadeHeaderController.disable(state1, state2, animated); } - /** - * Close the keyguard user switcher if it is open and capable of closing. - * - * Has no effect if user switcher isn't supported, if the user switcher is already closed, or - * if the user switcher uses "simple" mode. The simple user switcher cannot be closed. - * - * @return true if the keyguard user switcher was open, and is now closed - */ + @Override public boolean closeUserSwitcherIfOpen() { if (mKeyguardUserSwitcherController != null) { return mKeyguardUserSwitcherController.closeSwitcherIfOpenAndNotSimple( @@ -3453,7 +3462,7 @@ public final class NotificationPanelViewController implements Dumpable { ); } - /** Updates notification panel-specific flags on {@link SysUiState}. */ + @Override public void updateSystemUiStateFlags() { if (SysUiState.DEBUG) { Log.d(TAG, "Updating panel sysui state flags: fullyExpanded=" @@ -3507,7 +3516,7 @@ public final class NotificationPanelViewController implements Dumpable { event.offsetLocation(-deltaX, -deltaY); } - /** If the latency tracker is enabled, begins tracking expand latency. */ + @Override public void startExpandLatencyTracking() { if (mLatencyTracker.isEnabled()) { mLatencyTracker.onActionStart(LatencyTracker.ACTION_EXPAND_PANEL); @@ -3516,7 +3525,7 @@ public final class NotificationPanelViewController implements Dumpable { } private void startOpening(MotionEvent event) { - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); //TODO: keyguard opens QS a different way; log that too? // Log the position of the swipe that opened the panel @@ -3561,7 +3570,7 @@ public final class NotificationPanelViewController implements Dumpable { } /** Called when a MotionEvent is about to trigger Shade expansion. */ - public void startExpandMotion(float newX, float newY, boolean startTracking, + private void startExpandMotion(float newX, float newY, boolean startTracking, float expandedHeight) { if (!mHandlingPointerUp && !mStatusBarStateController.isDozing()) { mQsController.beginJankMonitoring(isFullyCollapsed()); @@ -3793,7 +3802,7 @@ public final class NotificationPanelViewController implements Dumpable { mExpansionDragDownAmountPx = h; mAmbientState.setExpansionFraction(mExpandedFraction); onHeightUpdated(mExpandedHeight); - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); }); } @@ -3817,7 +3826,8 @@ public final class NotificationPanelViewController implements Dumpable { } /** Sets the expanded height relative to a number from 0 to 1. */ - public void setExpandedFraction(float frac) { + @VisibleForTesting + void setExpandedFraction(float frac) { final int maxDist = getMaxPanelTransitionDistance(); mShadeHeightLogger.logFunctionCall("setExpandedFraction"); setExpandedHeight(maxDist * frac); @@ -3831,27 +3841,13 @@ public final class NotificationPanelViewController implements Dumpable { return mExpandedFraction; } - /** - * This method should not be used anymore, you should probably use {@link #isShadeFullyOpen()} - * instead. It was overused as indicating if shade is open or we're on keyguard/AOD. - * Moving forward we should be explicit about the what state we're checking. - * @return if panel is covering the screen, which means we're in expanded shade or keyguard/AOD - * - * @deprecated depends on the state you check, use {@link #isShadeFullyOpen()}, - * {@link #isOnAod()}, {@link #isOnKeyguard()} instead. - */ - @Deprecated + @Override public boolean isFullyExpanded() { return mExpandedHeight >= getMaxPanelTransitionDistance(); } - /** - * Returns true if shade is fully opened, that is we're actually in the notification shade - * with QQS or QS. It's different from {@link #isFullyExpanded()} that it will not report - * shade as always expanded if we're on keyguard/AOD. It will return true only when user goes - * from keyguard to shade. - */ - public boolean isShadeFullyOpen() { + @Override + public boolean isShadeFullyExpanded() { if (mBarState == SHADE) { return isFullyExpanded(); } else if (mBarState == SHADE_LOCKED) { @@ -3862,10 +3858,12 @@ public final class NotificationPanelViewController implements Dumpable { } } + @Override public boolean isFullyCollapsed() { return mExpandedFraction <= 0.0f; } + @Override public boolean isCollapsing() { return mClosing || mIsLaunchAnimationRunning; } @@ -3874,13 +3872,13 @@ public final class NotificationPanelViewController implements Dumpable { return mTracking; } - /** Returns whether the shade can be collapsed. */ - public boolean canPanelBeCollapsed() { + @Override + public boolean canBeCollapsed() { return !isFullyCollapsed() && !mTracking && !mClosing; } /** Collapses the shade instantly without animation. */ - public void instantCollapse() { + void instantCollapse() { abortAnimations(); mShadeHeightLogger.logFunctionCall("instantCollapse"); setExpandedFraction(0f); @@ -3889,7 +3887,7 @@ public final class NotificationPanelViewController implements Dumpable { } if (mInstantExpanding) { mInstantExpanding = false; - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); } } @@ -3898,6 +3896,7 @@ public final class NotificationPanelViewController implements Dumpable { mView.removeCallbacks(mFlingCollapseRunnable); } + @Override public boolean isUnlockHintRunning() { return mHintAnimationRunning; } @@ -3956,7 +3955,7 @@ public final class NotificationPanelViewController implements Dumpable { } /** Returns whether a shade or QS expansion animation is running */ - public boolean isShadeOrQsHeightAnimationRunning() { + private boolean isShadeOrQsHeightAnimationRunning() { return mHeightAnimator != null && !mHintAnimationRunning && !mIsSpringBackAnimation; } @@ -3972,7 +3971,7 @@ public final class NotificationPanelViewController implements Dumpable { public void onAnimationEnd(Animator animation) { setAnimator(null); onAnimationFinished.run(); - updatePanelExpansionAndVisibility(); + updateExpansionAndVisibility(); } }); animator.start(); @@ -4015,19 +4014,16 @@ public final class NotificationPanelViewController implements Dumpable { mView.setVisibility(shouldPanelBeVisible() ? VISIBLE : INVISIBLE); } - /** - * Updates the panel expansion and {@link NotificationPanelView} 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() { + + @Override + public void updateExpansionAndVisibility() { mShadeExpansionStateManager.onPanelExpansionChanged( mExpandedFraction, isExpanded(), mTracking, mExpansionDragDownAmountPx); updateVisibility(); } + @Override public boolean isExpanded() { return mExpandedFraction > 0f || mInstantExpanding @@ -4049,45 +4045,41 @@ public final class NotificationPanelViewController implements Dumpable { return mClosing; } - /** Collapses the shade with an animation duration in milliseconds. */ + @Override public void collapseWithDuration(int animationDuration) { mFixedDuration = animationDuration; collapse(false /* delayed */, 1.0f /* speedUpFactor */); mFixedDuration = NO_FIXED_DURATION; } - /** Returns the NotificationPanelView. */ - public ViewGroup getView() { - // TODO(b/254878364): remove this method, or at least reduce references to it. - return mView; - } - /** */ - public boolean postToView(Runnable action) { + boolean postToView(Runnable action) { return mView.post(action); } /** Sends an external (e.g. Status Bar) intercept touch event to the Shade touch handler. */ - public boolean handleExternalInterceptTouch(MotionEvent event) { + boolean handleExternalInterceptTouch(MotionEvent event) { return mTouchHandler.onInterceptTouchEvent(event); } - /** Sends an external (e.g. Status Bar) touch event to the Shade touch handler. */ + @Override public boolean handleExternalTouch(MotionEvent event) { return mTouchHandler.onTouchEvent(event); } - /** */ - public void requestLayoutOnView() { + @Override + public void updateTouchableRegion() { + //A layout will ensure that onComputeInternalInsets will be called and after that we can + // resize the layout. Make sure that the window stays small for one frame until the + // touchableRegion is set. mView.requestLayout(); + mNotificationShadeWindowController.setForceWindowCollapsed(true); + postToView(() -> { + mNotificationShadeWindowController.setForceWindowCollapsed(false); + }); } - /** */ - public void resetViewAlphas() { - ViewGroupFadeHelper.reset(mView); - } - - /** */ + @Override public boolean isViewEnabled() { return mView.isEnabled(); } @@ -4115,13 +4107,13 @@ public final class NotificationPanelViewController implements Dumpable { * shade QS are always expanded */ private void closeQsIfPossible() { - boolean openOrOpening = isShadeFullyOpen() || isExpanding(); + boolean openOrOpening = isShadeFullyExpanded() || isExpanding(); if (!(mSplitShadeEnabled && openOrOpening)) { mQsController.closeQs(); } } - /** TODO: remove need for this delegate (b/254870148) */ + @Override public void setQsScrimEnabled(boolean qsScrimEnabled) { mQsController.setScrimEnabled(qsScrimEnabled); } @@ -4224,7 +4216,7 @@ public final class NotificationPanelViewController implements Dumpable { == firstRow))) { requestScrollerTopPaddingUpdate(false /* animate */); } - if (getKeyguardShowing()) { + if (isKeyguardShowing()) { updateMaxDisplayedNotifications(true); } updateExpandedHeightToMaxHeight(); @@ -4470,7 +4462,7 @@ public final class NotificationPanelViewController implements Dumpable { @Override public float getLockscreenShadeDragProgress() { - return NotificationPanelViewController.this.getLockscreenShadeDragProgress(); + return mQsController.getLockscreenShadeDragProgress(); } }; @@ -4480,6 +4472,7 @@ public final class NotificationPanelViewController implements Dumpable { * to the KEYGUARD state, which is a heavy transition that causes jank as 10+ files react to the * change. */ + @VisibleForTesting public void showAodUi() { setDozing(true /* dozing */, false /* animate */); mStatusBarStateController.setUpcomingState(KEYGUARD); @@ -4489,7 +4482,7 @@ public final class NotificationPanelViewController implements Dumpable { setExpandedFraction(1f); } - /** Sets the overstretch amount in raw pixels when dragging down. */ + @Override public void setOverStretchAmount(float amount) { float progress = amount / mView.getHeight(); float overStretch = Interpolators.getOvershootInterpolation(progress); @@ -4581,8 +4574,8 @@ public final class NotificationPanelViewController implements Dumpable { return insets; } - /** Removes any pending runnables that would collapse the panel. */ - public void cancelPendingPanelCollapse() { + @Override + public void cancelPendingCollapse() { mView.removeCallbacks(mMaybeHideExpandedRunnable); } @@ -4655,7 +4648,7 @@ public final class NotificationPanelViewController implements Dumpable { private void onStatusBarWindowStateChanged(@StatusBarManager.WindowVisibleState int state) { if (state != WINDOW_STATE_SHOWING && mStatusBarStateController.getState() == StatusBarState.SHADE) { - collapsePanel( + collapse( false /* animate */, false /* delayed */, 1.0f /* speedUpFactor */); @@ -4667,6 +4660,7 @@ public final class NotificationPanelViewController implements Dumpable { private long mLastTouchDownTime = -1L; /** @see ViewGroup#onInterceptTouchEvent(MotionEvent) */ + @Override public boolean onInterceptTouchEvent(MotionEvent event) { mShadeLog.logMotionEvent(event, "NPVC onInterceptTouchEvent"); if (mQsController.disallowTouches()) { @@ -4928,7 +4922,7 @@ public final class NotificationPanelViewController implements Dumpable { // On expanding, single mouse click expands the panel instead of dragging. if (isFullyCollapsed() && event.isFromSource(InputDevice.SOURCE_MOUSE)) { if (event.getAction() == MotionEvent.ACTION_UP) { - expand(true); + expand(true /* animate */); } return true; } @@ -5156,7 +5150,7 @@ public final class NotificationPanelViewController implements Dumpable { @Override public void setTrackedHeadsUp(ExpandableNotificationRow pickedChild) { if (pickedChild != null) { - updateTrackingHeadsUp(pickedChild); + mShadeHeadsUpTracker.updateTrackingHeadsUp(pickedChild); mExpandingFromHeadsUp = true; } // otherwise we update the state when the expansion is finished diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java index 07c8e52e7a6c..ed88763082c5 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java @@ -766,7 +766,7 @@ public class QuickSettingsController { /** TODO(b/269742565) Remove this logging */ private void checkCorrectSplitShadeState(float height) { if (mSplitShadeEnabled && height == 0 - && mPanelViewControllerLazy.get().isShadeFullyOpen()) { + && mPanelViewControllerLazy.get().isShadeFullyExpanded()) { Log.wtfStack(TAG, "qsExpansion set to 0 while split shade is expanding or open"); } } @@ -989,13 +989,22 @@ public class QuickSettingsController { // TODO (b/265193930): remove dependency on NPVC float shadeExpandedFraction = mBarState == KEYGUARD - ? mPanelViewControllerLazy.get().getLockscreenShadeDragProgress() + ? getLockscreenShadeDragProgress() : mShadeExpandedFraction; mShadeHeaderController.setShadeExpandedFraction(shadeExpandedFraction); mShadeHeaderController.setQsExpandedFraction(qsExpansionFraction); mShadeHeaderController.setQsVisible(mVisible); } + float getLockscreenShadeDragProgress() { + // mTransitioningToFullShadeProgress > 0 means we're doing regular lockscreen to shade + // transition. If that's not the case we should follow QS expansion fraction for when + // user is pulling from the same top to go directly to expanded QS + return getTransitioningToFullShadeProgress() > 0 + ? mLockscreenShadeTransitionController.getQSDragProgress() + : computeExpansionFraction(); + } + /** */ public void updateExpansionEnabledAmbient() { final float scrollRangeToTop = mAmbientState.getTopPadding() - mQuickQsHeaderHeight; @@ -1521,7 +1530,7 @@ public class QuickSettingsController { if (scrollY > 0 && !mFullyExpanded) { // TODO (b/265193930): remove dependency on NPVC // If we are scrolling QS, we should be fully expanded. - mPanelViewControllerLazy.get().expandWithQs(); + mPanelViewControllerLazy.get().expandToQs(); } } @@ -1726,7 +1735,7 @@ public class QuickSettingsController { return true; } // TODO (b/265193930): remove dependency on NPVC - if (mPanelViewControllerLazy.get().getKeyguardShowing() + if (mPanelViewControllerLazy.get().isKeyguardShowing() && shouldQuickSettingsIntercept(mInitialTouchX, mInitialTouchY, 0)) { // Dragging down on the lockscreen statusbar should prohibit other interactions // immediately, otherwise we'll wait on the touchslop. This is to allow @@ -1790,7 +1799,7 @@ public class QuickSettingsController { return true; } else { mShadeLog.logQsTrackingNotStarted(mInitialTouchY, y, h, touchSlop, - getExpanded(), mPanelViewControllerLazy.get().getKeyguardShowing(), + getExpanded(), mPanelViewControllerLazy.get().isKeyguardShowing(), isExpansionEnabled()); } break; diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java index c1369935db54..826b3ee7a92d 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java @@ -35,12 +35,12 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.window.StatusBarWindowController; +import dagger.Lazy; + import java.util.ArrayList; import javax.inject.Inject; -import dagger.Lazy; - /** An implementation of {@link ShadeController}. */ @SysUISingleton public final class ShadeControllerImpl implements ShadeController { @@ -132,13 +132,13 @@ public final class ShadeControllerImpl implements ShadeController { "animateCollapse(): mExpandedVisible=" + mExpandedVisible + "flags=" + flags); } if (getNotificationShadeWindowView() != null - && mNotificationPanelViewController.canPanelBeCollapsed() + && mNotificationPanelViewController.canBeCollapsed() && (flags & CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL) == 0) { // release focus immediately to kick off focus change transition mNotificationShadeWindowController.setNotificationShadeFocusable(false); mNotificationShadeWindowViewController.cancelExpandHelper(); - mNotificationPanelViewController.collapsePanel(true, delayed, speedUpFactor); + mNotificationPanelViewController.collapse(true, delayed, speedUpFactor); } } @@ -155,7 +155,7 @@ public final class ShadeControllerImpl implements ShadeController { @Override public boolean isShadeFullyOpen() { - return mNotificationPanelViewController.isShadeFullyOpen(); + return mNotificationPanelViewController.isShadeFullyExpanded(); } @Override @@ -268,7 +268,7 @@ public final class ShadeControllerImpl implements ShadeController { } // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) - mNotificationPanelViewController.collapsePanel(false, false, 1.0f); + mNotificationPanelViewController.collapse(false, false, 1.0f); mExpandedVisible = false; notifyVisibilityChanged(false); @@ -290,7 +290,7 @@ public final class ShadeControllerImpl implements ShadeController { notifyExpandedVisibleChanged(false); mCommandQueue.recomputeDisableFlags( mDisplayId, - mNotificationPanelViewController.hideStatusBarIconsWhenExpanded() /* animate */); + mNotificationPanelViewController.shouldHideStatusBarIconsWhenExpanded()); // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in // the bouncer appear animation. diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt new file mode 100644 index 000000000000..b698bd3e6468 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.systemui.shade + +import android.view.ViewPropertyAnimator +import com.android.systemui.statusbar.GestureRecorder +import com.android.systemui.statusbar.NotificationShelfController +import com.android.systemui.statusbar.phone.CentralSurfaces +import com.android.systemui.statusbar.phone.HeadsUpManagerPhone + +/** + * Allows CentralSurfacesImpl to interact with the shade. Only CentralSurfacesImpl should reference + * this class. If any method in this class is needed outside of CentralSurfacesImpl, it must be + * pulled up into ShadeViewController. + */ +interface ShadeSurface : ShadeViewController { + /** Initialize objects instead of injecting to avoid circular dependencies. */ + fun initDependencies( + centralSurfaces: CentralSurfaces, + recorder: GestureRecorder, + hideExpandedRunnable: Runnable, + notificationShelfController: NotificationShelfController, + headsUpManager: HeadsUpManagerPhone + ) + + /** + * Animate QS collapse by flinging it. If QS is expanded, it will collapse into QQS and stop. If + * in split shade, it will collapse the whole shade. + * + * @param fullyCollapse Do not stop when QS becomes QQS. Fling until QS isn't visible anymore. + */ + fun animateCollapseQs(fullyCollapse: Boolean) + + /** Returns whether the shade can be collapsed. */ + fun canBeCollapsed(): Boolean + + /** Cancels any pending collapses. */ + fun cancelPendingCollapse() + + /** Cancels the views current animation. */ + fun cancelAnimation() + + /** + * Close the keyguard user switcher if it is open and capable of closing. + * + * Has no effect if user switcher isn't supported, if the user switcher is already closed, or if + * the user switcher uses "simple" mode. The simple user switcher cannot be closed. + * + * @return true if the keyguard user switcher was open, and is now closed + */ + fun closeUserSwitcherIfOpen(): Boolean + + /** Input focus transfer is about to happen. */ + fun startWaitingForExpandGesture() + + /** + * Called when this view is no longer waiting for input focus transfer. + * + * There are two scenarios behind this function call. First, input focus transfer has + * successfully happened and this view already received synthetic DOWN event. + * (mExpectingSynthesizedDown == false). Do nothing. + * + * Second, before input focus transfer finished, user may have lifted finger in previous window + * and this window never received synthetic DOWN event. (mExpectingSynthesizedDown == true). In + * this case, we use the velocity to trigger fling event. + * + * @param velocity unit is in px / millis + */ + fun stopWaitingForExpandGesture(cancel: Boolean, velocity: Float) + + /** Animates the view from its current alpha to zero then runs the runnable. */ + fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable): ViewPropertyAnimator + + /** Set whether the bouncer is showing. */ + fun setBouncerShowing(bouncerShowing: Boolean) + + /** + * Sets whether the shade can handle touches and/or animate, canceling any touch handling or + * animations in progress. + */ + fun setTouchAndAnimationDisabled(disabled: Boolean) + + /** + * Sets the dozing state. + * + * @param dozing `true` when dozing. + * @param animate if transition should be animated. + */ + fun setDozing(dozing: Boolean, animate: Boolean) + + /** @see view.setImportantForAccessibility */ + fun setImportantForAccessibility(mode: Int) + + /** Sets Qs ScrimEnabled and updates QS state. */ + fun setQsScrimEnabled(qsScrimEnabled: Boolean) + + /** Sets the view's X translation to zero. */ + fun resetTranslation() + + /** Sets the view's alpha to max. */ + fun resetAlpha() + + /** @see ViewGroupFadeHelper.reset */ + fun resetViewGroupFade() + + /** Called when Back gesture has been committed (i.e. a back event has definitely occurred) */ + fun onBackPressed() + + /** Sets progress of the predictive back animation. */ + fun onBackProgressed(progressFraction: Float) + + /** @see com.android.systemui.keyguard.ScreenLifecycle.Observer.onScreenTurningOn */ + fun onScreenTurningOn() + + /** + * Called when the device's theme changes. + * + * TODO(b/274655539) delete? + */ + fun onThemeChanged() + + /** Updates the shade expansion and [NotificationPanelView] visibility if necessary. */ + fun updateExpansionAndVisibility() + + /** Updates all field values drawn from Resources. */ + fun updateResources() +} diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt new file mode 100644 index 000000000000..34c9f6d16fff --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.systemui.shade + +import android.view.MotionEvent +import android.view.ViewGroup +import com.android.systemui.statusbar.RemoteInputController +import com.android.systemui.statusbar.notification.row.ActivatableNotificationView +import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow +import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController +import com.android.systemui.statusbar.phone.HeadsUpAppearanceController +import com.android.systemui.statusbar.phone.KeyguardBottomAreaView +import java.util.function.Consumer + +/** + * Controller for the top level shade view + * + * @see NotificationPanelViewController + */ +interface ShadeViewController { + /** Expand the shade either animated or instantly. */ + fun expand(animate: Boolean) + + /** Animates to an expanded shade with QS expanded. If the shade starts expanded, expands QS. */ + fun expandToQs() + + /** + * Expand shade so that notifications are visible. Non-split shade: just expanding shade or + * collapsing QS when they're expanded. Split shade: only expanding shade, notifications are + * always visible + * + * Called when `adb shell cmd statusbar expand-notifications` is executed. + */ + fun expandToNotifications() + + /** Returns whether the shade is expanding or collapsing itself or quick settings. */ + val isExpanding: Boolean + + /** + * Returns whether the shade height is greater than zero (i.e. partially or fully expanded), + * there is a HUN, the shade is animating, or the shade is instantly expanding. + */ + val isExpanded: Boolean + + /** + * Returns whether the shade height is greater than zero or the shade is expecting a synthesized + * down event. + */ + @get:Deprecated("use {@link #isExpanded()} instead") val isPanelExpanded: Boolean + + /** Returns whether the shade is fully expanded in either QS or QQS. */ + val isShadeFullyExpanded: Boolean + + /** + * Animates the collapse of a shade with the given delay and the default duration divided by + * speedUpFactor. + */ + fun collapse(delayed: Boolean, speedUpFactor: Float) + + /** Collapses the shade. */ + fun collapse(animate: Boolean, delayed: Boolean, speedUpFactor: Float) + + /** Collapses the shade with an animation duration in milliseconds. */ + fun collapseWithDuration(animationDuration: Int) + + /** Returns whether the shade is in the process of collapsing. */ + val isCollapsing: Boolean + + /** Returns whether shade's height is zero. */ + val isFullyCollapsed: Boolean + + /** Returns whether the shade is tracking touches for expand/collapse of the shade or QS. */ + val isTracking: Boolean + + /** Returns whether the shade's top level view is enabled. */ + val isViewEnabled: Boolean + + /** Returns whether status bar icons should be hidden when the shade is expanded. */ + fun shouldHideStatusBarIconsWhenExpanded(): Boolean + + /** + * 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. + */ + fun blockExpansionForCurrentTouch() + + /** + * Disables the shade header. + * + * @see ShadeHeaderController.disable + */ + fun disableHeader(state1: Int, state2: Int, animated: Boolean) + + /** If the latency tracker is enabled, begins tracking expand latency. */ + fun startExpandLatencyTracking() + + /** Called before animating Keyguard dismissal, i.e. the animation dismissing the bouncer. */ + fun startBouncerPreHideAnimation() + + /** Called once every minute while dozing. */ + fun dozeTimeTick() + + /** Close guts, notification menus, and QS. Set scroll and overscroll to 0. */ + fun resetViews(animate: Boolean) + + /** Returns the StatusBarState. */ + val barState: Int + + /** + * Returns the bottom part of the keyguard, which contains quick affordances. + * + * TODO(b/275550429): this should be removed. + */ + val keyguardBottomAreaView: KeyguardBottomAreaView? + + /** Returns the NSSL controller. */ + val notificationStackScrollLayoutController: NotificationStackScrollLayoutController + + /** Sets the amount of progress in the status bar launch animation. */ + fun applyLaunchAnimationProgress(linearProgress: Float) + + /** Sets whether the status bar launch animation is currently running. */ + fun setIsLaunchAnimationRunning(running: Boolean) + + /** Sets the alpha value of the shade to a value between 0 and 255. */ + fun setAlpha(alpha: Int, animate: Boolean) + + /** + * Sets the runnable to run after the alpha change animation completes. + * + * @see .setAlpha + */ + fun setAlphaChangeAnimationEndAction(r: Runnable) + + /** Sets whether the screen has temporarily woken up to display notifications. */ + fun setPulsing(pulsing: Boolean) + + /** Sets the top spacing for the ambient indicator. */ + fun setAmbientIndicationTop(ambientIndicationTop: Int, ambientTextVisible: Boolean) + + /** Updates notification panel-specific flags on [SysUiState]. */ + fun updateSystemUiStateFlags() + + /** Ensures that the touchable region is updated. */ + fun updateTouchableRegion() + + // ******* Begin Keyguard Section ********* + /** Animate to expanded shade after a delay in ms. Used for lockscreen to shade transition. */ + fun transitionToExpandedShade(delay: Long) + + /** + * Returns whether the unlock hint animation is running. The unlock hint animation is when the + * user taps the lock screen, causing the contents of the lock screen visually bounce. + */ + val isUnlockHintRunning: Boolean + + /** + * Set the alpha and translationY of the keyguard elements which only show on the lockscreen, + * but not in shade locked / shade. This is used when dragging down to the full shade. + */ + fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) + + /** Sets the overstretch amount in raw pixels when dragging down. */ + fun setOverStretchAmount(amount: Float) + + /** + * Sets the alpha value to be set on the keyguard status bar. + * + * @param alpha value between 0 and 1. -1 if the value is to be reset. + */ + fun setKeyguardStatusBarAlpha(alpha: Float) + + /** + * This method should not be used anymore, you should probably use [.isShadeFullyOpen] instead. + * It was overused as indicating if shade is open or we're on keyguard/AOD. Moving forward we + * should be explicit about the what state we're checking. + * + * @return if panel is covering the screen, which means we're in expanded shade or keyguard/AOD + */ + @Deprecated( + "depends on the state you check, use {@link #isShadeFullyExpanded()},\n" + + "{@link #isOnAod()}, {@link #isOnKeyguard()} instead." + ) + fun isFullyExpanded(): Boolean + + /** Sends an external (e.g. Status Bar) touch event to the Shade touch handler. */ + fun handleExternalTouch(event: MotionEvent): Boolean + + // ******* End Keyguard Section ********* + + /** Returns the ShadeHeadsUpTracker. */ + val shadeHeadsUpTracker: ShadeHeadsUpTracker + + /** Returns the ShadeFoldAnimator. */ + val shadeFoldAnimator: ShadeFoldAnimator + + /** Returns the ShadeNotificationPresenter. */ + val shadeNotificationPresenter: ShadeNotificationPresenter +} + +/** Manages listeners for when users begin expanding the shade from a HUN. */ +interface ShadeHeadsUpTracker { + /** Add a listener for when the user starts expanding the shade from a HUN. */ + fun addTrackingHeadsUpListener(listener: Consumer<ExpandableNotificationRow>) + + /** Remove a listener for when the user starts expanding the shade from a HUN. */ + fun removeTrackingHeadsUpListener(listener: Consumer<ExpandableNotificationRow>) + + /** Set the controller for the appearance of HUNs in the icon area and the header itself. */ + fun setHeadsUpAppearanceController(headsUpAppearanceController: HeadsUpAppearanceController?) + + /** The notification row that was touched to initiate shade expansion. */ + val trackedHeadsUpNotification: ExpandableNotificationRow? +} + +/** Handles the lifecycle of the shade's animation that happens when folding a foldable. */ +interface ShadeFoldAnimator { + /** Updates the views to the initial state for the fold to AOD animation. */ + fun prepareFoldToAodAnimation() + + /** + * Starts fold to AOD animation. + * + * @param startAction invoked when the animation starts. + * @param endAction invoked when the animation finishes, also if it was cancelled. + * @param cancelAction invoked when the animation is cancelled, before endAction. + */ + fun startFoldToAodAnimation(startAction: Runnable, endAction: Runnable, cancelAction: Runnable) + + /** Cancels fold to AOD transition and resets view state. */ + fun cancelFoldToAodAnimation() + + /** Returns the main view of the shade. */ + val view: ViewGroup +} + +/** Handles the shade's interactions with StatusBarNotificationPresenter. */ +interface ShadeNotificationPresenter { + /** Returns a new delegate for some view controller pieces of the remote input process. */ + fun createRemoteInputDelegate(): RemoteInputController.Delegate + + /** Returns whether the screen has temporarily woken up to display notifications. */ + fun hasPulsingNotifications(): Boolean + + /** The current activated notification. */ + var activatedChild: ActivatableNotificationView? +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt index 9a9503c8cd9c..63e29d105cd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt @@ -320,7 +320,7 @@ class LockscreenShadeTransitionController @Inject constructor( startingChild.onExpandedByGesture( true /* drag down is always an open */) } - notificationPanelController.animateToFullShade(delay) + notificationPanelController.transitionToExpandedShade(delay) callbacks.forEach { it.setTransitionToFullShadeAmount(0f, true /* animated */, delay) } @@ -531,7 +531,7 @@ class LockscreenShadeTransitionController @Inject constructor( } else { // Let's only animate notifications animationHandler = { delay: Long -> - notificationPanelController.animateToFullShade(delay) + notificationPanelController.transitionToExpandedShade(delay) } } goToLockedShadeInternal(expandedView, animationHandler, @@ -649,7 +649,7 @@ class LockscreenShadeTransitionController @Inject constructor( */ private fun performDefaultGoToFullShadeAnimation(delay: Long) { logger.logDefaultGoToFullShadeAnimation(delay) - notificationPanelController.animateToFullShade(delay) + notificationPanelController.transitionToExpandedShade(delay) animateAppear(delay) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java index b8c7a1d77810..e7760159bff5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java @@ -67,12 +67,12 @@ import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; +import dagger.Lazy; + import java.util.Optional; import javax.inject.Inject; -import dagger.Lazy; - /** */ @CentralSurfacesComponent.CentralSurfacesScope public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callbacks { @@ -218,7 +218,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba return; } - mNotificationPanelViewController.expandShadeToNotifications(); + mNotificationPanelViewController.expandToNotifications(); } @Override @@ -234,7 +234,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba // Settings are not available in setup if (!mDeviceProvisionedController.isCurrentUserSetup()) return; - mNotificationPanelViewController.expandWithQs(); + mNotificationPanelViewController.expandToQs(); } @Override @@ -300,7 +300,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba } } - mNotificationPanelViewController.disable(state1, state2, animate); + mNotificationPanelViewController.disableHeader(state1, state2, animate); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 2bc09a100976..bb77529a00a8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -683,7 +683,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public void onBackProgressed(BackEvent event) { if (shouldBackBeHandled()) { - if (mNotificationPanelViewController.canPanelBeCollapsed()) { + if (mNotificationPanelViewController.canBeCollapsed()) { float fraction = event.getProgress(); mNotificationPanelViewController.onBackProgressed(fraction); } @@ -1255,14 +1255,13 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // re-display the notification panel if necessary (for example, if // a heads-up notification was being displayed and should continue being // displayed). - mNotificationPanelViewController.updatePanelExpansionAndVisibility(); + mNotificationPanelViewController.updateExpansionAndVisibility(); setBouncerShowingForStatusBarComponents(mBouncerShowing); checkBarModes(); }); initializer.initializeStatusBar(mCentralSurfacesComponent); mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView); - mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); createNavigationBar(result); @@ -1335,7 +1334,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { this, mGestureRec, mShadeController::makeExpandedInvisible, - mNotificationShelfController); + mNotificationShelfController, + mHeadsUpManager); BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); mMediaManager.setup(backdrop, backdrop.findViewById(R.id.backdrop_front), @@ -2073,16 +2073,16 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } if (start) { - mNotificationPanelViewController.startWaitingForOpenPanelGesture(); + mNotificationPanelViewController.startWaitingForExpandGesture(); } else { - mNotificationPanelViewController.stopWaitingForOpenPanelGesture(cancel, velocity); + mNotificationPanelViewController.stopWaitingForExpandGesture(cancel, velocity); } } @Override public void animateCollapseQuickSettings() { if (mState == StatusBarState.SHADE) { - mNotificationPanelViewController.collapsePanel( + mNotificationPanelViewController.collapse( true, false /* delayed */, 1.0f /* speedUpFactor */); } } @@ -3277,14 +3277,14 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { return true; } if (mQsController.getExpanded()) { - mNotificationPanelViewController.animateCloseQs(false); + mNotificationPanelViewController.animateCollapseQs(false); return true; } if (mNotificationPanelViewController.closeUserSwitcherIfOpen()) { return true; } if (shouldBackBeHandled()) { - if (mNotificationPanelViewController.canPanelBeCollapsed()) { + if (mNotificationPanelViewController.canBeCollapsed()) { // this is the Shade dismiss animation, so make sure QQS closes when it ends. mNotificationPanelViewController.onBackPressed(); mShadeController.animateCollapseShade(); @@ -4317,7 +4317,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNavigationBarController.touchAutoDim(mDisplayId); Trace.beginSection("CentralSurfaces#updateKeyguardState"); if (mState == StatusBarState.KEYGUARD) { - mNotificationPanelViewController.cancelPendingPanelCollapse(); + mNotificationPanelViewController.cancelPendingCollapse(); } updateDozingState(); checkBarModes(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 69f7c71dafba..171e3d0a864e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -32,6 +32,7 @@ import com.android.systemui.flags.Flags; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shade.NotificationPanelViewController; +import com.android.systemui.shade.ShadeHeadsUpTracker; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.HeadsUpStatusBarView; @@ -133,7 +134,8 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar // has started pulling down the notification shade from the HUN and then the font size // changes). We need to re-fetch these values since they're used to correctly display the // HUN during this shade expansion. - mTrackedChild = notificationPanelViewController.getTrackedHeadsUpNotification(); + mTrackedChild = notificationPanelViewController.getShadeHeadsUpTracker() + .getTrackedHeadsUpNotification(); mAppearFraction = stackScrollerController.getAppearFraction(); mExpandedHeight = stackScrollerController.getExpandedHeight(); @@ -170,19 +172,23 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar mView.setOnDrawingRectChangedListener( () -> updateIsolatedIconLocation(true /* requireUpdate */)); mWakeUpCoordinator.addListener(this); - mNotificationPanelViewController.addTrackingHeadsUpListener(mSetTrackingHeadsUp); - mNotificationPanelViewController.setHeadsUpAppearanceController(this); + getShadeHeadsUpTracker().addTrackingHeadsUpListener(mSetTrackingHeadsUp); + getShadeHeadsUpTracker().setHeadsUpAppearanceController(this); mStackScrollerController.addOnExpandedHeightChangedListener(mSetExpandedHeight); mDarkIconDispatcher.addDarkReceiver(this); } + private ShadeHeadsUpTracker getShadeHeadsUpTracker() { + return mNotificationPanelViewController.getShadeHeadsUpTracker(); + } + @Override protected void onViewDetached() { mHeadsUpManager.removeListener(this); mView.setOnDrawingRectChangedListener(null); mWakeUpCoordinator.removeListener(this); - mNotificationPanelViewController.removeTrackingHeadsUpListener(mSetTrackingHeadsUp); - mNotificationPanelViewController.setHeadsUpAppearanceController(null); + getShadeHeadsUpTracker().removeTrackingHeadsUpListener(mSetTrackingHeadsUp); + getShadeHeadsUpTracker().setHeadsUpAppearanceController(null); mStackScrollerController.removeOnExpandedHeightChangedListener(mSetExpandedHeight); mDarkIconDispatcher.removeDarkReceiver(this); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java index 3d6bebbe998c..a7413d58a6cb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeadsUpChangeListener.java @@ -65,18 +65,7 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener mNotificationShadeWindowController.setHeadsUpShowing(true); mStatusBarWindowController.setForceStatusBarVisible(true); if (mNotificationPanelViewController.isFullyCollapsed()) { - // We need to ensure that the touchable region is updated before the - //window will be - // resized, in order to not catch any touches. A layout will ensure that - // onComputeInternalInsets will be called and after that we can - //resize the layout. Let's - // make sure that the window stays small for one frame until the - //touchableRegion is set. - mNotificationPanelViewController.requestLayoutOnView(); - mNotificationShadeWindowController.setForceWindowCollapsed(true); - mNotificationPanelViewController.postToView(() -> { - mNotificationShadeWindowController.setForceWindowCollapsed(false); - }); + mNotificationPanelViewController.updateTouchableRegion(); } } else { boolean bypassKeyguard = mKeyguardBypassController.getBypassEnabled() @@ -96,7 +85,8 @@ public class StatusBarHeadsUpChangeListener implements OnHeadsUpChangedListener //animation // is finished. mHeadsUpManager.setHeadsUpGoingAway(true); - mNotificationPanelViewController.runAfterAnimationFinished(() -> { + mNotificationPanelViewController.getNotificationStackScrollLayoutController() + .runAfterAnimationFinished(() -> { if (!mHeadsUpManager.hasPinnedHeadsUp()) { mNotificationShadeWindowController.setHeadsUpShowing(false); mHeadsUpManager.setHeadsUpGoingAway(false); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index f9493f41dfd2..49b58df23fdb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -973,7 +973,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb public void onKeyguardFadedAway() { mNotificationContainer.postDelayed(() -> mNotificationShadeWindowController .setKeyguardFadingAway(false), 100); - mNotificationPanelViewController.resetViewAlphas(); + mNotificationPanelViewController.resetViewGroupFade(); mCentralSurfaces.finishKeyguardFadingAway(); mBiometricUnlockController.finishKeyguardFadingAway(); WindowManagerGlobal.getInstance().trimMemory( @@ -1048,7 +1048,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if (hideImmediately) { mStatusBarStateController.setLeaveOpenOnKeyguardHide(false); } else { - mNotificationPanelViewController.expandShadeToNotifications(); + mNotificationPanelViewController.expandToNotifications(); } } return; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java index 4eed48739b40..39362cf29e14 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenter.java @@ -16,7 +16,6 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.statusbar.phone.CentralSurfaces.CLOSE_PANEL_WHEN_EMPTIED; import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG; -import static com.android.systemui.statusbar.phone.CentralSurfaces.MULTIUSER_DEBUG; import android.app.KeyguardManager; import android.content.Context; @@ -176,7 +175,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, } remoteInputManager.setUpWithCallback( remoteInputManagerCallback, - mNotificationPanel.createRemoteInputDelegate()); + mNotificationPanel.getShadeNotificationPresenter().createRemoteInputDelegate()); initController.addPostInitTask(() -> { mKeyguardIndicationController.init(); @@ -209,8 +208,8 @@ class StatusBarNotificationPresenter implements NotificationPresenter, } private void maybeEndAmbientPulse() { - if (mNotificationPanel.hasPulsingNotifications() && - !mHeadsUpManager.hasNotifications()) { + if (mNotificationPanel.getShadeNotificationPresenter().hasPulsingNotifications() + && !mHeadsUpManager.hasNotifications()) { // We were showing a pulse for a notification, but no notifications are pulsing anymore. // Finish the pulse. mDozeScrimController.pulseOutNow(); @@ -222,7 +221,6 @@ class StatusBarNotificationPresenter implements NotificationPresenter, // Begin old BaseStatusBar.userSwitched mHeadsUpManager.setUser(newUserId); // End old BaseStatusBar.userSwitched - if (MULTIUSER_DEBUG) mNotificationPanel.setHeaderDebugInfo("USER " + newUserId); mCommandQueue.animateCollapsePanels(); mMediaManager.clearCurrentMediaNotification(); mCentralSurfaces.setLockscreenUser(newUserId); @@ -243,7 +241,9 @@ class StatusBarNotificationPresenter implements NotificationPresenter, @Override public void onActivated(ActivatableNotificationView view) { onActivated(); - if (view != null) mNotificationPanel.setActivatedChild(view); + if (view != null) { + mNotificationPanel.getShadeNotificationPresenter().setActivatedChild(view); + } } public void onActivated() { @@ -251,7 +251,8 @@ class StatusBarNotificationPresenter implements NotificationPresenter, MetricsEvent.ACTION_LS_NOTE, 0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */); mLockscreenGestureLogger.log(LockscreenUiEvent.LOCKSCREEN_NOTIFICATION_FALSE_TOUCH); - ActivatableNotificationView previousView = mNotificationPanel.getActivatedChild(); + ActivatableNotificationView previousView = + mNotificationPanel.getShadeNotificationPresenter().getActivatedChild(); if (previousView != null) { previousView.makeInactive(true /* animate */); } @@ -259,8 +260,8 @@ class StatusBarNotificationPresenter implements NotificationPresenter, @Override public void onActivationReset(ActivatableNotificationView view) { - if (view == mNotificationPanel.getActivatedChild()) { - mNotificationPanel.setActivatedChild(null); + if (view == mNotificationPanel.getShadeNotificationPresenter().getActivatedChild()) { + mNotificationPanel.getShadeNotificationPresenter().setActivatedChild(null); mKeyguardIndicationController.hideTransientIndication(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java index 24ddded8847a..fe639943e191 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java @@ -509,7 +509,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue private boolean shouldHideNotificationIcons() { if (!mShadeExpansionStateManager.isClosed() - && mNotificationPanelViewController.hideStatusBarIconsWhenExpanded()) { + && mNotificationPanelViewController.shouldHideStatusBarIconsWhenExpanded()) { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java index 86e74564fba0..a4cb99b1b94b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessMirrorController.java @@ -64,7 +64,7 @@ public class BrightnessMirrorController mToggleSliderController = setMirrorLayout(); mNotificationPanel = notificationPanelViewController; mDepthController = notificationShadeDepthController; - mNotificationPanel.setPanelAlphaEndAction(() -> { + mNotificationPanel.setAlphaChangeAnimationEndAction(() -> { mBrightnessMirror.setVisibility(View.INVISIBLE); }); mVisibilityCallback = visibilityCallback; @@ -74,13 +74,13 @@ public class BrightnessMirrorController public void showMirror() { mBrightnessMirror.setVisibility(View.VISIBLE); mVisibilityCallback.accept(true); - mNotificationPanel.setPanelAlpha(0, true /* animate */); + mNotificationPanel.setAlpha(0, true /* animate */); mDepthController.setBrightnessMirrorVisible(true); } public void hideMirror() { mVisibilityCallback.accept(false); - mNotificationPanel.setPanelAlpha(255, true /* animate */); + mNotificationPanel.setAlpha(255, true /* animate */); mDepthController.setBrightnessMirrorVisible(false); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index 1a4a311ee0de..9ede6ce29963 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -281,6 +281,10 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { mUser = user; } + public int getUser() { + return mUser; + } + public void dump(@NonNull PrintWriter pw, @NonNull String[] args) { pw.println("HeadsUpManager state:"); dumpInternal(pw, args); diff --git a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt index 101bd4483cb3..cb561f690e36 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt @@ -30,6 +30,7 @@ import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.lifecycle.repeatWhenAttached +import com.android.systemui.shade.ShadeFoldAnimator import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.ScreenOffAnimation @@ -79,7 +80,7 @@ constructor( private val foldToAodLatencyTracker = FoldToAodLatencyTracker() private val startAnimationRunnable = Runnable { - centralSurfaces.notificationPanelViewController.startFoldToAodAnimation( + getShadeFoldAnimator().startFoldToAodAnimation( /* startAction= */ { foldToAodLatencyTracker.onAnimationStarted() }, /* endAction= */ { setAnimationState(playing = false) }, /* cancelAction= */ { setAnimationState(playing = false) }, @@ -93,7 +94,7 @@ constructor( wakefulnessLifecycle.addObserver(this) // TODO(b/254878364): remove this call to NPVC.getView() - centralSurfaces.notificationPanelViewController.view.repeatWhenAttached { + getShadeFoldAnimator().view.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { listenForDozing(this) } } } @@ -109,7 +110,7 @@ constructor( override fun startAnimation(): Boolean = if (shouldStartAnimation()) { setAnimationState(playing = true) - centralSurfaces.notificationPanelViewController.prepareFoldToAodAnimation() + getShadeFoldAnimator().prepareFoldToAodAnimation() true } else { setAnimationState(playing = false) @@ -120,12 +121,15 @@ constructor( if (isAnimationPlaying) { foldToAodLatencyTracker.cancel() cancelAnimation?.run() - centralSurfaces.notificationPanelViewController.cancelFoldToAodAnimation() + getShadeFoldAnimator().cancelFoldToAodAnimation() } setAnimationState(playing = false) } + private fun getShadeFoldAnimator(): ShadeFoldAnimator = + centralSurfaces.notificationPanelViewController.shadeFoldAnimator + private fun setAnimationState(playing: Boolean) { shouldPlayAnimation = playing isAnimationPlaying = playing @@ -154,14 +158,14 @@ constructor( // We should play the folding to AOD animation setAnimationState(playing = true) - centralSurfaces.notificationPanelViewController.prepareFoldToAodAnimation() + getShadeFoldAnimator().prepareFoldToAodAnimation() // We don't need to wait for the scrim as it is already displayed // but we should wait for the initial animation preparations to be drawn // (setting initial alpha/translation) // TODO(b/254878364): remove this call to NPVC.getView() OneShotPreDrawListener.add( - centralSurfaces.notificationPanelViewController.view, + getShadeFoldAnimator().view, onReady ) } else { @@ -186,7 +190,8 @@ constructor( cancelAnimation?.run() // Post starting the animation to the next frame to avoid junk due to inset changes - cancelAnimation = mainExecutor.executeDelayed(startAnimationRunnable, /* delayMillis= */ 0) + cancelAnimation = + mainExecutor.executeDelayed(startAnimationRunnable, /* delayMillis= */ 0) shouldPlayAnimation = false } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 7087c0135998..d447feafce93 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -162,6 +162,8 @@ import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.util.time.SystemClock; import com.android.wm.shell.animation.FlingAnimationUtils; +import dagger.Lazy; + import org.junit.After; import org.junit.Before; import org.mockito.ArgumentCaptor; @@ -173,7 +175,6 @@ import org.mockito.stubbing.Answer; import java.util.List; import java.util.Optional; -import dagger.Lazy; import kotlinx.coroutines.CoroutineDispatcher; public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @@ -578,7 +579,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mCentralSurfaces, null, () -> {}, - mNotificationShelfController); + mNotificationShelfController, + mHeadsUpManager); mNotificationPanelViewController.setTrackingStartedListener(() -> {}); mNotificationPanelViewController.setOpenCloseListener( new NotificationPanelViewController.OpenCloseListener() { @@ -588,7 +590,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Override public void onOpenStarted() {} }); - mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); ArgumentCaptor<View.OnAttachStateChangeListener> onAttachStateChangeListenerArgumentCaptor = ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class); verify(mView, atLeast(1)).addOnAttachStateChangeListener( @@ -601,7 +602,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mAccessibilityDelegate = accessibilityDelegateArgumentCaptor.getValue(); mNotificationPanelViewController.getStatusBarStateController() .addCallback(mNotificationPanelViewController.getStatusBarStateListener()); - mNotificationPanelViewController + mNotificationPanelViewController.getShadeHeadsUpTracker() .setHeadsUpAppearanceController(mock(HeadsUpAppearanceController.class)); verify(mNotificationStackScrollLayoutController) .setOnEmptySpaceClickListener(mEmptySpaceClickListenerCaptor.capture()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index d36cc7e0ddbe..c12b74405827 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -702,7 +702,8 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo ArgumentCaptor.forClass(ValueAnimator.AnimatorUpdateListener.class); // Start fold animation & Capture Listeners - mNotificationPanelViewController.startFoldToAodAnimation(() -> {}, () -> {}, () -> {}); + mNotificationPanelViewController.getShadeFoldAnimator() + .startFoldToAodAnimation(() -> {}, () -> {}, () -> {}); verify(mViewPropertyAnimator).setListener(animCaptor.capture()); verify(mViewPropertyAnimator).setUpdateListener(updateCaptor.capture()); @@ -717,7 +718,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo enableSplitShade(/* enabled= */ true); mStatusBarStateController.setState(KEYGUARD); - mNotificationPanelViewController.expandWithQs(); + mNotificationPanelViewController.expandToQs(); verify(mLockscreenShadeTransitionController).goToLockedShade( /* expandedView= */null, /* needsQSAnimation= */true); @@ -798,7 +799,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo @Test public void testQsExpansionChangedToDefaultWhenRotatingFromOrToSplitShade() { // to make sure shade is in expanded state - mNotificationPanelViewController.startWaitingForOpenPanelGesture(); + mNotificationPanelViewController.startWaitingForExpandGesture(); // switch to split shade from portrait (default state) enableSplitShade(/* enabled= */ true); @@ -817,7 +818,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo mNotificationPanelViewController.setExpandedFraction(1f); assertThat(mNotificationPanelViewController.isClosing()).isFalse(); - mNotificationPanelViewController.animateCloseQs(false); + mNotificationPanelViewController.animateCollapseQs(false); assertThat(mNotificationPanelViewController.isClosing()).isTrue(); } @@ -825,7 +826,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo @Test public void getMaxPanelTransitionDistance_expanding_inSplitShade_returnsSplitShadeFullTransitionDistance() { enableSplitShade(true); - mNotificationPanelViewController.expandWithQs(); + mNotificationPanelViewController.expandToQs(); int maxDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); @@ -835,7 +836,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo @Test public void getMaxPanelTransitionDistance_inSplitShade_withHeadsUp_returnsBiggerValue() { enableSplitShade(true); - mNotificationPanelViewController.expandWithQs(); + mNotificationPanelViewController.expandToQs(); when(mHeadsUpManager.isTrackingHeadsUp()).thenReturn(true); when(mQsController.calculatePanelHeightExpanded(anyInt())).thenReturn(10000); mNotificationPanelViewController.setHeadsUpDraggingStartingHeight( @@ -852,7 +853,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo public void getMaxPanelTransitionDistance_expandingSplitShade_keyguard_returnsNonSplitShadeValue() { mStatusBarStateController.setState(KEYGUARD); enableSplitShade(true); - mNotificationPanelViewController.expandWithQs(); + mNotificationPanelViewController.expandToQs(); int maxDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); @@ -862,7 +863,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo @Test public void getMaxPanelTransitionDistance_expanding_notSplitShade_returnsNonSplitShadeValue() { enableSplitShade(false); - mNotificationPanelViewController.expandWithQs(); + mNotificationPanelViewController.expandToQs(); int maxDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); @@ -1033,11 +1034,11 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo mStatusBarStateController.setState(SHADE); mNotificationPanelViewController.setExpandedHeight(0); - assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isFalse(); + assertThat(mNotificationPanelViewController.isShadeFullyExpanded()).isFalse(); int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); mNotificationPanelViewController.setExpandedHeight(transitionDistance); - assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); + assertThat(mNotificationPanelViewController.isShadeFullyExpanded()).isTrue(); } @Test @@ -1046,12 +1047,12 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); mNotificationPanelViewController.setExpandedHeight(transitionDistance); - assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isFalse(); + assertThat(mNotificationPanelViewController.isShadeFullyExpanded()).isFalse(); } @Test public void shadeExpanded_onShadeLocked() { mStatusBarStateController.setState(SHADE_LOCKED); - assertThat(mNotificationPanelViewController.isShadeFullyOpen()).isTrue(); + assertThat(mNotificationPanelViewController.isShadeFullyExpanded()).isTrue(); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt index ab615f99ebad..932a1f9ca587 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt @@ -223,7 +223,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { fun testGoToLockedShadeCreatesQSAnimation() { transitionController.goToLockedShade(null) verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED) - verify(notificationPanelController).animateToFullShade(anyLong()) + verify(notificationPanelController).transitionToExpandedShade(anyLong()) assertNotNull(transitionController.dragDownAnimator) } @@ -231,7 +231,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { fun testGoToLockedShadeDoesntCreateQSAnimation() { transitionController.goToLockedShade(null, needsQSAnimation = false) verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED) - verify(notificationPanelController).animateToFullShade(anyLong()) + verify(notificationPanelController).transitionToExpandedShade(anyLong()) assertNull(transitionController.dragDownAnimator) } @@ -239,7 +239,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { fun testGoToLockedShadeAlwaysCreatesQSAnimationInSplitShade() { enableSplitShade() transitionController.goToLockedShade(null, needsQSAnimation = true) - verify(notificationPanelController).animateToFullShade(anyLong()) + verify(notificationPanelController).transitionToExpandedShade(anyLong()) assertNotNull(transitionController.dragDownAnimator) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java index 31a1e4f9a4d9..775d2673ab18 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java @@ -57,6 +57,8 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; +import dagger.Lazy; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -66,8 +68,6 @@ import org.mockito.stubbing.Answer; import java.util.Optional; -import dagger.Lazy; - @SmallTest @RunWith(AndroidTestingRunner.class) public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { @@ -153,7 +153,7 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { // Trying to open it does nothing. mSbcqCallbacks.animateExpandNotificationsPanel(); - verify(mNotificationPanelViewController, never()).expandShadeToNotifications(); + verify(mNotificationPanelViewController, never()).expandToNotifications(); mSbcqCallbacks.animateExpandSettingsPanel(null); verify(mNotificationPanelViewController, never()).expand(anyBoolean()); } @@ -171,9 +171,9 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { // Can now be opened. mSbcqCallbacks.animateExpandNotificationsPanel(); - verify(mNotificationPanelViewController).expandShadeToNotifications(); + verify(mNotificationPanelViewController).expandToNotifications(); mSbcqCallbacks.animateExpandSettingsPanel(null); - verify(mNotificationPanelViewController).expandWithQs(); + verify(mNotificationPanelViewController).expandToQs(); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index 7db219719bf0..4dfe5e75c01d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -855,7 +855,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { eq(OnBackInvokedDispatcher.PRIORITY_DEFAULT), mOnBackInvokedCallback.capture()); - when(mNotificationPanelViewController.canPanelBeCollapsed()).thenReturn(true); + when(mNotificationPanelViewController.canBeCollapsed()).thenReturn(true); mOnBackInvokedCallback.getValue().onBackInvoked(); verify(mShadeController).animateCollapseShade(); } @@ -875,7 +875,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { OnBackAnimationCallback onBackAnimationCallback = (OnBackAnimationCallback) (mOnBackInvokedCallback.getValue()); - when(mNotificationPanelViewController.canPanelBeCollapsed()).thenReturn(true); + when(mNotificationPanelViewController.canBeCollapsed()).thenReturn(true); BackEvent fakeSwipeInFromLeftEdge = new BackEvent(20.0f, 100.0f, 1.0f, BackEvent.EDGE_LEFT); onBackAnimationCallback.onBackProgressed(fakeSwipeInFromLeftEdge); @@ -897,7 +897,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { OnBackAnimationCallback onBackAnimationCallback = (OnBackAnimationCallback) (mOnBackInvokedCallback.getValue()); - when(mNotificationPanelViewController.canPanelBeCollapsed()).thenReturn(true); + when(mNotificationPanelViewController.canBeCollapsed()).thenReturn(true); BackEvent fakeSwipeInFromLeftEdge = new BackEvent(20.0f, 10.0f, 0.0f, BackEvent.EDGE_LEFT); onBackAnimationCallback.onBackProgressed(fakeSwipeInFromLeftEdge); @@ -1233,7 +1233,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { setFoldedStates(FOLD_STATE_FOLDED); setGoToSleepStates(FOLD_STATE_FOLDED); mCentralSurfaces.setBarStateForTest(SHADE); - when(mNotificationPanelViewController.isShadeFullyOpen()).thenReturn(true); + when(mNotificationPanelViewController.isShadeFullyExpanded()).thenReturn(true); setDeviceState(FOLD_STATE_UNFOLDED); @@ -1245,7 +1245,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { setFoldedStates(FOLD_STATE_FOLDED); setGoToSleepStates(FOLD_STATE_FOLDED); mCentralSurfaces.setBarStateForTest(KEYGUARD); - when(mNotificationPanelViewController.isShadeFullyOpen()).thenReturn(true); + when(mNotificationPanelViewController.isShadeFullyExpanded()).thenReturn(true); setDeviceState(FOLD_STATE_UNFOLDED); @@ -1258,7 +1258,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { setFoldedStates(FOLD_STATE_FOLDED); setGoToSleepStates(FOLD_STATE_FOLDED); mCentralSurfaces.setBarStateForTest(SHADE); - when(mNotificationPanelViewController.isShadeFullyOpen()).thenReturn(false); + when(mNotificationPanelViewController.isShadeFullyExpanded()).thenReturn(false); setDeviceState(FOLD_STATE_UNFOLDED); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java index e5e5d94ab595..3372dc3e7959 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java @@ -39,6 +39,7 @@ import com.android.systemui.flags.Flags; import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shade.NotificationPanelViewController; +import com.android.systemui.shade.ShadeHeadsUpTracker; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.HeadsUpStatusBarView; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; @@ -66,6 +67,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mock(NotificationStackScrollLayoutController.class); private final NotificationPanelViewController mPanelView = mock(NotificationPanelViewController.class); + private final ShadeHeadsUpTracker mShadeHeadsUpTracker = mock(ShadeHeadsUpTracker.class); private final DarkIconDispatcher mDarkIconDispatcher = mock(DarkIconDispatcher.class); private HeadsUpAppearanceController mHeadsUpAppearanceController; private NotificationTestHelper mTestHelper; @@ -102,6 +104,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { mCommandQueue = mock(CommandQueue.class); mNotificationRoundnessManager = mock(NotificationRoundnessManager.class); mFeatureFlag = mock(FeatureFlags.class); + when(mPanelView.getShadeHeadsUpTracker()).thenReturn(mShadeHeadsUpTracker); when(mFeatureFlag.isEnabled(Flags.USE_ROUNDNESS_SOURCETYPES)).thenReturn(true); mHeadsUpAppearanceController = new HeadsUpAppearanceController( mock(NotificationIconAreaController.class), @@ -212,15 +215,15 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase { public void testDestroy() { reset(mHeadsUpManager); reset(mDarkIconDispatcher); - reset(mPanelView); + reset(mShadeHeadsUpTracker); reset(mStackScrollerController); mHeadsUpAppearanceController.onViewDetached(); verify(mHeadsUpManager).removeListener(any()); verify(mDarkIconDispatcher).removeDarkReceiver((DarkIconDispatcher.DarkReceiver) any()); - verify(mPanelView).removeTrackingHeadsUpListener(any()); - verify(mPanelView).setHeadsUpAppearanceController(isNull()); + verify(mShadeHeadsUpTracker).removeTrackingHeadsUpListener(any()); + verify(mShadeHeadsUpTracker).setHeadsUpAppearanceController(isNull()); verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java index 5bb25f5425a7..e83e50d65ae9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java @@ -45,6 +45,7 @@ import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.NotificationShadeWindowView; import com.android.systemui.shade.QuickSettingsController; import com.android.systemui.shade.ShadeController; +import com.android.systemui.shade.ShadeNotificationPresenter; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.KeyguardIndicationController; import com.android.systemui.statusbar.LockscreenShadeTransitionController; @@ -110,9 +111,12 @@ public class StatusBarNotificationPresenterTest extends SysuiTestCase { mock(NotificationStackScrollLayout.class)); when(notificationShadeWindowView.getResources()).thenReturn(mContext.getResources()); + NotificationPanelViewController npvc = mock(NotificationPanelViewController.class); + when(npvc.getShadeNotificationPresenter()) + .thenReturn(mock(ShadeNotificationPresenter.class)); mStatusBarNotificationPresenter = new StatusBarNotificationPresenter( mContext, - mock(NotificationPanelViewController.class), + npvc, mock(QuickSettingsController.class), mock(HeadsUpManagerPhone.class), notificationShadeWindowView, diff --git a/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt index a87e61aae207..61c1ab7587e0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt @@ -32,6 +32,7 @@ import com.android.systemui.keyguard.data.repository.FakeKeyguardBouncerReposito import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.shade.NotificationPanelViewController +import com.android.systemui.shade.ShadeFoldAnimator import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.phone.CentralSurfaces @@ -79,6 +80,8 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { @Mock private lateinit var commandQueue: CommandQueue + @Mock lateinit var shadeFoldAnimator: ShadeFoldAnimator + @Captor private lateinit var foldStateListenerCaptor: ArgumentCaptor<FoldStateListener> private lateinit var deviceStates: FoldableDeviceStates @@ -95,17 +98,17 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { deviceStates = FoldableTestUtils.findDeviceStates(context) // TODO(b/254878364): remove this call to NPVC.getView() - whenever(notificationPanelViewController.view).thenReturn(viewGroup) + whenever(notificationPanelViewController.shadeFoldAnimator).thenReturn(shadeFoldAnimator) + whenever(shadeFoldAnimator.view).thenReturn(viewGroup) whenever(viewGroup.viewTreeObserver).thenReturn(viewTreeObserver) whenever(wakefulnessLifecycle.lastSleepReason) .thenReturn(PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD) whenever(centralSurfaces.notificationPanelViewController) .thenReturn(notificationPanelViewController) - whenever(notificationPanelViewController.startFoldToAodAnimation(any(), any(), any())) - .then { - val onActionStarted = it.arguments[0] as Runnable - onActionStarted.run() - } + whenever(shadeFoldAnimator.startFoldToAodAnimation(any(), any(), any())).then { + val onActionStarted = it.arguments[0] as Runnable + onActionStarted.run() + } keyguardRepository = FakeKeyguardRepository() val featureFlags = FakeFeatureFlags().apply { set(FACE_AUTH_REFACTOR, true) } |