Uses static top padding for lockscreen notification space

This removes the usage of NSSLC.getTopPadding() to calculate the number of notifications to display, and uses a static value.

+ Make debugging lines for notification available space more clear.

+ Renamed getMinStackScrollerPadding, as it was used only in Lockscreen.

Fixes: 230083553
Test: Enabled debug lines for visual inspection & made sure notifications don't change count when coming back from camera started from lockscreen
Change-Id: I139d25e2bb57257a18f18f6288f3e18b7a1b72d1
This commit is contained in:
Nicolo' Mazzucato
2022-05-06 16:05:35 +02:00
parent 7b1e39d5c1
commit 66a2f62852
4 changed files with 34 additions and 8 deletions

View File

@@ -220,7 +220,7 @@ public class KeyguardClockPositionAlgorithm {
}
}
public float getMinStackScrollerPadding() {
public float getLockscreenMinStackScrollerPadding() {
if (mBypassEnabled) {
return mUnlockedStackScrollerPadding;
} else if (mIsSplitShade) {

View File

@@ -325,6 +325,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;
@@ -1513,7 +1518,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();
@@ -1525,11 +1533,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;
}
@@ -4923,6 +4935,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);

View File

@@ -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);
}

View File

@@ -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