Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7940bf86 authored by Christian Göllner's avatar Christian Göllner Committed by Automerger Merge Worker
Browse files

Merge "[Motion] Split-shade transition on LS: move keyguard even when media is...

Merge "[Motion] Split-shade transition on LS: move keyguard even when media is not showing" into tm-dev am: 9be9b033

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17400664



Change-Id: I132396d4710e3fa30a896fd684e75c9f49e928fc
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c4d1f86c 9be9b033
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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>
+4 −0
Original line number Diff line number Diff line
@@ -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>
+7 −0
Original line number Diff line number Diff line
@@ -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>
+5 −5
Original line number Diff line number Diff line
@@ -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 {
+31 −7
Original line number Diff line number Diff line
@@ -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,
Loading