summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christian Göllner <chrisgollner@google.com> 2022-03-26 07:50:04 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-03-26 07:50:04 +0000
commit9be9b0336afeec96f0d03af5cb490cdf5a098585 (patch)
treee94f8f5519248aa7849577b735e45f92a0967213
parent3405ecf55b0f40be9e56d354c725d6e92db486c0 (diff)
parent7e7946873a660e64189266dd14f3c3a72edef908 (diff)
Merge "[Motion] Split-shade transition on LS: move keyguard even when media is not showing" into tm-dev
-rw-r--r--packages/SystemUI/res/values-sw600dp-land/dimens.xml6
-rw-r--r--packages/SystemUI/res/values-sw720dp-land/dimens.xml4
-rw-r--r--packages/SystemUI/res/values/dimens.xml7
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt38
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt24
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt27
7 files changed, 100 insertions, 16 deletions
diff --git a/packages/SystemUI/res/values-sw600dp-land/dimens.xml b/packages/SystemUI/res/values-sw600dp-land/dimens.xml
index 76780ffd2f80..b3da144ac73b 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 name="lockscreen_shade_status_bar_transition_distance">@dimen/lockscreen_shade_full_transition_distance</dimen>
+ <dimen name="lockscreen_shade_keyguard_transition_distance">@dimen/lockscreen_shade_media_transition_distance</dimen>
+
+ <!-- Roughly the same distance as media on LS to media on QS. We will translate by this value
+ when media is not showing. -->
+ <dimen name="lockscreen_shade_keyguard_transition_vertical_offset">83dp</dimen>
+
<dimen name="notification_panel_margin_horizontal">24dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values-sw720dp-land/dimens.xml b/packages/SystemUI/res/values-sw720dp-land/dimens.xml
index 0512d3c2c3a4..4d4f5205754f 100644
--- a/packages/SystemUI/res/values-sw720dp-land/dimens.xml
+++ b/packages/SystemUI/res/values-sw720dp-land/dimens.xml
@@ -28,4 +28,8 @@
<dimen name="qs_media_session_height_expanded">251dp</dimen>
<dimen name="lockscreen_shade_max_over_scroll_amount">42dp</dimen>
+
+ <!-- Roughly the same distance as media on LS to media on QS. We will translate by this value
+ when media is not showing. -->
+ <dimen name="lockscreen_shade_keyguard_transition_vertical_offset">93dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index f39b5efdca24..e187cd369442 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 name="lockscreen_shade_status_bar_transition_distance">@dimen/lockscreen_shade_full_transition_distance</dimen>
+ <!-- Distance that the full shade transition takes in order for the keyguard elements to fully
+ translate into their final position. -->
+ <dimen name="lockscreen_shade_keyguard_transition_distance">@dimen/lockscreen_shade_media_transition_distance</dimen>
+
+ <!-- The amount of vertical offset for the keyguard during the full shade transition. -->
+ <dimen name="lockscreen_shade_keyguard_transition_vertical_offset">0dp</dimen>
+
<!-- Distance that the full shade transition takes in order for media to fully transition to
the shade -->
<dimen name="lockscreen_shade_media_transition_distance">120dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
index b0159ede51a9..3d9f933b3a05 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 3620e84de398..63ab3de14d24 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
@@ -164,6 +164,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 203eb47165e0..d65b6b31a26d 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 fc19d131f351..e2d6ae07fe70 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