diff options
| author | Peter Kalauskas <peskal@google.com> | 2021-03-05 11:04:17 -0800 |
|---|---|---|
| committer | Peter Kalauskas <peskal@google.com> | 2021-03-08 08:17:53 -0800 |
| commit | 37e2f8d5d8fec50073b6ccb4ec3389e3e00a10fc (patch) | |
| tree | ac909f7c09237b9bc9d4ddc26da12e4951f8aaca | |
| parent | 13c2342861c6f62f4c2058ab06628b18f96b97fc (diff) | |
Fix animation bugs in keyguard user switcher
- Fix bug where user detail items disappeared too quickly when closing
the user switcher.
- Change input to clock position algorithm so that it no longer pushes
the clock down when the keyguard user switcher is used.
- Cleanup updateVisibilities() for readability
Bug: 181265906
Bug: 169783558
Test: Open and close keyguard user switcher
Change-Id: Ib83a5666ca548d78e39ac2a6d0ded6925bcadcb2
3 files changed, 38 insertions, 75 deletions
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 ae14fa943a4b..19b98953325f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1051,9 +1051,7 @@ public class NotificationPanelViewController extends PanelViewController { .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia(); mKeyguardStatusViewController.setHasVisibleNotifications(hasVisibleNotifications); int userIconHeight = mKeyguardQsUserSwitchController != null - ? mKeyguardQsUserSwitchController.getUserIconHeight() - : (mKeyguardUserSwitcherController != null - ? mKeyguardUserSwitcherController.getUserIconHeight() : 0); + ? mKeyguardQsUserSwitchController.getUserIconHeight() : 0; mClockPositionAlgorithm.setup(mStatusBarHeaderHeightKeyguard, totalHeight - bottomPadding, mNotificationStackScrollLayoutController.getIntrinsicContentHeight(), 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 5a80c05cc3cd..b473a613cbf2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherController.java @@ -322,14 +322,6 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS } /** - * Get the height of the keyguard user switcher view when closed. - */ - public int getUserIconHeight() { - View firstChild = mListView.getChildAt(0); - return firstChild == null ? 0 : firstChild.getHeight(); - } - - /** * Set the visibility of the keyguard user switcher view based on some new state. */ public void setKeyguardUserSwitcherVisibility( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherListView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherListView.java index 7c82c116eb3d..a815adfc9c9a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherListView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcherListView.java @@ -35,20 +35,22 @@ public class KeyguardUserSwitcherListView extends AlphaOptimizedLinearLayout { private static final String TAG = "KeyguardUserSwitcherListView"; private static final boolean DEBUG = KeyguardConstants.DEBUG; - private static final int ANIMATION_DURATION_OPENING = 360; - private static final int ANIMATION_DURATION_CLOSING = 240; - private boolean mAnimating; private final AppearAnimationUtils mAppearAnimationUtils; private final DisappearAnimationUtils mDisappearAnimationUtils; public KeyguardUserSwitcherListView(Context context, AttributeSet attrs) { super(context, attrs); - setClipChildren(false); - mAppearAnimationUtils = new AppearAnimationUtils(context, ANIMATION_DURATION_OPENING, - -0.5f, 0.5f, Interpolators.FAST_OUT_SLOW_IN); - mDisappearAnimationUtils = new DisappearAnimationUtils(context, ANIMATION_DURATION_CLOSING, - 0.5f, 0.5f, Interpolators.FAST_OUT_LINEAR_IN); + mAppearAnimationUtils = new AppearAnimationUtils(context, + AppearAnimationUtils.DEFAULT_APPEAR_DURATION, + -0.5f /* translationScaleFactor */, + 0.5f /* delayScaleFactor */, + Interpolators.FAST_OUT_SLOW_IN); + mDisappearAnimationUtils = new DisappearAnimationUtils(context, + AppearAnimationUtils.DEFAULT_APPEAR_DURATION, + 0.2f /* translationScaleFactor */, + 0.2f /* delayScaleFactor */, + Interpolators.FAST_OUT_SLOW_IN_REVERSE); } /** @@ -82,69 +84,40 @@ public class KeyguardUserSwitcherListView extends AlphaOptimizedLinearLayout { mAnimating = false; - int userListCount = getChildCount(); - if (userListCount > 0) { - // The first child is always the current user. - KeyguardUserDetailItemView currentUserView = ((KeyguardUserDetailItemView) getChildAt( - 0)); - currentUserView.updateVisibilities(true /* showItem */, open /* showTextName */, - animate); - currentUserView.setClickable(true); - currentUserView.clearAnimation(); - } - - if (userListCount <= 1) { - return; - } - - if (animate) { - // Create an array of all the remaining users (that aren't the current user). - KeyguardUserDetailItemView[] otherUserViews = - new KeyguardUserDetailItemView[userListCount - 1]; - for (int i = 1, n = 0; i < userListCount; i++, n++) { - otherUserViews[n] = (KeyguardUserDetailItemView) getChildAt(i); - + int childCount = getChildCount(); + KeyguardUserDetailItemView[] userItemViews = new KeyguardUserDetailItemView[childCount]; + for (int i = 0; i < childCount; i++) { + userItemViews[i] = (KeyguardUserDetailItemView) getChildAt(i); + userItemViews[i].clearAnimation(); + if (i == 0) { + // The first child is always the current user. + userItemViews[i].updateVisibilities(true /* showItem */, open /* showTextName */, + animate); + userItemViews[i].setClickable(true); + } else { // Update clickable state immediately so that the menu feels more responsive - otherUserViews[n].setClickable(open); - + userItemViews[i].setClickable(open); // Before running the animation, ensure visibility is set correctly - otherUserViews[n].updateVisibilities( - true /* showItem */, true /* showTextName */, false /* animate */); - otherUserViews[n].clearAnimation(); + userItemViews[i].updateVisibilities(animate || open /* showItem */, + true /* showTextName */, false /* animate */); } + } + + if (animate) { + // AnimationUtils will immediately hide/show the first item in the array. Since the + // first view is the current user, we want to manage its visibility separately. + // Set first item to null so AnimationUtils ignores it. + userItemViews[0] = null; setClipChildren(false); setClipToPadding(false); - mAnimating = true; - - final int nonCurrentUserCount = otherUserViews.length; - if (open) { - mAppearAnimationUtils.startAnimation(otherUserViews, () -> { - setClipChildren(true); - setClipToPadding(true); - mAnimating = false; - }); - } else { - mDisappearAnimationUtils.startAnimation(otherUserViews, () -> { - setClipChildren(true); - setClipToPadding(true); - for (int i = 0; i < nonCurrentUserCount; i++) { - otherUserViews[i].updateVisibilities( - false /* showItem */, true /* showTextName */, false /* animate */); - } - mAnimating = false; - }); - } - } else { - for (int i = 1; i < userListCount; i++) { - KeyguardUserDetailItemView nonCurrentUserView = - ((KeyguardUserDetailItemView) getChildAt(i)); - nonCurrentUserView.clearAnimation(); - nonCurrentUserView.updateVisibilities( - open /* showItem */, true /* showTextName */, false /* animate */); - nonCurrentUserView.setClickable(open); - } + (open ? mAppearAnimationUtils : mDisappearAnimationUtils) + .startAnimation(userItemViews, () -> { + setClipChildren(true); + setClipToPadding(true); + mAnimating = false; + }); } } |
