Accounting for user switcher on split shade lock screen
Adjusting KeyguardClockPositionAlgorithm so it properly positions elements when user switcher is visible - moving notifications down and keeping clock at the same place. Also actually passing height of old user switcher (compared to new QS user switcher) to the algorithm. Bug: 210121179 Test: KeyguardClockPositionAlgorithmTest + manual Change-Id: I76a84b4f2eca76981cc69a7a1163709a7e8d516c
This commit is contained in:
@@ -57,8 +57,7 @@ public class KeyguardClockPositionAlgorithm {
|
||||
private int mUserSwitchPreferredY;
|
||||
|
||||
/**
|
||||
* Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher
|
||||
* avatar.
|
||||
* Minimum top margin to avoid overlap with status bar or multi-user switcher avatar.
|
||||
*/
|
||||
private int mMinTopMargin;
|
||||
|
||||
@@ -203,7 +202,7 @@ public class KeyguardClockPositionAlgorithm {
|
||||
if (mBypassEnabled) {
|
||||
return mUnlockedStackScrollerPadding;
|
||||
} else if (mIsSplitShade) {
|
||||
return getClockY(1.0f, mDarkAmount);
|
||||
return getClockY(1.0f, mDarkAmount) + mUserSwitchHeight;
|
||||
} else {
|
||||
return getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight;
|
||||
}
|
||||
@@ -213,7 +212,7 @@ public class KeyguardClockPositionAlgorithm {
|
||||
if (mBypassEnabled) {
|
||||
return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount);
|
||||
} else if (mIsSplitShade) {
|
||||
return Math.max(0, clockYPosition - mSplitShadeTopNotificationsMargin);
|
||||
return clockYPosition - mSplitShadeTopNotificationsMargin + mUserSwitchHeight;
|
||||
} else {
|
||||
return clockYPosition + mKeyguardStatusHeight;
|
||||
}
|
||||
@@ -223,7 +222,7 @@ public class KeyguardClockPositionAlgorithm {
|
||||
if (mBypassEnabled) {
|
||||
return mUnlockedStackScrollerPadding;
|
||||
} else if (mIsSplitShade) {
|
||||
return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin);
|
||||
return mSplitShadeTargetTopMargin + mUserSwitchHeight;
|
||||
} else {
|
||||
return mMinTopMargin + mKeyguardStatusHeight;
|
||||
}
|
||||
@@ -231,7 +230,7 @@ public class KeyguardClockPositionAlgorithm {
|
||||
|
||||
private int getExpandedPreferredClockY() {
|
||||
if (mIsSplitShade) {
|
||||
return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin);
|
||||
return mSplitShadeTargetTopMargin;
|
||||
} else {
|
||||
return mMinTopMargin;
|
||||
}
|
||||
|
||||
@@ -1303,8 +1303,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mKeyguardStatusViewController.displayClock(LARGE);
|
||||
}
|
||||
updateKeyguardStatusViewAlignment(true /* animate */);
|
||||
int userIconHeight = mKeyguardQsUserSwitchController != null
|
||||
int userSwitcherHeight = mKeyguardQsUserSwitchController != null
|
||||
? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
|
||||
if (mKeyguardUserSwitcherController != null) {
|
||||
userSwitcherHeight = mKeyguardUserSwitcherController.getHeight();
|
||||
}
|
||||
float expandedFraction =
|
||||
mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
|
||||
? 1.0f : getExpandedFraction();
|
||||
@@ -1324,7 +1327,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
mStatusBarHeaderHeightKeyguard,
|
||||
expandedFraction,
|
||||
mKeyguardStatusViewController.getLockscreenHeight(),
|
||||
userIconHeight,
|
||||
userSwitcherHeight,
|
||||
userSwitcherPreferredY,
|
||||
darkamount, mOverStretchAmount,
|
||||
bypassEnabled, getUnlockedStackScrollerPadding(),
|
||||
|
||||
@@ -245,6 +245,11 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS
|
||||
return mUserSwitcherController.isSimpleUserSwitcher();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
// TODO(brzezinski): fix height value when user switcher is back to collapsed
|
||||
return mListView.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param animate if the transition should be animated
|
||||
* @return true if the switcher state changed
|
||||
|
||||
@@ -62,6 +62,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
private float mPanelExpansion;
|
||||
private int mKeyguardStatusBarHeaderHeight;
|
||||
private int mKeyguardStatusHeight;
|
||||
private int mUserSwitchHeight;
|
||||
private float mDark;
|
||||
private float mQsExpansion;
|
||||
private int mCutoutTopInset = 0;
|
||||
@@ -264,8 +265,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void clockPositionedDependingOnMarginInSplitShade() {
|
||||
when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin))
|
||||
.thenReturn(400);
|
||||
setSplitShadeTopMargin(400);
|
||||
mClockPositionAlgorithm.loadDimens(mResources);
|
||||
givenLockScreen();
|
||||
mIsSplitShade = true;
|
||||
@@ -290,6 +290,32 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(30);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPaddingAccountsForMultiUserSwitcherInSplitShade() {
|
||||
setSplitShadeTopMargin(100);
|
||||
mUserSwitchHeight = 150;
|
||||
mClockPositionAlgorithm.loadDimens(mResources);
|
||||
givenLockScreen();
|
||||
mIsSplitShade = true;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN the notif padding is split shade top margin + user switch height
|
||||
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(250);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clockDoesntAccountForMultiUserSwitcherInSplitShade() {
|
||||
setSplitShadeTopMargin(100);
|
||||
mUserSwitchHeight = 150;
|
||||
mClockPositionAlgorithm.loadDimens(mResources);
|
||||
givenLockScreen();
|
||||
mIsSplitShade = true;
|
||||
// WHEN the position algorithm is run
|
||||
positionClock();
|
||||
// THEN clockY = split shade top margin
|
||||
assertThat(mClockPosition.clockY).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() {
|
||||
givenLockScreen();
|
||||
@@ -495,6 +521,11 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
assertThat(mClockPosition.clockY).isEqualTo(mCutoutTopInset);
|
||||
}
|
||||
|
||||
private void setSplitShadeTopMargin(int value) {
|
||||
when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin))
|
||||
.thenReturn(value);
|
||||
}
|
||||
|
||||
private void givenHighestBurnInOffset() {
|
||||
when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).then(returnsFirstArg());
|
||||
}
|
||||
@@ -529,7 +560,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
|
||||
mKeyguardStatusBarHeaderHeight,
|
||||
mPanelExpansion,
|
||||
mKeyguardStatusHeight,
|
||||
0 /* userSwitchHeight */,
|
||||
mUserSwitchHeight,
|
||||
0 /* userSwitchPreferredY */,
|
||||
mDark,
|
||||
ZERO_DRAG,
|
||||
|
||||
Reference in New Issue
Block a user