summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java78
4 files changed, 108 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 058cb2dbdbcf..ebda5852faea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -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();
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 0171d7f42aed..26e0a705aa5c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java
@@ -59,6 +59,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.
*/
private int mNotificationStackHeight;
@@ -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;
@@ -125,6 +135,8 @@ public class KeyguardClockPositionAlgorithm {
mHeight = parentHeight;
mKeyguardStatusHeight = keyguardStatusHeight;
mClockPreferredY = clockPreferredY;
+ mHasCustomClock = hasCustomClock;
+ mHasVisibleNotifs = hasVisibleNotifs;
mDarkAmount = dark;
mEmptyDragAmount = emptyDragAmount;
}
@@ -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
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 2207e0412949..c39a4941fdab 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -637,6 +637,8 @@ public class NotificationPanelView extends PanelView implements
totalHeight,
mKeyguardStatusView.getHeight(),
clockPreferredY,
+ hasCustomClock(),
+ mNotificationStackScroller.getVisibleNotificationCount() != 0,
mInterpolatedDarkAmount,
mEmptyDragAmount);
mClockPositionAlgorithm.run(mClockPositionResult);
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 93546488ad0a..f191cabbb3d9 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
@@ -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;
@@ -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
@@ -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;
@@ -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);
}
}