From df03b06e262bd47756451a94371b136fad0dd73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6llner?= Date: Wed, 2 Mar 2022 12:55:31 +0100 Subject: [PATCH] Lockscreen shade transition: rename and split resources There were two existing resource names that didn't reflect the their real usage, and have been renamed. The resources have also been split into multiple resources for easier fine tuning. Bug: 214946307 Test: Manually Change-Id: I7328e54c4b76d844327b5fd24b5de1afb2bb5904 --- .../res/values-sw600dp-land/dimens.xml | 41 ++++++-- packages/SystemUI/res/values/dimens.xml | 35 ++++++- .../LockscreenShadeTransitionController.kt | 96 ++++++++++++++++--- 3 files changed, 148 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/res/values-sw600dp-land/dimens.xml b/packages/SystemUI/res/values-sw600dp-land/dimens.xml index 4f95811b21b37..3459aba63c367 100644 --- a/packages/SystemUI/res/values-sw600dp-land/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp-land/dimens.xml @@ -34,17 +34,44 @@ 0.45 8dp - - 200dp + + 200dp + + + 200dp + + + 200dp - 200dp + @dimen/lockscreen_shade_full_transition_distance - - 200dp + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance 12dp diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 5a7efca3dece2..5ca7285d3f737 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1122,13 +1122,40 @@ 12.5dp 20dp - - 200dp + + 200dp + + + 80dp - 80dp + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance + + + @dimen/lockscreen_shade_full_transition_distance diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt index 17f42b1a3a433..263463050d41c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt @@ -99,15 +99,57 @@ class LockscreenShadeTransitionController @Inject constructor( internal var pulseHeightAnimator: ValueAnimator? = null /** - * Distance that the full shade transition takes in order for scrim to fully transition to - * the shade (in alpha) + * Distance that the full shade transition takes in order to complete. + */ + private var fullTransitionDistance = 0 + + /** + * Distance that the full transition takes in order for us to fully transition to the shade by + * tapping on a button, such as "expand". + */ + private var fullTransitionDistanceByTap = 0 + + /** + * Distance that the full shade transition takes in order for scrim to fully transition to the + * shade (in alpha) */ private var scrimTransitionDistance = 0 /** - * Distance that the full transition takes in order for us to fully transition to the shade + * Distance that the full shade transition takes in order for the notification shelf to fully + * expand. */ - private var fullTransitionDistance = 0 + private var notificationShelfTransitionDistance = 0 + + /** + * Distance that the full shade transition takes in order for the Quick Settings to fully fade + * and expand. + */ + private var qsTransitionDistance = 0 + + /** + * Distance that the full shade transition takes in order for the keyguard content on + * NotificationPanelViewController to fully fade (e.g. Clock & Smartspace). + */ + private var npvcKeyguardContentAlphaTransitionDistance = 0 + + /** + * Distance that the full shade transition takes in order for depth of the wallpaper to fully + * change. + */ + private var depthControllerTransitionDistance = 0 + + /** + * Distance that the full shade transition takes in order for the UDFPS Keyguard View to fully + * fade. + */ + private var udfpsTransitionDistance = 0 + + /** + * Used for StatusBar to know that a transition is in progress. At the moment it only checks + * whether the progress is > 0, therefore this value is not very important. + */ + private var statusBarTransitionDistance = 0 /** * Flag to make sure that the dragDownAmount is applied to the listeners even when in the @@ -130,7 +172,7 @@ class LockscreenShadeTransitionController @Inject constructor( * The distance until we're showing the notifications when pulsing */ val distanceUntilShowingPulsingNotifications - get() = scrimTransitionDistance + get() = fullTransitionDistance /** * The udfpsKeyguardViewController if it exists. @@ -177,10 +219,24 @@ class LockscreenShadeTransitionController @Inject constructor( } private fun updateResources() { + fullTransitionDistance = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_full_transition_distance) + fullTransitionDistanceByTap = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_transition_by_tap_distance) scrimTransitionDistance = context.resources.getDimensionPixelSize( R.dimen.lockscreen_shade_scrim_transition_distance) - fullTransitionDistance = context.resources.getDimensionPixelSize( + notificationShelfTransitionDistance = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_notif_shelf_transition_distance) + qsTransitionDistance = context.resources.getDimensionPixelSize( R.dimen.lockscreen_shade_qs_transition_distance) + npvcKeyguardContentAlphaTransitionDistance = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance) + depthControllerTransitionDistance = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_depth_controller_transition_distance) + udfpsTransitionDistance = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_udfps_keyguard_transition_distance) + statusBarTransitionDistance = context.resources.getDimensionPixelSize( + R.dimen.lockscreen_shade_status_bar_transition_distance) useSplitShade = Utils.shouldUseSplitNotificationShade(context.resources) } @@ -337,11 +393,16 @@ class LockscreenShadeTransitionController @Inject constructor( if (field != value || forceApplyAmount) { field = value if (!nsslController.isInLockedDownShade() || field == 0f || forceApplyAmount) { - qSDragProgress = MathUtils.saturate(dragDownAmount / scrimTransitionDistance) - nsslController.setTransitionToFullShadeAmount(field, qSDragProgress) + val notificationShelfProgress = + MathUtils.saturate(dragDownAmount / notificationShelfTransitionDistance) + nsslController.setTransitionToFullShadeAmount(field, notificationShelfProgress) + + qSDragProgress = MathUtils.saturate(dragDownAmount / qsTransitionDistance) qS.setTransitionToFullShadeAmount(field, qSDragProgress) + notificationPanelController.setTransitionToFullShadeAmount(field, false /* animate */, 0 /* delay */) + mediaHierarchyManager.setTransitionToFullShadeAmount(field) transitionToShadeAmountCommon(field) } @@ -357,11 +418,20 @@ class LockscreenShadeTransitionController @Inject constructor( private fun transitionToShadeAmountCommon(dragDownAmount: Float) { val scrimProgress = MathUtils.saturate(dragDownAmount / scrimTransitionDistance) scrimController.setTransitionToFullShadeProgress(scrimProgress) + // Fade out all content only visible on the lockscreen - notificationPanelController.setKeyguardOnlyContentAlpha(1.0f - scrimProgress) - depthController.transitionToFullShadeProgress = scrimProgress - udfpsKeyguardViewController?.setTransitionToFullShadeProgress(scrimProgress) - centralSurfaces.setTransitionToFullShadeProgress(scrimProgress) + val npvcProgress = + MathUtils.saturate(dragDownAmount / npvcKeyguardContentAlphaTransitionDistance) + notificationPanelController.setKeyguardOnlyContentAlpha(1.0f - npvcProgress) + + val depthProgress = MathUtils.saturate(dragDownAmount / depthControllerTransitionDistance) + depthController.transitionToFullShadeProgress = depthProgress + + val udfpsProgress = MathUtils.saturate(dragDownAmount / udfpsTransitionDistance) + udfpsKeyguardViewController?.setTransitionToFullShadeProgress(udfpsProgress) + + val statusBarProgress = MathUtils.saturate(dragDownAmount / statusBarTransitionDistance) + centralSurfaces.setTransitionToFullShadeProgress(statusBarProgress) } private fun setDragDownAmountAnimated( @@ -404,7 +474,7 @@ class LockscreenShadeTransitionController @Inject constructor( // be a couple of frames later. if we're setting it to 0, it will use the // default inset and therefore flicker dragDownAmount = 1f - setDragDownAmountAnimated(fullTransitionDistance.toFloat(), delay = delay) { + setDragDownAmountAnimated(fullTransitionDistanceByTap.toFloat(), delay = delay) { // End listener: // Reset dragDownAmount = 0f