diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index 83970dc15e61d..629aa0317d24f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -220,7 +220,7 @@ public class KeyguardClockPositionAlgorithm { } } - public float getMinStackScrollerPadding() { + public float getLockscreenMinStackScrollerPadding() { if (mBypassEnabled) { return mUnlockedStackScrollerPadding; } else if (mIsSplitShade) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 7da32384b7667..74b9c71d2198a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -326,6 +326,11 @@ public class NotificationPanelViewController extends PanelViewController { private boolean mShouldUseSplitNotificationShade; // The bottom padding reserved for elements of the keyguard measuring notifications private float mKeyguardNotificationBottomPadding; + /** + * The top padding from where notification should start in lockscreen. + * Should be static also during animations and should match the Y of the first notification. + */ + private float mKeyguardNotificationTopPadding; // Current max allowed keyguard notifications determined by measuring the panel private int mMaxAllowedKeyguardNotifications; @@ -1514,7 +1519,10 @@ public class NotificationPanelViewController extends PanelViewController { */ @VisibleForTesting float getSpaceForLockscreenNotifications() { - float topPadding = mNotificationStackScrollLayoutController.getTopPadding(); + float staticTopPadding = mClockPositionAlgorithm.getLockscreenMinStackScrollerPadding() + // getMinStackScrollerPadding is from the top of the screen, + // but we need it from the top of the NSSL. + - mNotificationStackScrollLayoutController.getTop(); // Space between bottom of notifications and top of lock icon or udfps background. float lockIconPadding = mLockIconViewController.getTop(); @@ -1526,11 +1534,15 @@ public class NotificationPanelViewController extends PanelViewController { float bottomPadding = Math.max(lockIconPadding, Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)); - mKeyguardNotificationBottomPadding = bottomPadding; + mKeyguardNotificationBottomPadding = bottomPadding; + mKeyguardNotificationTopPadding = staticTopPadding; + + // To debug the available space, enable debug lines in this class. If you change how the + // available space is calculated, please also update those lines. float availableSpace = mNotificationStackScrollLayoutController.getHeight() - - topPadding + - staticTopPadding - bottomPadding; return availableSpace; } @@ -4924,6 +4936,20 @@ public class NotificationPanelViewController extends PanelViewController { drawDebugInfo(canvas, (int) mLockIconViewController.getTop(), Color.GRAY, "mLockIconViewController.getTop()"); + if (mKeyguardShowing) { + // Notifications have the space between those two lines. + drawDebugInfo(canvas, + mNotificationStackScrollLayoutController.getTop() + + (int) mKeyguardNotificationTopPadding, + Color.RED, + "NSSL.getTop() + mKeyguardNotificationTopPadding"); + + drawDebugInfo(canvas, mNotificationStackScrollLayoutController.getBottom() - + (int) mKeyguardNotificationBottomPadding, + Color.RED, + "NSSL.getBottom() - mKeyguardNotificationBottomPadding"); + } + mDebugPaint.setColor(Color.CYAN); canvas.drawLine(0, mClockPositionResult.stackScrollerPadding, mView.getWidth(), mNotificationStackScrollLayoutController.getTopPadding(), mDebugPaint); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index 6d3a5fecc826e..ec20271ea43b3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -336,7 +336,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { // WHEN the position algorithm is run positionClock(); // THEN the padding DOESN'T adjust for keyguard status height. - assertThat(mClockPositionAlgorithm.getMinStackScrollerPadding()) + assertThat(mClockPositionAlgorithm.getLockscreenMinStackScrollerPadding()) .isEqualTo(mKeyguardStatusBarHeaderHeight); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index 94e6b9a12a93c..11f96cec6369b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -610,13 +610,13 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { when(mLockIconViewController.getTop()).thenReturn(80f); when(mResources.getDimensionPixelSize(R.dimen.shelf_and_lock_icon_overlap)).thenReturn(5); - // Available space (100 - 10 - 15 = 75) + // Available space (100 - 0 - 15 = 85) when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(100); - when(mNotificationStackScrollLayoutController.getTopPadding()).thenReturn(10); + when(mNotificationStackScrollLayoutController.getTop()).thenReturn(0); mNotificationPanelViewController.updateResources(); assertThat(mNotificationPanelViewController.getSpaceForLockscreenNotifications()) - .isEqualTo(75); + .isEqualTo(85); } @Test