[Motion] Split-shade transition on LS: move keyguard even when media is not showing
- When media is showing, the keyguard is moved in sync with the media movement - Now when media is not showing, keyguard is moved based on an offset defined in resources Fixes: 226908761 Test: Unit tests + Manually Change-Id: Ic04c2b64f01f03e99e899591c6189113582a4c2b
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user