diff --git a/packages/SystemUI/res/values-sw600dp-land/dimens.xml b/packages/SystemUI/res/values-sw600dp-land/dimens.xml
index 76780ffd2f80e..b3da144ac73ba 100644
--- a/packages/SystemUI/res/values-sw600dp-land/dimens.xml
+++ b/packages/SystemUI/res/values-sw600dp-land/dimens.xml
@@ -88,5 +88,11 @@
whether the progress is > 0, therefore this value is not very important. -->
@dimen/lockscreen_shade_full_transition_distance
+ @dimen/lockscreen_shade_media_transition_distance
+
+
+ 83dp
+
24dp
diff --git a/packages/SystemUI/res/values-sw720dp-land/dimens.xml b/packages/SystemUI/res/values-sw720dp-land/dimens.xml
index 0512d3c2c3a48..4d4f5205754ff 100644
--- a/packages/SystemUI/res/values-sw720dp-land/dimens.xml
+++ b/packages/SystemUI/res/values-sw720dp-land/dimens.xml
@@ -28,4 +28,8 @@
251dp
42dp
+
+
+ 93dp
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index f39b5efdca24e..e187cd3694428 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1170,6 +1170,13 @@
whether the progress is > 0, therefore this value is not very important. -->
@dimen/lockscreen_shade_full_transition_distance
+
+ @dimen/lockscreen_shade_media_transition_distance
+
+
+ 0dp
+
120dp
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
index b0159ede51a94..3d9f933b3a05b 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
@@ -809,11 +809,11 @@ class MediaHierarchyManager @Inject constructor(
return resultBounds
}
- /**
- * @return true if this transformation is guided by an external progress like a finger
- */
- private fun isCurrentlyInGuidedTransformation(): Boolean {
- return hasValidStartAndEndLocations() && getTransformationProgress() >= 0
+ /** @return true if this transformation is guided by an external progress like a finger */
+ fun isCurrentlyInGuidedTransformation(): Boolean {
+ return hasValidStartAndEndLocations() &&
+ getTransformationProgress() >= 0 &&
+ areGuidedTransitionHostsVisible()
}
private fun hasValidStartAndEndLocations(): Boolean {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
index 3620e84de3980..63ab3de14d248 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
@@ -163,6 +163,17 @@ class LockscreenShadeTransitionController @Inject constructor(
*/
private var statusBarTransitionDistance = 0
+ /**
+ * Distance that the full shade transition takes in order for the keyguard elements to fully
+ * translate into their final position
+ */
+ private var keyguardTransitionDistance = 0
+
+ /**
+ * The amount of vertical offset for the keyguard during the full shade transition.
+ */
+ private var keyguardTransitionOffset = 0
+
/**
* Flag to make sure that the dragDownAmount is applied to the listeners even when in the
* locked down shade.
@@ -275,6 +286,10 @@ class LockscreenShadeTransitionController @Inject constructor(
statusBarTransitionDistance = context.resources.getDimensionPixelSize(
R.dimen.lockscreen_shade_status_bar_transition_distance)
useSplitShade = LargeScreenUtils.shouldUseSplitNotificationShade(context.resources)
+ keyguardTransitionDistance = context.resources.getDimensionPixelSize(
+ R.dimen.lockscreen_shade_keyguard_transition_distance)
+ keyguardTransitionOffset = context.resources.getDimensionPixelSize(
+ R.dimen.lockscreen_shade_keyguard_transition_vertical_offset)
}
fun setStackScroller(nsslController: NotificationStackScrollLayoutController) {
@@ -485,13 +500,7 @@ class LockscreenShadeTransitionController @Inject constructor(
val keyguardAlphaProgress =
MathUtils.saturate(dragDownAmount / npvcKeyguardContentAlphaTransitionDistance)
val keyguardAlpha = 1f - keyguardAlphaProgress
- val keyguardTranslationY = if (useSplitShade) {
- // On split-shade, the translationY of the keyguard should stay in sync with the
- // translation of media.
- mediaHierarchyManager.getGuidedTransformationTranslationY()
- } else {
- 0
- }
+ val keyguardTranslationY = calculateKeyguardTranslationY(dragDownAmount)
notificationPanelController
.setKeyguardTransitionProgress(keyguardAlpha, keyguardTranslationY)
@@ -499,6 +508,21 @@ class LockscreenShadeTransitionController @Inject constructor(
notificationPanelController.setKeyguardStatusBarAlpha(statusBarAlpha)
}
+ private fun calculateKeyguardTranslationY(dragDownAmount: Float): Int {
+ if (!useSplitShade) {
+ return 0
+ }
+ // On split-shade, the translationY of the keyguard should stay in sync with the
+ // translation of media.
+ if (mediaHierarchyManager.isCurrentlyInGuidedTransformation()) {
+ return mediaHierarchyManager.getGuidedTransformationTranslationY()
+ }
+ // When media is not showing, apply the default distance
+ val translationProgress = MathUtils.saturate(dragDownAmount / keyguardTransitionDistance)
+ val translationY = translationProgress * keyguardTransitionOffset
+ return translationY.toInt()
+ }
+
private fun setDragDownAmountAnimated(
target: Float,
delay: Long = 0,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt
index 203eb47165e03..d65b6b31a26d0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt
@@ -16,6 +16,7 @@
package com.android.systemui.media
+import org.mockito.Mockito.`when` as whenever
import android.graphics.Rect
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
@@ -54,7 +55,6 @@ import org.mockito.Mockito.clearInvocations
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
-import org.mockito.Mockito.`when` as whenever
@SmallTest
@RunWith(AndroidTestingRunner::class)
@@ -283,6 +283,28 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
.isEqualTo(expectedTranslation)
}
+ @Test
+ fun isCurrentlyInGuidedTransformation_hostsVisible_returnsTrue() {
+ goToLockscreen()
+ enterGuidedTransformation()
+ whenever(lockHost.visible).thenReturn(true)
+ whenever(qsHost.visible).thenReturn(true)
+ whenever(qqsHost.visible).thenReturn(true)
+
+ assertThat(mediaHiearchyManager.isCurrentlyInGuidedTransformation()).isTrue()
+ }
+
+ @Test
+ fun isCurrentlyInGuidedTransformation_hostNotVisible_returnsTrue() {
+ goToLockscreen()
+ enterGuidedTransformation()
+ whenever(lockHost.visible).thenReturn(false)
+ whenever(qsHost.visible).thenReturn(true)
+ whenever(qqsHost.visible).thenReturn(true)
+
+ assertThat(mediaHiearchyManager.isCurrentlyInGuidedTransformation()).isFalse()
+ }
+
private fun enableSplitShade() {
context.getOrCreateTestableResources().addOverride(
R.bool.config_use_split_notification_shade, true
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt
index fc19d131f351e..e2d6ae07fe709 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt
@@ -298,8 +298,9 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
fun setDragAmount_notInSplitShade_setsKeyguardTranslationToZero() {
val mediaTranslationY = 123
disableSplitShade()
+ whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true)
whenever(mediaHierarchyManager.getGuidedTransformationTranslationY())
- .thenReturn(mediaTranslationY)
+ .thenReturn(mediaTranslationY)
transitionController.dragDownAmount = 10f
@@ -310,13 +311,33 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
fun setDragAmount_inSplitShade_setsKeyguardTranslationBasedOnMediaTranslation() {
val mediaTranslationY = 123
enableSplitShade()
+ whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true)
whenever(mediaHierarchyManager.getGuidedTransformationTranslationY())
- .thenReturn(mediaTranslationY)
+ .thenReturn(mediaTranslationY)
transitionController.dragDownAmount = 10f
verify(notificationPanelController)
- .setKeyguardTransitionProgress(anyFloat(), eq(mediaTranslationY))
+ .setKeyguardTransitionProgress(anyFloat(), eq(mediaTranslationY))
+ }
+
+ @Test
+ fun setDragAmount_inSplitShade_mediaNotShowing_setsKeyguardTranslationBasedOnDistance() {
+ enableSplitShade()
+ whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(false)
+ whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()).thenReturn(123)
+
+ transitionController.dragDownAmount = 10f
+
+ val distance =
+ context.resources.getDimensionPixelSize(
+ R.dimen.lockscreen_shade_keyguard_transition_distance)
+ val offset =
+ context.resources.getDimensionPixelSize(
+ R.dimen.lockscreen_shade_keyguard_transition_vertical_offset)
+ val expectedTranslation = 10f / distance * offset
+ verify(notificationPanelController)
+ .setKeyguardTransitionProgress(anyFloat(), eq(expectedTranslation.toInt()))
}
@Test