From 38f8e0e53e6c25f809bdcf66c554999f4c25b4e9 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Tue, 9 Nov 2021 18:30:27 +0000 Subject: [PATCH] Moving notifications and keyguard status higher in split shade lockscreen Decreasing Y position of keyguard status view and decreasing padding of notifications. Padding of notifications is calculated instead of provided with resources because notifications already have margin that is flexible and would be likely overriden in overlays. Fixes: 204568802 Test: KeyguardClockPositionAlgorithmTest Change-Id: I3f9c60ec03bfdc3efc347d3dd1cb1b66c6dcd865 --- .../res/values-sw600dp-land/dimens.xml | 4 ++ packages/SystemUI/res/values/dimens.xml | 3 ++ .../phone/KeyguardClockPositionAlgorithm.java | 39 ++++++++++--------- .../KeyguardClockPositionAlgorithmTest.java | 30 +++++++++++++- 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/packages/SystemUI/res/values-sw600dp-land/dimens.xml b/packages/SystemUI/res/values-sw600dp-land/dimens.xml index 23f138ba250fc..3cfe056380320 100644 --- a/packages/SystemUI/res/values-sw600dp-land/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp-land/dimens.xml @@ -21,4 +21,8 @@ 25dp 115dp 60dp + + + 8dp diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 58beb000539ce..7aa96fc4c2a24 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -747,6 +747,9 @@ 100dp + + 68dp 20dp 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 4f3bbdbff030b..7ca8652e1b3c5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -56,21 +56,6 @@ public class KeyguardClockPositionAlgorithm { */ private int mUserSwitchPreferredY; - /** - * Whether or not there is a custom clock face on keyguard. - */ - private boolean mHasCustomClock; - - /** - * Whether or not the NSSL contains any visible notifications. - */ - private boolean mHasVisibleNotifs; - - /** - * Height of notification stack: Sum of height of each notification. - */ - private int mNotificationStackHeight; - /** * Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher * avatar. @@ -87,6 +72,16 @@ public class KeyguardClockPositionAlgorithm { */ private int mContainerTopPadding; + /** + * Top margin of notifications introduced by presence of split shade header / status bar + */ + private int mSplitShadeTopNotificationsMargin; + + /** + * Target margin for notifications and clock from the top of the screen in split shade + */ + private int mSplitShadeTargetTopMargin; + /** * @see NotificationPanelViewController#getExpandedFraction() */ @@ -152,6 +147,10 @@ public class KeyguardClockPositionAlgorithm { public void loadDimens(Resources res) { mStatusViewBottomMargin = res.getDimensionPixelSize( R.dimen.keyguard_status_view_bottom_margin); + mSplitShadeTopNotificationsMargin = + res.getDimensionPixelSize(R.dimen.split_shade_header_height); + mSplitShadeTargetTopMargin = + res.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin); mContainerTopPadding = res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); @@ -214,7 +213,7 @@ public class KeyguardClockPositionAlgorithm { if (mBypassEnabled) { return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount); } else if (mIsSplitShade) { - return clockYPosition; + return Math.max(0, clockYPosition - mSplitShadeTopNotificationsMargin); } else { return clockYPosition + mKeyguardStatusHeight; } @@ -224,14 +223,18 @@ public class KeyguardClockPositionAlgorithm { if (mBypassEnabled) { return mUnlockedStackScrollerPadding; } else if (mIsSplitShade) { - return mMinTopMargin; + return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin); } else { return mMinTopMargin + mKeyguardStatusHeight; } } private int getExpandedPreferredClockY() { - return mMinTopMargin + mUserSwitchHeight; + if (mIsSplitShade) { + return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin); + } else { + return mMinTopMargin; + } } public int getLockscreenStatusViewHeight() { 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 624bedc30be9b..11826954baee9 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 @@ -262,6 +262,34 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } + @Test + public void clockPositionedDependingOnMarginInSplitShade() { + when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) + .thenReturn(400); + mClockPositionAlgorithm.loadDimens(mResources); + givenLockScreen(); + mIsSplitShade = true; + // WHEN the position algorithm is run + positionClock(); + + assertThat(mClockPosition.clockY).isEqualTo(400); + } + + @Test + public void notifPaddingMakesUpToFullMarginInSplitShade() { + when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) + .thenReturn(100); + when(mResources.getDimensionPixelSize(R.dimen.split_shade_header_height)) + .thenReturn(70); + mClockPositionAlgorithm.loadDimens(mResources); + givenLockScreen(); + mIsSplitShade = true; + // WHEN the position algorithm is run + positionClock(); + // THEN the notif padding makes up lacking margin (margin - header height = 30). + assertThat(mClockPosition.stackScrollerPadding).isEqualTo(30); + } + @Test public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() { givenLockScreen(); @@ -271,7 +299,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { positionClock(); // THEN the padding DOESN'T adjust for keyguard status height. assertThat(mClockPosition.stackScrollerPaddingExpanded) - .isEqualTo(mClockPosition.clockYFullyDozing); + .isEqualTo(mClockPosition.clockY); } @Test