Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +14 −0 Original line number Diff line number Diff line Loading @@ -1193,6 +1193,20 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd } } /** * Returns best effort count of visible notifications. */ public int getVisibleNotificationCount() { int count = 0; for (int i = 0; i < getChildCount(); i++) { final View child = getChildAt(i); if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) { count++; } } return count; } @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) private boolean isCurrentlyAnimating() { return mStateAnimator.isRunning(); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +16 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,16 @@ public class KeyguardClockPositionAlgorithm { */ private int mClockPreferredY; /** * 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. */ Loading Loading @@ -117,7 +127,7 @@ public class KeyguardClockPositionAlgorithm { public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight, float panelExpansion, int parentHeight, int keyguardStatusHeight, int clockPreferredY, float dark, float emptyDragAmount) { boolean hasCustomClock, boolean hasVisibleNotifs, float dark, float emptyDragAmount) { mMinTopMargin = minTopMargin + mContainerTopPadding; mMaxShadeBottom = maxShadeBottom; mNotificationStackHeight = notificationStackHeight; Loading @@ -125,6 +135,8 @@ public class KeyguardClockPositionAlgorithm { mHeight = parentHeight; mKeyguardStatusHeight = keyguardStatusHeight; mClockPreferredY = clockPreferredY; mHasCustomClock = hasCustomClock; mHasVisibleNotifs = hasVisibleNotifs; mDarkAmount = dark; mEmptyDragAmount = emptyDragAmount; } Loading Loading @@ -179,6 +191,9 @@ public class KeyguardClockPositionAlgorithm { clockYDark = MathUtils.max(0, clockYDark); float clockYRegular = getExpandedClockPosition(); if (mHasCustomClock && !mHasVisibleNotifs) { clockYRegular = clockYDark; } float clockYBouncer = -mKeyguardStatusHeight; // Move clock up while collapsing the shade Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +2 −0 Original line number Diff line number Diff line Loading @@ -637,6 +637,8 @@ public class NotificationPanelView extends PanelView implements totalHeight, mKeyguardStatusView.getHeight(), clockPreferredY, hasCustomClock(), mNotificationStackScroller.getVisibleNotificationCount() != 0, mInterpolatedDarkAmount, mEmptyDragAmount); mClockPositionAlgorithm.run(mClockPositionResult); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +76 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private static final float ZERO_DRAG = 0.f; private static final float OPAQUE = 1.f; private static final float TRANSPARENT = 0.f; private static final boolean HAS_CUSTOM_CLOCK = false; private static final boolean HAS_VISIBLE_NOTIFS = false; private KeyguardClockPositionAlgorithm mClockPositionAlgorithm; private KeyguardClockPositionAlgorithm.Result mClockPosition; Loading @@ -48,11 +50,18 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private float mPanelExpansion; private int mKeyguardStatusHeight; private float mDark; private int mPreferredClockY; private boolean mHasCustomClock; private boolean mHasVisibleNotifs; @Before public void setUp() { mClockPositionAlgorithm = new KeyguardClockPositionAlgorithm(); mClockPosition = new KeyguardClockPositionAlgorithm.Result(); mPreferredClockY = PREFERRED_CLOCK_Y; mHasCustomClock = HAS_CUSTOM_CLOCK; mHasVisibleNotifs = HAS_VISIBLE_NOTIFS; } @Test Loading Loading @@ -293,6 +302,71 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } @Test public void preferredCustomClockPositionNoNotifications() { // GIVEN on the lock screen with a custom clock and no visible notifications givenLockScreen(); mPreferredClockY = 100; mHasCustomClock = true; mHasVisibleNotifs = false; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the preferred Y position. assertThat(mClockPosition.clockY).isEqualTo(100); } @Test public void preferredDefaultClockPositionNoNotifications() { // GIVEN on the lock screen with a custom clock and no visible notifications givenLockScreen(); mPreferredClockY = 100; mHasCustomClock = false; mHasVisibleNotifs = false; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the middle of the screen (SCREEN_HEIGHT / 2) and not // preferred. assertThat(mClockPosition.clockY).isEqualTo(1000); } @Test public void preferredCustomClockPositionWithVisibleNotifications() { // GIVEN on the lock screen with a custom clock and visible notifications givenLockScreen(); mPreferredClockY = 100; mHasCustomClock = true; mHasVisibleNotifs = true; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the middle of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.clockY).isEqualTo(1000); } @Test public void preferredCustomClockPositionWithVisibleNotificationsOnAod() { // GIVEN on the lock screen with a custom clock and visible notifications givenAOD(); mPreferredClockY = 100; mHasCustomClock = true; mHasVisibleNotifs = true; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the preferred Y position. assertThat(mClockPosition.clockY).isEqualTo(100); } private void givenAOD() { mPanelExpansion = 1.f; mDark = 1.f; Loading @@ -305,8 +379,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private void positionClock() { mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight, mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, PREFERRED_CLOCK_Y, mDark, ZERO_DRAG); mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mPreferredClockY, mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG); mClockPositionAlgorithm.run(mClockPosition); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +14 −0 Original line number Diff line number Diff line Loading @@ -1193,6 +1193,20 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd } } /** * Returns best effort count of visible notifications. */ public int getVisibleNotificationCount() { int count = 0; for (int i = 0; i < getChildCount(); i++) { final View child = getChildAt(i); if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) { count++; } } return count; } @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) private boolean isCurrentlyAnimating() { return mStateAnimator.isRunning(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +16 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,16 @@ public class KeyguardClockPositionAlgorithm { */ private int mClockPreferredY; /** * 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. */ Loading Loading @@ -117,7 +127,7 @@ public class KeyguardClockPositionAlgorithm { public void setup(int minTopMargin, int maxShadeBottom, int notificationStackHeight, float panelExpansion, int parentHeight, int keyguardStatusHeight, int clockPreferredY, float dark, float emptyDragAmount) { boolean hasCustomClock, boolean hasVisibleNotifs, float dark, float emptyDragAmount) { mMinTopMargin = minTopMargin + mContainerTopPadding; mMaxShadeBottom = maxShadeBottom; mNotificationStackHeight = notificationStackHeight; Loading @@ -125,6 +135,8 @@ public class KeyguardClockPositionAlgorithm { mHeight = parentHeight; mKeyguardStatusHeight = keyguardStatusHeight; mClockPreferredY = clockPreferredY; mHasCustomClock = hasCustomClock; mHasVisibleNotifs = hasVisibleNotifs; mDarkAmount = dark; mEmptyDragAmount = emptyDragAmount; } Loading Loading @@ -179,6 +191,9 @@ public class KeyguardClockPositionAlgorithm { clockYDark = MathUtils.max(0, clockYDark); float clockYRegular = getExpandedClockPosition(); if (mHasCustomClock && !mHasVisibleNotifs) { clockYRegular = clockYDark; } float clockYBouncer = -mKeyguardStatusHeight; // Move clock up while collapsing the shade Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +2 −0 Original line number Diff line number Diff line Loading @@ -637,6 +637,8 @@ public class NotificationPanelView extends PanelView implements totalHeight, mKeyguardStatusView.getHeight(), clockPreferredY, hasCustomClock(), mNotificationStackScroller.getVisibleNotificationCount() != 0, mInterpolatedDarkAmount, mEmptyDragAmount); mClockPositionAlgorithm.run(mClockPositionResult); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +76 −2 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private static final float ZERO_DRAG = 0.f; private static final float OPAQUE = 1.f; private static final float TRANSPARENT = 0.f; private static final boolean HAS_CUSTOM_CLOCK = false; private static final boolean HAS_VISIBLE_NOTIFS = false; private KeyguardClockPositionAlgorithm mClockPositionAlgorithm; private KeyguardClockPositionAlgorithm.Result mClockPosition; Loading @@ -48,11 +50,18 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private float mPanelExpansion; private int mKeyguardStatusHeight; private float mDark; private int mPreferredClockY; private boolean mHasCustomClock; private boolean mHasVisibleNotifs; @Before public void setUp() { mClockPositionAlgorithm = new KeyguardClockPositionAlgorithm(); mClockPosition = new KeyguardClockPositionAlgorithm.Result(); mPreferredClockY = PREFERRED_CLOCK_Y; mHasCustomClock = HAS_CUSTOM_CLOCK; mHasVisibleNotifs = HAS_VISIBLE_NOTIFS; } @Test Loading Loading @@ -293,6 +302,71 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } @Test public void preferredCustomClockPositionNoNotifications() { // GIVEN on the lock screen with a custom clock and no visible notifications givenLockScreen(); mPreferredClockY = 100; mHasCustomClock = true; mHasVisibleNotifs = false; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the preferred Y position. assertThat(mClockPosition.clockY).isEqualTo(100); } @Test public void preferredDefaultClockPositionNoNotifications() { // GIVEN on the lock screen with a custom clock and no visible notifications givenLockScreen(); mPreferredClockY = 100; mHasCustomClock = false; mHasVisibleNotifs = false; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the middle of the screen (SCREEN_HEIGHT / 2) and not // preferred. assertThat(mClockPosition.clockY).isEqualTo(1000); } @Test public void preferredCustomClockPositionWithVisibleNotifications() { // GIVEN on the lock screen with a custom clock and visible notifications givenLockScreen(); mPreferredClockY = 100; mHasCustomClock = true; mHasVisibleNotifs = true; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the middle of the screen (SCREEN_HEIGHT / 2). assertThat(mClockPosition.clockY).isEqualTo(1000); } @Test public void preferredCustomClockPositionWithVisibleNotificationsOnAod() { // GIVEN on the lock screen with a custom clock and visible notifications givenAOD(); mPreferredClockY = 100; mHasCustomClock = true; mHasVisibleNotifs = true; // AND given empty height for clock and stack scroller mNotificationStackHeight = EMPTY_HEIGHT; mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the clock position algorithm is run positionClock(); // THEN the clock Y position is the preferred Y position. assertThat(mClockPosition.clockY).isEqualTo(100); } private void givenAOD() { mPanelExpansion = 1.f; mDark = 1.f; Loading @@ -305,8 +379,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private void positionClock() { mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight, mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, PREFERRED_CLOCK_Y, mDark, ZERO_DRAG); mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mPreferredClockY, mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG); mClockPositionAlgorithm.run(mClockPosition); } }