From 7d0f7fb747cd85091881759c8f274b8ddd2d64e9 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Wed, 22 Dec 2021 16:49:52 +0000 Subject: [PATCH 1/2] 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 --- .../phone/KeyguardClockPositionAlgorithm.java | 11 +++--- .../NotificationPanelViewController.java | 7 +++- .../KeyguardUserSwitcherController.java | 5 +++ .../KeyguardClockPositionAlgorithmTest.java | 37 +++++++++++++++++-- 4 files changed, 49 insertions(+), 11 deletions(-) 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 7ca8652e1b3c5..732e5f0343a22 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -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; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 5eb35ac74732b..33c4109b34266 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -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(), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java index 43b2061ecd32c..f83a97b9f6812 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java @@ -245,6 +245,11 @@ public class KeyguardUserSwitcherController extends ViewController Date: Thu, 23 Dec 2021 13:56:24 +0000 Subject: [PATCH 2/2] Fixing keyguard user switcher height after collapsing User switcher still had expanded flight after being collapsed - caused by all children views (of type KeyguardUserDetailItemView) still being visible but having alpha of 0. The function to make them GONE was called too early and with improper value, so they were never GONE. Fix is to make them VISIBLE before animating opening user switcher and make them GONE only after closing animation is finished. Fixes: 210121179 Test: open keyguard user switcher and close it -> views below should move back to their previous positions Change-Id: I76ea8651b19ef7ae931e6c14951d804a85c237ed --- .../policy/KeyguardUserSwitcherController.java | 1 - .../policy/KeyguardUserSwitcherListView.java | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java index f83a97b9f6812..8e4778e15de72 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java @@ -246,7 +246,6 @@ public class KeyguardUserSwitcherController extends ViewController