Merge "Cleaning up KeyguardClockPositionAlgorithm and its tests" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
efa4aca7d3
@@ -1148,7 +1148,7 @@
|
||||
|
||||
<!-- The maximum offset in either direction that elements are moved vertically to prevent
|
||||
burn-in on AOD. -->
|
||||
<dimen name="burn_in_prevention_offset_y_large_clock">42dp</dimen>
|
||||
<dimen name="burn_in_prevention_offset_y_clock">42dp</dimen>
|
||||
|
||||
<!-- Clock maximum font size (dp is intentional, to prevent any further scaling) -->
|
||||
<dimen name="large_clock_text_size">150dp</dimen>
|
||||
|
||||
@@ -32,23 +32,12 @@ import com.android.systemui.statusbar.policy.KeyguardUserSwitcherListView;
|
||||
* Utility class to calculate the clock position and top padding of notifications on Keyguard.
|
||||
*/
|
||||
public class KeyguardClockPositionAlgorithm {
|
||||
/**
|
||||
* How much the clock height influences the shade position.
|
||||
* 0 means nothing, 1 means move the shade up by the height of the clock
|
||||
* 0.5f means move the shade up by half of the size of the clock.
|
||||
*/
|
||||
private static float CLOCK_HEIGHT_WEIGHT = 0.7f;
|
||||
|
||||
/**
|
||||
* Margin between the bottom of the status view and the notification shade.
|
||||
*/
|
||||
private int mStatusViewBottomMargin;
|
||||
|
||||
/**
|
||||
* Height of the parent view - display size in px.
|
||||
*/
|
||||
private int mHeight;
|
||||
|
||||
/**
|
||||
* Height of {@link KeyguardStatusView}.
|
||||
*/
|
||||
@@ -67,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.
|
||||
@@ -93,12 +67,6 @@ public class KeyguardClockPositionAlgorithm {
|
||||
*/
|
||||
private int mCutoutTopInset = 0;
|
||||
|
||||
/**
|
||||
* Maximum bottom padding to avoid overlap with {@link KeyguardBottomAreaView} or
|
||||
* the ambient indication.
|
||||
*/
|
||||
private int mMaxShadeBottom;
|
||||
|
||||
/**
|
||||
* Recommended distance from the status bar.
|
||||
*/
|
||||
@@ -115,14 +83,9 @@ public class KeyguardClockPositionAlgorithm {
|
||||
private int mBurnInPreventionOffsetX;
|
||||
|
||||
/**
|
||||
* Burn-in prevention y translation.
|
||||
* Burn-in prevention y translation for clock layouts.
|
||||
*/
|
||||
private int mBurnInPreventionOffsetY;
|
||||
|
||||
/**
|
||||
* Burn-in prevention y translation for large clock layouts.
|
||||
*/
|
||||
private int mBurnInPreventionOffsetYLargeClock;
|
||||
private int mBurnInPreventionOffsetYClock;
|
||||
|
||||
/**
|
||||
* Doze/AOD transition amount.
|
||||
@@ -160,34 +123,26 @@ public class KeyguardClockPositionAlgorithm {
|
||||
res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) / 2;
|
||||
mBurnInPreventionOffsetX = res.getDimensionPixelSize(
|
||||
R.dimen.burn_in_prevention_offset_x);
|
||||
mBurnInPreventionOffsetY = res.getDimensionPixelSize(
|
||||
R.dimen.burn_in_prevention_offset_y);
|
||||
mBurnInPreventionOffsetYLargeClock = res.getDimensionPixelSize(
|
||||
R.dimen.burn_in_prevention_offset_y_large_clock);
|
||||
mBurnInPreventionOffsetYClock = res.getDimensionPixelSize(
|
||||
R.dimen.burn_in_prevention_offset_y_clock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up algorithm values.
|
||||
*/
|
||||
public void setup(int keyguardStatusBarHeaderHeight, int maxShadeBottom,
|
||||
int notificationStackHeight, float panelExpansion, int parentHeight,
|
||||
public void setup(int keyguardStatusBarHeaderHeight, float panelExpansion,
|
||||
int keyguardStatusHeight, int userSwitchHeight, int userSwitchPreferredY,
|
||||
boolean hasCustomClock, boolean hasVisibleNotifs, float dark,
|
||||
float overStrechAmount, boolean bypassEnabled, int unlockedStackScrollerPadding,
|
||||
float qsExpansion, int cutoutTopInset, boolean isSplitShade) {
|
||||
float dark, float overStretchAmount, boolean bypassEnabled,
|
||||
int unlockedStackScrollerPadding, float qsExpansion, int cutoutTopInset,
|
||||
boolean isSplitShade) {
|
||||
mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding,
|
||||
userSwitchHeight);
|
||||
mMaxShadeBottom = maxShadeBottom;
|
||||
mNotificationStackHeight = notificationStackHeight;
|
||||
mPanelExpansion = panelExpansion;
|
||||
mHeight = parentHeight;
|
||||
mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin;
|
||||
mUserSwitchHeight = userSwitchHeight;
|
||||
mUserSwitchPreferredY = userSwitchPreferredY;
|
||||
mHasCustomClock = hasCustomClock;
|
||||
mHasVisibleNotifs = hasVisibleNotifs;
|
||||
mDarkAmount = dark;
|
||||
mOverStretchAmount = overStrechAmount;
|
||||
mOverStretchAmount = overStretchAmount;
|
||||
mBypassEnabled = bypassEnabled;
|
||||
mUnlockedStackScrollerPadding = unlockedStackScrollerPadding;
|
||||
mQsExpansion = qsExpansion;
|
||||
@@ -244,8 +199,8 @@ public class KeyguardClockPositionAlgorithm {
|
||||
|
||||
// This will keep the clock at the top but out of the cutout area
|
||||
float shift = 0;
|
||||
if (clockY - mBurnInPreventionOffsetYLargeClock < mCutoutTopInset) {
|
||||
shift = mCutoutTopInset - (clockY - mBurnInPreventionOffsetYLargeClock);
|
||||
if (clockY - mBurnInPreventionOffsetYClock < mCutoutTopInset) {
|
||||
shift = mCutoutTopInset - (clockY - mBurnInPreventionOffsetYClock);
|
||||
}
|
||||
float clockYDark = clockY + burnInPreventionOffsetY() + shift;
|
||||
|
||||
@@ -281,7 +236,7 @@ public class KeyguardClockPositionAlgorithm {
|
||||
}
|
||||
|
||||
private float burnInPreventionOffsetY() {
|
||||
int offset = mBurnInPreventionOffsetYLargeClock;
|
||||
int offset = mBurnInPreventionOffsetYClock;
|
||||
|
||||
return getBurnInOffset(offset * 2, false /* xAxis */) - offset;
|
||||
}
|
||||
|
||||
@@ -1317,8 +1317,6 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
}
|
||||
|
||||
private void updateClockAppearance() {
|
||||
int totalHeight = mView.getHeight();
|
||||
int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding);
|
||||
int userSwitcherPreferredY = mStatusBarHeaderHeightKeyguard;
|
||||
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
|
||||
final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
||||
@@ -1339,14 +1337,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
|
||||
? 1.0f : mInterpolatedDarkAmount;
|
||||
mClockPositionAlgorithm.setup(mStatusBarHeaderHeightKeyguard,
|
||||
totalHeight - bottomPadding,
|
||||
mNotificationStackScrollLayoutController.getIntrinsicContentHeight(),
|
||||
expandedFraction,
|
||||
totalHeight,
|
||||
mKeyguardStatusViewController.getLockscreenHeight(),
|
||||
userIconHeight,
|
||||
userSwitcherPreferredY, hasCustomClock(),
|
||||
hasVisibleNotifications, darkamount, mOverStretchAmount,
|
||||
userSwitcherPreferredY,
|
||||
darkamount, mOverStretchAmount,
|
||||
bypassEnabled, getUnlockedStackScrollerPadding(),
|
||||
computeQsExpansionFraction(),
|
||||
mDisplayTopInset,
|
||||
|
||||
@@ -31,42 +31,31 @@ import org.junit.runner.RunWith;
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
|
||||
private static final int SCREEN_HEIGHT = 2000;
|
||||
private static final int EMPTY_MARGIN = 0;
|
||||
private static final int EMPTY_HEIGHT = 0;
|
||||
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;
|
||||
private int mNotificationStackHeight;
|
||||
private float mPanelExpansion;
|
||||
private int mKeyguardStatusHeight;
|
||||
private float mDark;
|
||||
private boolean mHasCustomClock;
|
||||
private boolean mHasVisibleNotifs;
|
||||
private float mQsExpansion;
|
||||
private int mCutoutTopInset = 0; // in pixels
|
||||
private int mCutoutTopInsetPx = 0;
|
||||
private boolean mIsSplitShade = false;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mClockPositionAlgorithm = new KeyguardClockPositionAlgorithm();
|
||||
mClockPosition = new KeyguardClockPositionAlgorithm.Result();
|
||||
|
||||
mHasCustomClock = HAS_CUSTOM_CLOCK;
|
||||
mHasVisibleNotifs = HAS_VISIBLE_NOTIFS;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clockPositionTopOfScreenOnAOD() {
|
||||
// GIVEN on AOD and both stack scroll and clock have 0 height
|
||||
// GIVEN on AOD and clock has 0 height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
@@ -79,11 +68,10 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void clockPositionBelowCutout() {
|
||||
// GIVEN on AOD and both stack scroll and clock have 0 height
|
||||
// GIVEN on AOD and clock has 0 height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mCutoutTopInset = 300;
|
||||
mCutoutTopInsetPx = 300;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the clock Y position is below the cutout
|
||||
@@ -97,7 +85,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void clockPositionAdjustsForKeyguardStatusOnAOD() {
|
||||
// GIVEN on AOD with a clock of height 100
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = 100;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
@@ -112,7 +99,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void clockPositionLargeClockOnAOD() {
|
||||
// GIVEN on AOD with a full screen clock
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
@@ -125,9 +111,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void clockPositionTopOfScreenOnLockScreen() {
|
||||
// GIVEN on lock screen with stack scroll and clock of 0 height
|
||||
// GIVEN on lock screen with clock of 0 height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
@@ -137,25 +122,10 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
assertThat(mClockPosition.clockX).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clockPositionWithStackScrollExpandOnLockScreen() {
|
||||
// GIVEN on lock screen with stack scroll of height 500
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = 500;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the clock Y position stays to the top
|
||||
assertThat(mClockPosition.clockY).isEqualTo(0);
|
||||
// AND the clock is positioned on the left.
|
||||
assertThat(mClockPosition.clockX).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clockPositionWithPartialDragOnLockScreen() {
|
||||
// GIVEN dragging up on lock screen
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mPanelExpansion = 0.5f;
|
||||
// WHEN the clock position algorithm is run
|
||||
@@ -171,7 +141,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void clockPositionWithFullDragOnLockScreen() {
|
||||
// GIVEN the lock screen is dragged up
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mPanelExpansion = 0.f;
|
||||
// WHEN the clock position algorithm is run
|
||||
@@ -184,7 +153,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void largeClockOnLockScreenIsTransparent() {
|
||||
// GIVEN on lock screen with a full screen clock
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
@@ -194,9 +162,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void notifPositionTopOfScreenOnAOD() {
|
||||
// GIVEN on AOD and both stack scroll and clock have 0 height
|
||||
// GIVEN on AOD and clock has 0 height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
@@ -208,7 +175,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() {
|
||||
// GIVEN on AOD and clock has a nonzero height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = 100;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
@@ -220,7 +186,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void notifPositionWithLargeClockOnAOD() {
|
||||
// GIVEN on AOD and clock has a nonzero height
|
||||
givenAOD();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
@@ -230,9 +195,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void notifPositionMiddleOfScreenOnLockScreen() {
|
||||
// GIVEN on lock screen and both stack scroll and clock have 0 height
|
||||
// GIVEN on lock screen and clock has 0 height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
@@ -240,48 +204,21 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAdjustsForStackHeightOnLockScreen() {
|
||||
// GIVEN on lock screen and stack scroller has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = 500;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding adjusts for keyguard status height
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAdjustsForClockHeightOnLockScreen() {
|
||||
// GIVEN on lock screen and stack scroller has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = 200;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding adjusts for both clock and notif stack.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAdjustsForStackHeightAndClockHeightOnLockScreen() {
|
||||
// GIVEN on lock screen and stack scroller has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = 500;
|
||||
mKeyguardStatusHeight = 200;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notifs are placed below the statusview
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPositionAlignedWithClockInSplitShadeMode() {
|
||||
// GIVEN on lock screen and split shade mode
|
||||
givenLockScreen();
|
||||
mIsSplitShade = true;
|
||||
mHasCustomClock = true;
|
||||
mKeyguardStatusHeight = 200;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding DOESN'T adjust for keyguard status height.
|
||||
@@ -292,7 +229,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void notifPositionWithLargeClockOnLockScreen() {
|
||||
// GIVEN on lock screen and clock has a nonzero height
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
@@ -304,7 +240,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void notifPositionWithFullDragOnLockScreen() {
|
||||
// GIVEN the lock screen is dragged up
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = EMPTY_HEIGHT;
|
||||
mPanelExpansion = 0.f;
|
||||
// WHEN the clock position algorithm is run
|
||||
@@ -317,19 +252,17 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
public void notifPositionWithLargeClockFullDragOnLockScreen() {
|
||||
// GIVEN the lock screen is dragged up and a full screen clock
|
||||
givenLockScreen();
|
||||
mNotificationStackHeight = EMPTY_HEIGHT;
|
||||
mKeyguardStatusHeight = SCREEN_HEIGHT;
|
||||
mPanelExpansion = 0.f;
|
||||
// WHEN the clock position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is zero.
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(
|
||||
(int) (mKeyguardStatusHeight * .667f));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clockHiddenWhenQsIsExpanded() {
|
||||
// GIVEN on the lock screen with a custom clock and visible notifications
|
||||
// GIVEN on the lock screen with visible notifications
|
||||
givenLockScreen();
|
||||
mQsExpansion = 1;
|
||||
// WHEN the clock position algorithm is run
|
||||
@@ -349,12 +282,11 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
private void positionClock() {
|
||||
mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight,
|
||||
mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight,
|
||||
mClockPositionAlgorithm.setup(EMPTY_MARGIN, mPanelExpansion, mKeyguardStatusHeight,
|
||||
0 /* userSwitchHeight */, 0 /* userSwitchPreferredY */,
|
||||
mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG, false /* bypassEnabled */,
|
||||
mDark, ZERO_DRAG, false /* bypassEnabled */,
|
||||
0 /* unlockedStackScrollerPadding */, mQsExpansion,
|
||||
mCutoutTopInset, mIsSplitShade);
|
||||
mCutoutTopInsetPx, mIsSplitShade);
|
||||
mClockPositionAlgorithm.run(mClockPosition);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user