diff options
6 files changed, 71 insertions, 48 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index e68182ef85c9..5ea52230d588 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -393,6 +393,9 @@ public final class NotificationPanelViewController implements Dumpable { private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; private int mQsTrackingPointer; private VelocityTracker mQsVelocityTracker; + private TrackingStartedListener mTrackingStartedListener; + private OpenCloseListener mOpenCloseListener; + private GestureRecorder mGestureRecorder; private boolean mQsTracking; /** Whether the ongoing gesture might both trigger the expansion in both the view and QS. */ private boolean mConflictingQsExpansionGesture; @@ -1362,6 +1365,14 @@ public final class NotificationPanelViewController implements Dumpable { mKeyguardIndicationController.setIndicationArea(mKeyguardBottomArea); } + void setOpenCloseListener(OpenCloseListener openCloseListener) { + mOpenCloseListener = openCloseListener; + } + + void setTrackingStartedListener(TrackingStartedListener trackingStartedListener) { + mTrackingStartedListener = trackingStartedListener; + } + private void updateGestureExclusionRect() { Rect exclusionRect = calculateGestureExclusionRect(); mView.setSystemGestureExclusionRects(exclusionRect.isEmpty() ? Collections.emptyList() @@ -1936,9 +1947,9 @@ public final class NotificationPanelViewController implements Dumpable { } private void fling(float vel) { - GestureRecorder gr = mCentralSurfaces.getGestureRecorder(); - if (gr != null) { - gr.tag("fling " + ((vel > 0) ? "open" : "closed"), "notifications,v=" + vel); + if (mGestureRecorder != null) { + mGestureRecorder.tag("fling " + ((vel > 0) ? "open" : "closed"), + "notifications,v=" + vel); } fling(vel, true, 1.0f /* collapseSpeedUpFactor */, false); } @@ -3711,7 +3722,7 @@ public final class NotificationPanelViewController implements Dumpable { mFalsingCollector.onTrackingStarted(!mKeyguardStateController.canDismissLockScreen()); endClosing(); mTracking = true; - mCentralSurfaces.onTrackingStarted(); + mTrackingStartedListener.onTrackingStarted(); notifyExpandingStarted(); updatePanelExpansionAndVisibility(); mScrimController.onTrackingStarted(); @@ -3945,7 +3956,7 @@ public final class NotificationPanelViewController implements Dumpable { } private void onClosingFinished() { - mCentralSurfaces.onClosingFinished(); + mOpenCloseListener.onClosingFinished(); setClosingWithAlphaFadeout(false); mMediaHierarchyManager.closeGuts(); } @@ -4504,11 +4515,13 @@ public final class NotificationPanelViewController implements Dumpable { */ public void initDependencies( CentralSurfaces centralSurfaces, + GestureRecorder recorder, Runnable hideExpandedRunnable, NotificationShelfController notificationShelfController) { // TODO(b/254859580): this can be injected. mCentralSurfaces = centralSurfaces; + mGestureRecorder = recorder; mHideExpandedRunnable = hideExpandedRunnable; mNotificationStackScrollLayoutController.setShelfController(notificationShelfController); mNotificationShelfController = notificationShelfController; @@ -5757,7 +5770,7 @@ public final class NotificationPanelViewController implements Dumpable { if (mSplitShadeEnabled && !isOnKeyguard()) { setQsExpandImmediate(true); } - mCentralSurfaces.makeExpandedVisible(false); + mOpenCloseListener.onOpenStarted(); } if (state == STATE_CLOSED) { setQsExpandImmediate(false); @@ -6240,4 +6253,17 @@ public final class NotificationPanelViewController implements Dumpable { return super.performAccessibilityAction(host, action, args); } } + + /** Listens for when touch tracking begins. */ + interface TrackingStartedListener { + void onTrackingStarted(); + } + + /** Listens for when shade begins opening of finishes closing. */ + interface OpenCloseListener { + /** Called when the shade finishes closing. */ + void onClosingFinished(); + /** Called when the shade starts opening. */ + void onOpenStarted(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java index de9dcf99cde8..a41a15d4e2a2 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java @@ -111,6 +111,9 @@ public interface ShadeController { /** Handle status bar touch event. */ void onStatusBarTouch(MotionEvent event); + /** Called when the shade finishes collapsing. */ + void onClosingFinished(); + /** Sets the listener for when the visibility of the shade changes. */ void setVisibilityListener(ShadeVisibilityListener listener); diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java index 807e2e63156f..638e74883f23 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java @@ -227,6 +227,16 @@ public final class ShadeControllerImpl implements ShadeController { } @Override + public void onClosingFinished() { + runPostCollapseRunnables(); + if (!mPresenter.isPresenterFullyCollapsed()) { + // if we set it not to be focusable when collapsing, we have to undo it when we aborted + // the closing + mNotificationShadeWindowController.setNotificationShadeFocusable(true); + } + } + + @Override public void instantCollapseShade() { mNotificationPanelViewController.instantCollapse(); runPostCollapseRunnables(); @@ -329,5 +339,18 @@ public final class ShadeControllerImpl implements ShadeController { public void setNotificationPanelViewController( NotificationPanelViewController notificationPanelViewController) { mNotificationPanelViewController = notificationPanelViewController; + mNotificationPanelViewController.setTrackingStartedListener(this::runPostCollapseRunnables); + mNotificationPanelViewController.setOpenCloseListener( + new NotificationPanelViewController.OpenCloseListener() { + @Override + public void onClosingFinished() { + ShadeControllerImpl.this.onClosingFinished(); + } + + @Override + public void onOpenStarted() { + makeExpandedVisible(false); + } + }); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index 883ce1e715af..c6f64f3e56ba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -51,7 +51,6 @@ import com.android.systemui.qs.QSPanelController; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.NotificationShadeWindowView; import com.android.systemui.shade.NotificationShadeWindowViewController; -import com.android.systemui.statusbar.GestureRecorder; import com.android.systemui.statusbar.LightRevealScrim; import com.android.systemui.statusbar.NotificationPresenter; @@ -286,8 +285,6 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn void onTouchEvent(MotionEvent event); - GestureRecorder getGestureRecorder(); - BiometricUnlockController getBiometricUnlockController(); void showWirelessChargingAnimation(int batteryLevel); @@ -402,10 +399,6 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn LightRevealScrim getLightRevealScrim(); - void onTrackingStarted(); - - void onClosingFinished(); - // TODO: Figure out way to remove these. NavigationBarView getNavigationBarView(); @@ -489,13 +482,6 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn void updateNotificationPanelTouchState(); - /** - * TODO(b/257041702) delete this - * @deprecated Use ShadeController#makeExpandedVisible - */ - @Deprecated - void makeExpandedVisible(boolean force); - int getDisplayId(); int getRotation(); 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 1c0febb6a0ef..00a9916f5ac1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1257,6 +1257,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNotificationPanelViewController.initDependencies( this, + mGestureRec, mShadeController::makeExpandedInvisible, mNotificationShelfController); @@ -1855,7 +1856,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { public void onLaunchAnimationCancelled(boolean isLaunchForActivity) { if (mPresenter.isPresenterFullyCollapsed() && !mPresenter.isCollapsing() && isLaunchForActivity) { - onClosingFinished(); + mShadeController.onClosingFinished(); } else { mShadeController.collapseShade(true /* animate */); } @@ -1865,7 +1866,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public void onLaunchAnimationEnd(boolean launchIsFullScreen) { if (!mPresenter.isCollapsing()) { - onClosingFinished(); + mShadeController.onClosingFinished(); } if (launchIsFullScreen) { mShadeController.instantCollapseShade(); @@ -2052,11 +2053,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } @Override - public GestureRecorder getGestureRecorder() { - return mGestureRec; - } - - @Override public BiometricUnlockController getBiometricUnlockController() { return mBiometricUnlockController; } @@ -3338,21 +3334,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { return mLightRevealScrim; } - @Override - public void onTrackingStarted() { - mShadeController.runPostCollapseRunnables(); - } - - @Override - public void onClosingFinished() { - mShadeController.runPostCollapseRunnables(); - if (!mPresenter.isPresenterFullyCollapsed()) { - // if we set it not to be focusable when collapsing, we have to undo it when we aborted - // the closing - mNotificationShadeWindowController.setNotificationShadeFocusable(true); - } - } - // TODO: Figure out way to remove these. @Override public NavigationBarView getNavigationBarView() { @@ -3584,12 +3565,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNotificationIconAreaController.setAnimationsEnabled(!disabled); } - //TODO(b/257041702) delete - @Override - public void makeExpandedVisible(boolean force) { - mShadeController.makeExpandedVisible(force); - } - final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() { @Override public void onScreenTurningOn(Runnable onDrawn) { 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 69a45599668b..f7358899ace3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -499,8 +499,18 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mDumpManager); mNotificationPanelViewController.initDependencies( mCentralSurfaces, + null, () -> {}, mNotificationShelfController); + mNotificationPanelViewController.setTrackingStartedListener(() -> {}); + mNotificationPanelViewController.setOpenCloseListener( + new NotificationPanelViewController.OpenCloseListener() { + @Override + public void onClosingFinished() {} + + @Override + public void onOpenStarted() {} + }); mNotificationPanelViewController.setHeadsUpManager(mHeadsUpManager); ArgumentCaptor<View.OnAttachStateChangeListener> onAttachStateChangeListenerArgumentCaptor = ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class); |