Merge "Don't slide down "At a Glance" when notifs aren't visible." into qt-dev

am: de058b8e1b

Change-Id: If0fec20eafe23998ddc017b0490da66cc40a3638
This commit is contained in:
Robert Snoeberger
2019-04-22 11:46:52 -07:00
committed by android-build-merger
4 changed files with 108 additions and 3 deletions

View File

@@ -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();

View File

@@ -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.
*/
@@ -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

View File

@@ -637,6 +637,8 @@ public class NotificationPanelView extends PanelView implements
totalHeight,
mKeyguardStatusView.getHeight(),
clockPreferredY,
hasCustomClock(),
mNotificationStackScroller.getVisibleNotificationCount() != 0,
mInterpolatedDarkAmount,
mEmptyDragAmount);
mClockPositionAlgorithm.run(mClockPositionResult);

View File

@@ -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);
}
}