Merge "[Motion] Split-shade transition on LS: move keyguard even when media is not showing" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9be9b0336a
@@ -88,5 +88,11 @@
|
|||||||
whether the progress is > 0, therefore this value is not very important. -->
|
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_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>
|
<dimen name="notification_panel_margin_horizontal">24dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -28,4 +28,8 @@
|
|||||||
<dimen name="qs_media_session_height_expanded">251dp</dimen>
|
<dimen name="qs_media_session_height_expanded">251dp</dimen>
|
||||||
|
|
||||||
<dimen name="lockscreen_shade_max_over_scroll_amount">42dp</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>
|
</resources>
|
||||||
|
|||||||
@@ -1170,6 +1170,13 @@
|
|||||||
whether the progress is > 0, therefore this value is not very important. -->
|
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_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
|
<!-- Distance that the full shade transition takes in order for media to fully transition to
|
||||||
the shade -->
|
the shade -->
|
||||||
<dimen name="lockscreen_shade_media_transition_distance">120dp</dimen>
|
<dimen name="lockscreen_shade_media_transition_distance">120dp</dimen>
|
||||||
|
|||||||
@@ -809,11 +809,11 @@ class MediaHierarchyManager @Inject constructor(
|
|||||||
return resultBounds
|
return resultBounds
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @return true if this transformation is guided by an external progress like a finger */
|
||||||
* @return true if this transformation is guided by an external progress like a finger
|
fun isCurrentlyInGuidedTransformation(): Boolean {
|
||||||
*/
|
return hasValidStartAndEndLocations() &&
|
||||||
private fun isCurrentlyInGuidedTransformation(): Boolean {
|
getTransformationProgress() >= 0 &&
|
||||||
return hasValidStartAndEndLocations() && getTransformationProgress() >= 0
|
areGuidedTransitionHostsVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasValidStartAndEndLocations(): Boolean {
|
private fun hasValidStartAndEndLocations(): Boolean {
|
||||||
|
|||||||
@@ -163,6 +163,17 @@ class LockscreenShadeTransitionController @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
private var statusBarTransitionDistance = 0
|
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
|
* Flag to make sure that the dragDownAmount is applied to the listeners even when in the
|
||||||
* locked down shade.
|
* locked down shade.
|
||||||
@@ -275,6 +286,10 @@ class LockscreenShadeTransitionController @Inject constructor(
|
|||||||
statusBarTransitionDistance = context.resources.getDimensionPixelSize(
|
statusBarTransitionDistance = context.resources.getDimensionPixelSize(
|
||||||
R.dimen.lockscreen_shade_status_bar_transition_distance)
|
R.dimen.lockscreen_shade_status_bar_transition_distance)
|
||||||
useSplitShade = LargeScreenUtils.shouldUseSplitNotificationShade(context.resources)
|
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) {
|
fun setStackScroller(nsslController: NotificationStackScrollLayoutController) {
|
||||||
@@ -485,13 +500,7 @@ class LockscreenShadeTransitionController @Inject constructor(
|
|||||||
val keyguardAlphaProgress =
|
val keyguardAlphaProgress =
|
||||||
MathUtils.saturate(dragDownAmount / npvcKeyguardContentAlphaTransitionDistance)
|
MathUtils.saturate(dragDownAmount / npvcKeyguardContentAlphaTransitionDistance)
|
||||||
val keyguardAlpha = 1f - keyguardAlphaProgress
|
val keyguardAlpha = 1f - keyguardAlphaProgress
|
||||||
val keyguardTranslationY = if (useSplitShade) {
|
val keyguardTranslationY = calculateKeyguardTranslationY(dragDownAmount)
|
||||||
// On split-shade, the translationY of the keyguard should stay in sync with the
|
|
||||||
// translation of media.
|
|
||||||
mediaHierarchyManager.getGuidedTransformationTranslationY()
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
notificationPanelController
|
notificationPanelController
|
||||||
.setKeyguardTransitionProgress(keyguardAlpha, keyguardTranslationY)
|
.setKeyguardTransitionProgress(keyguardAlpha, keyguardTranslationY)
|
||||||
|
|
||||||
@@ -499,6 +508,21 @@ class LockscreenShadeTransitionController @Inject constructor(
|
|||||||
notificationPanelController.setKeyguardStatusBarAlpha(statusBarAlpha)
|
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(
|
private fun setDragDownAmountAnimated(
|
||||||
target: Float,
|
target: Float,
|
||||||
delay: Long = 0,
|
delay: Long = 0,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.media
|
package com.android.systemui.media
|
||||||
|
|
||||||
|
import org.mockito.Mockito.`when` as whenever
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.testing.AndroidTestingRunner
|
import android.testing.AndroidTestingRunner
|
||||||
import android.testing.TestableLooper
|
import android.testing.TestableLooper
|
||||||
@@ -54,7 +55,6 @@ import org.mockito.Mockito.clearInvocations
|
|||||||
import org.mockito.Mockito.times
|
import org.mockito.Mockito.times
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.junit.MockitoJUnit
|
import org.mockito.junit.MockitoJUnit
|
||||||
import org.mockito.Mockito.`when` as whenever
|
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner::class)
|
@RunWith(AndroidTestingRunner::class)
|
||||||
@@ -283,6 +283,28 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
|
|||||||
.isEqualTo(expectedTranslation)
|
.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() {
|
private fun enableSplitShade() {
|
||||||
context.getOrCreateTestableResources().addOverride(
|
context.getOrCreateTestableResources().addOverride(
|
||||||
R.bool.config_use_split_notification_shade, true
|
R.bool.config_use_split_notification_shade, true
|
||||||
|
|||||||
@@ -298,8 +298,9 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
|
|||||||
fun setDragAmount_notInSplitShade_setsKeyguardTranslationToZero() {
|
fun setDragAmount_notInSplitShade_setsKeyguardTranslationToZero() {
|
||||||
val mediaTranslationY = 123
|
val mediaTranslationY = 123
|
||||||
disableSplitShade()
|
disableSplitShade()
|
||||||
|
whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true)
|
||||||
whenever(mediaHierarchyManager.getGuidedTransformationTranslationY())
|
whenever(mediaHierarchyManager.getGuidedTransformationTranslationY())
|
||||||
.thenReturn(mediaTranslationY)
|
.thenReturn(mediaTranslationY)
|
||||||
|
|
||||||
transitionController.dragDownAmount = 10f
|
transitionController.dragDownAmount = 10f
|
||||||
|
|
||||||
@@ -310,13 +311,33 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() {
|
|||||||
fun setDragAmount_inSplitShade_setsKeyguardTranslationBasedOnMediaTranslation() {
|
fun setDragAmount_inSplitShade_setsKeyguardTranslationBasedOnMediaTranslation() {
|
||||||
val mediaTranslationY = 123
|
val mediaTranslationY = 123
|
||||||
enableSplitShade()
|
enableSplitShade()
|
||||||
|
whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true)
|
||||||
whenever(mediaHierarchyManager.getGuidedTransformationTranslationY())
|
whenever(mediaHierarchyManager.getGuidedTransformationTranslationY())
|
||||||
.thenReturn(mediaTranslationY)
|
.thenReturn(mediaTranslationY)
|
||||||
|
|
||||||
transitionController.dragDownAmount = 10f
|
transitionController.dragDownAmount = 10f
|
||||||
|
|
||||||
verify(notificationPanelController)
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user