From 13e61476e3f818889ac0df6073040f5bfaa4d190 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Thu, 28 Oct 2021 18:38:32 +0100 Subject: [PATCH] Decreasing notifications height on split shade lockscreen Notifications were taking too much space, sometimes overlapping with other lockscreen elements under it. The issue was caused by notifications position calculation on lockscreen not always taking into account different arrangement in split shade, where notifications are not under keyguard status. Fixes: 200838082 Test: 1. KeyguardClockPositionAlgorithmTest 2. Have a lot of notifications and see if they overlap other lockscreen elements Change-Id: Ibbee12a85dc27e33726d206684a2120a99cfc42f --- .../phone/KeyguardClockPositionAlgorithm.java | 22 +++++++++++++--- .../KeyguardClockPositionAlgorithmTest.java | 25 ++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) 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 e368aad31ac87..4f3bbdbff030b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -195,12 +195,21 @@ public class KeyguardClockPositionAlgorithm { 1.0f /* panelExpansion */, 1.0f /* darkAmount */); result.clockAlpha = getClockAlpha(y); result.stackScrollerPadding = getStackScrollerPadding(y); - result.stackScrollerPaddingExpanded = mBypassEnabled ? mUnlockedStackScrollerPadding - : getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight; + result.stackScrollerPaddingExpanded = getStackScrollerPaddingExpanded(); result.clockX = (int) interpolate(0, burnInPreventionOffsetX(), mDarkAmount); result.clockScale = interpolate(getBurnInScale(), 1.0f, 1.0f - mDarkAmount); } + private int getStackScrollerPaddingExpanded() { + if (mBypassEnabled) { + return mUnlockedStackScrollerPadding; + } else if (mIsSplitShade) { + return getClockY(1.0f, mDarkAmount); + } else { + return getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight; + } + } + private int getStackScrollerPadding(int clockYPosition) { if (mBypassEnabled) { return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount); @@ -212,8 +221,13 @@ public class KeyguardClockPositionAlgorithm { } public float getMinStackScrollerPadding() { - return mBypassEnabled ? mUnlockedStackScrollerPadding - : mMinTopMargin + mKeyguardStatusHeight; + if (mBypassEnabled) { + return mUnlockedStackScrollerPadding; + } else if (mIsSplitShade) { + return mMinTopMargin; + } else { + return mMinTopMargin + mKeyguardStatusHeight; + } } private int getExpandedPreferredClockY() { 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 d098e1a0b8a5a..624bedc30be9b 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 @@ -58,7 +58,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private KeyguardClockPositionAlgorithm.Result mClockPosition; private MockitoSession mStaticMockSession; - private int mNotificationStackHeight; private float mPanelExpansion; private int mKeyguardStatusBarHeaderHeight; @@ -263,6 +262,30 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } + @Test + public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() { + givenLockScreen(); + mIsSplitShade = true; + mKeyguardStatusHeight = 200; + // WHEN the position algorithm is run + positionClock(); + // THEN the padding DOESN'T adjust for keyguard status height. + assertThat(mClockPosition.stackScrollerPaddingExpanded) + .isEqualTo(mClockPosition.clockYFullyDozing); + } + + @Test + public void notifMinPaddingAlignedWithClockInSplitShadeMode() { + givenLockScreen(); + mIsSplitShade = true; + mKeyguardStatusHeight = 200; + // WHEN the position algorithm is run + positionClock(); + // THEN the padding DOESN'T adjust for keyguard status height. + assertThat(mClockPositionAlgorithm.getMinStackScrollerPadding()) + .isEqualTo(mKeyguardStatusBarHeaderHeight); + } + @Test public void notifPositionWithLargeClockOnLockScreen() { // GIVEN on lock screen and clock has a nonzero height