Merge changes I76ea8651,I76a84b4f into sc-v2-dev

* changes:
  Fixing keyguard user switcher height after collapsing
  Accounting for user switcher on split shade lock screen
This commit is contained in:
Michał Brzeziński
2022-01-04 13:45:27 +00:00
committed by Android (Google) Code Review
5 changed files with 61 additions and 14 deletions

View File

@@ -57,8 +57,7 @@ public class KeyguardClockPositionAlgorithm {
private int mUserSwitchPreferredY; private int mUserSwitchPreferredY;
/** /**
* Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher * Minimum top margin to avoid overlap with status bar or multi-user switcher avatar.
* avatar.
*/ */
private int mMinTopMargin; private int mMinTopMargin;
@@ -203,7 +202,7 @@ public class KeyguardClockPositionAlgorithm {
if (mBypassEnabled) { if (mBypassEnabled) {
return mUnlockedStackScrollerPadding; return mUnlockedStackScrollerPadding;
} else if (mIsSplitShade) { } else if (mIsSplitShade) {
return getClockY(1.0f, mDarkAmount); return getClockY(1.0f, mDarkAmount) + mUserSwitchHeight;
} else { } else {
return getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight; return getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight;
} }
@@ -213,7 +212,7 @@ public class KeyguardClockPositionAlgorithm {
if (mBypassEnabled) { if (mBypassEnabled) {
return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount); return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount);
} else if (mIsSplitShade) { } else if (mIsSplitShade) {
return Math.max(0, clockYPosition - mSplitShadeTopNotificationsMargin); return clockYPosition - mSplitShadeTopNotificationsMargin + mUserSwitchHeight;
} else { } else {
return clockYPosition + mKeyguardStatusHeight; return clockYPosition + mKeyguardStatusHeight;
} }
@@ -223,7 +222,7 @@ public class KeyguardClockPositionAlgorithm {
if (mBypassEnabled) { if (mBypassEnabled) {
return mUnlockedStackScrollerPadding; return mUnlockedStackScrollerPadding;
} else if (mIsSplitShade) { } else if (mIsSplitShade) {
return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin); return mSplitShadeTargetTopMargin + mUserSwitchHeight;
} else { } else {
return mMinTopMargin + mKeyguardStatusHeight; return mMinTopMargin + mKeyguardStatusHeight;
} }
@@ -231,7 +230,7 @@ public class KeyguardClockPositionAlgorithm {
private int getExpandedPreferredClockY() { private int getExpandedPreferredClockY() {
if (mIsSplitShade) { if (mIsSplitShade) {
return Math.max(mSplitShadeTargetTopMargin, mMinTopMargin); return mSplitShadeTargetTopMargin;
} else { } else {
return mMinTopMargin; return mMinTopMargin;
} }

View File

@@ -1303,8 +1303,11 @@ public class NotificationPanelViewController extends PanelViewController {
mKeyguardStatusViewController.displayClock(LARGE); mKeyguardStatusViewController.displayClock(LARGE);
} }
updateKeyguardStatusViewAlignment(true /* animate */); updateKeyguardStatusViewAlignment(true /* animate */);
int userIconHeight = mKeyguardQsUserSwitchController != null int userSwitcherHeight = mKeyguardQsUserSwitchController != null
? mKeyguardQsUserSwitchController.getUserIconHeight() : 0; ? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
if (mKeyguardUserSwitcherController != null) {
userSwitcherHeight = mKeyguardUserSwitcherController.getHeight();
}
float expandedFraction = float expandedFraction =
mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying() mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
? 1.0f : getExpandedFraction(); ? 1.0f : getExpandedFraction();
@@ -1324,7 +1327,7 @@ public class NotificationPanelViewController extends PanelViewController {
mStatusBarHeaderHeightKeyguard, mStatusBarHeaderHeightKeyguard,
expandedFraction, expandedFraction,
mKeyguardStatusViewController.getLockscreenHeight(), mKeyguardStatusViewController.getLockscreenHeight(),
userIconHeight, userSwitcherHeight,
userSwitcherPreferredY, userSwitcherPreferredY,
darkamount, mOverStretchAmount, darkamount, mOverStretchAmount,
bypassEnabled, getUnlockedStackScrollerPadding(), bypassEnabled, getUnlockedStackScrollerPadding(),

View File

@@ -245,6 +245,10 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS
return mUserSwitcherController.isSimpleUserSwitcher(); return mUserSwitcherController.isSimpleUserSwitcher();
} }
public int getHeight() {
return mListView.getHeight();
}
/** /**
* @param animate if the transition should be animated * @param animate if the transition should be animated
* @return true if the switcher state changed * @return true if the switcher state changed

View File

@@ -97,9 +97,12 @@ public class KeyguardUserSwitcherListView extends AlphaOptimizedLinearLayout {
} else { } else {
// Update clickable state immediately so that the menu feels more responsive // Update clickable state immediately so that the menu feels more responsive
userItemViews[i].setClickable(open); userItemViews[i].setClickable(open);
// Before running the animation, ensure visibility is set correctly // when opening we need to make views visible beforehand so they can be animated
userItemViews[i].updateVisibilities(animate || open /* showItem */, if (open) {
true /* showTextName */, false /* animate */); userItemViews[i].updateVisibilities(true /* showItem */,
true /* showTextName */, false /* animate */);
}
} }
} }
@@ -117,6 +120,13 @@ public class KeyguardUserSwitcherListView extends AlphaOptimizedLinearLayout {
setClipChildren(true); setClipChildren(true);
setClipToPadding(true); setClipToPadding(true);
mAnimating = false; mAnimating = false;
if (!open) {
// after closing we hide children so that height of this view is correct
for (int i = 1; i < userItemViews.length; i++) {
userItemViews[i].updateVisibilities(false /* showItem */,
true /* showTextName */, false /* animate */);
}
}
}); });
} }
} }

View File

@@ -62,6 +62,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
private float mPanelExpansion; private float mPanelExpansion;
private int mKeyguardStatusBarHeaderHeight; private int mKeyguardStatusBarHeaderHeight;
private int mKeyguardStatusHeight; private int mKeyguardStatusHeight;
private int mUserSwitchHeight;
private float mDark; private float mDark;
private float mQsExpansion; private float mQsExpansion;
private int mCutoutTopInset = 0; private int mCutoutTopInset = 0;
@@ -264,8 +265,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
@Test @Test
public void clockPositionedDependingOnMarginInSplitShade() { public void clockPositionedDependingOnMarginInSplitShade() {
when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) setSplitShadeTopMargin(400);
.thenReturn(400);
mClockPositionAlgorithm.loadDimens(mResources); mClockPositionAlgorithm.loadDimens(mResources);
givenLockScreen(); givenLockScreen();
mIsSplitShade = true; mIsSplitShade = true;
@@ -290,6 +290,32 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(30); 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 @Test
public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() { public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() {
givenLockScreen(); givenLockScreen();
@@ -495,6 +521,11 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
assertThat(mClockPosition.clockY).isEqualTo(mCutoutTopInset); 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() { private void givenHighestBurnInOffset() {
when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).then(returnsFirstArg()); when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).then(returnsFirstArg());
} }
@@ -529,7 +560,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
mKeyguardStatusBarHeaderHeight, mKeyguardStatusBarHeaderHeight,
mPanelExpansion, mPanelExpansion,
mKeyguardStatusHeight, mKeyguardStatusHeight,
0 /* userSwitchHeight */, mUserSwitchHeight,
0 /* userSwitchPreferredY */, 0 /* userSwitchPreferredY */,
mDark, mDark,
ZERO_DRAG, ZERO_DRAG,