Merge "Uses static top padding for lockscreen notification space" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-05-07 03:22:27 +00:00
committed by Android (Google) Code Review
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) { if (mBypassEnabled) {
return mUnlockedStackScrollerPadding; return mUnlockedStackScrollerPadding;
} else if (mIsSplitShade) { } else if (mIsSplitShade) {

View File

@@ -326,6 +326,11 @@ public class NotificationPanelViewController extends PanelViewController {
private boolean mShouldUseSplitNotificationShade; private boolean mShouldUseSplitNotificationShade;
// The bottom padding reserved for elements of the keyguard measuring notifications // The bottom padding reserved for elements of the keyguard measuring notifications
private float mKeyguardNotificationBottomPadding; 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 // Current max allowed keyguard notifications determined by measuring the panel
private int mMaxAllowedKeyguardNotifications; private int mMaxAllowedKeyguardNotifications;
@@ -1514,7 +1519,10 @@ public class NotificationPanelViewController extends PanelViewController {
*/ */
@VisibleForTesting @VisibleForTesting
float getSpaceForLockscreenNotifications() { 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. // Space between bottom of notifications and top of lock icon or udfps background.
float lockIconPadding = mLockIconViewController.getTop(); float lockIconPadding = mLockIconViewController.getTop();
@@ -1526,11 +1534,15 @@ public class NotificationPanelViewController extends PanelViewController {
float bottomPadding = Math.max(lockIconPadding, float bottomPadding = Math.max(lockIconPadding,
Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)); 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 = float availableSpace =
mNotificationStackScrollLayoutController.getHeight() mNotificationStackScrollLayoutController.getHeight()
- topPadding - staticTopPadding
- bottomPadding; - bottomPadding;
return availableSpace; return availableSpace;
} }
@@ -4924,6 +4936,20 @@ public class NotificationPanelViewController extends PanelViewController {
drawDebugInfo(canvas, (int) mLockIconViewController.getTop(), Color.GRAY, drawDebugInfo(canvas, (int) mLockIconViewController.getTop(), Color.GRAY,
"mLockIconViewController.getTop()"); "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); mDebugPaint.setColor(Color.CYAN);
canvas.drawLine(0, mClockPositionResult.stackScrollerPadding, mView.getWidth(), canvas.drawLine(0, mClockPositionResult.stackScrollerPadding, mView.getWidth(),
mNotificationStackScrollLayoutController.getTopPadding(), mDebugPaint); mNotificationStackScrollLayoutController.getTopPadding(), mDebugPaint);

View File

@@ -336,7 +336,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
// WHEN the position algorithm is run // WHEN the position algorithm is run
positionClock(); positionClock();
// THEN the padding DOESN'T adjust for keyguard status height. // THEN the padding DOESN'T adjust for keyguard status height.
assertThat(mClockPositionAlgorithm.getMinStackScrollerPadding()) assertThat(mClockPositionAlgorithm.getLockscreenMinStackScrollerPadding())
.isEqualTo(mKeyguardStatusBarHeaderHeight); .isEqualTo(mKeyguardStatusBarHeaderHeight);
} }

View File

@@ -610,13 +610,13 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
when(mLockIconViewController.getTop()).thenReturn(80f); when(mLockIconViewController.getTop()).thenReturn(80f);
when(mResources.getDimensionPixelSize(R.dimen.shelf_and_lock_icon_overlap)).thenReturn(5); 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.getHeight()).thenReturn(100);
when(mNotificationStackScrollLayoutController.getTopPadding()).thenReturn(10); when(mNotificationStackScrollLayoutController.getTop()).thenReturn(0);
mNotificationPanelViewController.updateResources(); mNotificationPanelViewController.updateResources();
assertThat(mNotificationPanelViewController.getSpaceForLockscreenNotifications()) assertThat(mNotificationPanelViewController.getSpaceForLockscreenNotifications())
.isEqualTo(75); .isEqualTo(85);
} }
@Test @Test