From 146ab3cc339a50c7eba79c5a4ff9b9980767406d Mon Sep 17 00:00:00 2001 From: Robert Snoeberger Date: Thu, 13 Jun 2019 14:12:10 -0400 Subject: [PATCH] Remove the custom clock from LS during transition from AOD Fixes: 132273216 Test: visual -- transition to AOD with notifications Test: visual -- transition to AOD without notifications Test: visual -- remove last notification on LS Test: visual -- add notification on LS Change-Id: I1c003a8930cc557e388e2263e4a4fa41b912998a --- .../android/keyguard/KeyguardClockSwitch.java | 36 +++++++++++++++++++ .../android/keyguard/KeyguardStatusView.java | 7 ++++ .../phone/NotificationPanelView.java | 5 ++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index 3da969c8542e6..57bcd776177cb 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -9,6 +9,7 @@ import android.content.Context; import android.graphics.Paint; import android.graphics.Paint.Style; import android.os.Build; +import android.transition.Fade; import android.transition.Transition; import android.transition.TransitionListenerAdapter; import android.transition.TransitionManager; @@ -115,6 +116,11 @@ public class KeyguardClockSwitch extends RelativeLayout { */ private float mDarkAmount; + /** + * Boolean value indicating if notifications are visible on lock screen. + */ + private boolean mHasVisibleNotifications; + /** * If the Keyguard Slice has a header (big center-aligned text.) */ @@ -320,6 +326,24 @@ public class KeyguardClockSwitch extends RelativeLayout { if (mClockPlugin != null) { mClockPlugin.setDarkAmount(darkAmount); } + updateBigClockAlpha(); + } + + /** + * Set whether or not the lock screen is showing notifications. + */ + void setHasVisibleNotifications(boolean hasVisibleNotifications) { + if (hasVisibleNotifications == mHasVisibleNotifications) { + return; + } + mHasVisibleNotifications = hasVisibleNotifications; + if (mDarkAmount == 0f && mBigClockContainer != null) { + // Starting a fade transition since the visibility of the big clock will change. + TransitionManager.beginDelayedTransition(mBigClockContainer, + new Fade().setDuration(KeyguardSliceView.DEFAULT_ANIM_DURATION / 2).addTarget( + mBigClockContainer)); + } + updateBigClockAlpha(); } public Paint getPaint() { @@ -396,6 +420,18 @@ public class KeyguardClockSwitch extends RelativeLayout { } } + private void updateBigClockAlpha() { + if (mBigClockContainer != null) { + final float alpha = mHasVisibleNotifications ? mDarkAmount : 1f; + mBigClockContainer.setAlpha(alpha); + if (alpha == 0f) { + mBigClockContainer.setVisibility(INVISIBLE); + } else if (mBigClockContainer.getVisibility() == INVISIBLE) { + mBigClockContainer.setVisibility(VISIBLE); + } + } + } + /** * Sets if the keyguard slice is showing a center-aligned header. We need a smaller clock in * these cases. diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java index e7923d87a582e..37e89c0955758 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java @@ -145,6 +145,13 @@ public class KeyguardStatusView extends GridLayout implements return mClockView.hasCustomClock(); } + /** + * Set whether or not the lock screen is showing notifications. + */ + public void setHasVisibleNotifications(boolean hasVisibleNotifications) { + mClockView.setHasVisibleNotifications(hasVisibleNotifications); + } + private void setEnableMarquee(boolean enabled) { if (DEBUG) Log.v(TAG, "Schedule setEnableMarquee: " + (enabled ? "Enable" : "Disable")); if (enabled) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index e805575e38846..7ebcdca75f82b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -710,6 +710,9 @@ public class NotificationPanelView extends PanelView implements int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding); int clockPreferredY = mKeyguardStatusView.getClockPreferredY(totalHeight); boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled(); + final boolean hasVisibleNotifications = + !bypassEnabled && mNotificationStackScroller.getVisibleNotificationCount() != 0; + mKeyguardStatusView.setHasVisibleNotifications(hasVisibleNotifications); mClockPositionAlgorithm.setup( mStatusBarMinHeight, totalHeight - bottomPadding, @@ -720,7 +723,7 @@ public class NotificationPanelView extends PanelView implements - mShelfHeight / 2.0f - mDarkIconSize / 2.0f), clockPreferredY, hasCustomClock(), - mNotificationStackScroller.getVisibleNotificationCount() != 0, + hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount, bypassEnabled,