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

Commit 6594f224 authored by Matt Pietal's avatar Matt Pietal
Browse files

Tweak splitshade nssl positioning

Specifically for keyguard/shade migration, the top padding in split
shade mode needed to match the legacy positioning in order to prevent
the shade jumping slightly when pulled down on lockscreen. This also
ensures the placeholder is properly sized so the max notification
logic works.

Bug: 308772985
Test: atest SharedNotificationContainerInteractorTest
SharedNotificationContainerViewModelTest
Flag: ACONFIG com.android.systemui.keyguard_shade_migration_nssl
DEVELOPMENT

Change-Id: I11cc76f207d98d7d817f470001690b4d96566ed6
parent 2596f1e1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -87,8 +87,13 @@ constructor(
                )
                setGoneMargin(R.id.nssl_placeholder, TOP, bottomMargin)
            } else {
                connect(R.id.nssl_placeholder, TOP, R.id.keyguard_status_view, TOP, bottomMargin)
                val splitShadeTopMargin =
                    context.resources.getDimensionPixelSize(
                        R.dimen.large_screen_shade_header_height
                    )
                connect(R.id.nssl_placeholder, TOP, PARENT_ID, TOP, splitShadeTopMargin)
            }

            connect(R.id.nssl_placeholder, START, PARENT_ID, START)
            connect(R.id.nssl_placeholder, END, PARENT_ID, END)

+3 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ constructor(
                        marginTop = getDimensionPixelSize(R.dimen.notification_panel_margin_top),
                        marginTopLargeScreen =
                            getDimensionPixelSize(R.dimen.large_screen_shade_header_height),
                        keyguardSplitShadeTopMargin =
                            getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin),
                    )
                }
            }
@@ -95,5 +97,6 @@ constructor(
        val marginBottom: Int,
        val marginTop: Int,
        val marginTopLargeScreen: Int,
        val keyguardSplitShadeTopMargin: Int,
    )
}
+10 −5
Original line number Diff line number Diff line
@@ -83,6 +83,14 @@ constructor(
                    marginTop =
                        if (it.useLargeScreenHeader) it.marginTopLargeScreen else it.marginTop,
                    useSplitShade = it.useSplitShade,
                    paddingTop =
                        if (it.useSplitShade) {
                            // When in split shade, the margin is applied twice as the legacy shade
                            // code uses it to calculate padding.
                            it.keyguardSplitShadeTopMargin - 2 * it.marginTopLargeScreen
                        } else {
                            0
                        }
                )
            }
            .distinctUntilChanged()
@@ -156,11 +164,7 @@ constructor(
                ),
            ) { onLockscreen, bounds, config, (top, isInTransitionToAnyState, qsExpansion) ->
                if (onLockscreen) {
                    if (config.useSplitShade) {
                        bounds.copy(top = 0f)
                    } else {
                        bounds
                    }
                    bounds.copy(top = bounds.top + config.paddingTop)
                } else {
                    // When QS expansion > 0, it should directly set the top padding so do not
                    // animate it
@@ -268,5 +272,6 @@ constructor(
        val marginEnd: Int,
        val marginBottom: Int,
        val useSplitShade: Boolean,
        val paddingTop: Int,
    )
}
+3 −1
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.res.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.res.R
import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runCurrent
@@ -56,6 +56,7 @@ class SharedNotificationContainerInteractorTest : SysuiTestCase() {
        overrideResource(R.dimen.notification_panel_margin_bottom, 10)
        overrideResource(R.dimen.notification_panel_margin_top, 10)
        overrideResource(R.dimen.large_screen_shade_header_height, 0)
        overrideResource(R.dimen.keyguard_split_shade_top_margin, 55)

        val dimens = collectLastValue(underTest.configurationBasedDimensions)

@@ -70,5 +71,6 @@ class SharedNotificationContainerInteractorTest : SysuiTestCase() {
        assertThat(lastDimens.marginBottom).isGreaterThan(0)
        assertThat(lastDimens.marginTop).isGreaterThan(0)
        assertThat(lastDimens.marginTopLargeScreen).isEqualTo(0)
        assertThat(lastDimens.keyguardSplitShadeTopMargin).isEqualTo(55)
    }
}
+38 −7
Original line number Diff line number Diff line
@@ -99,6 +99,34 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            assertThat(dimens!!.marginStart).isEqualTo(20)
        }

    @Test
    fun validatePaddingTopInSplitShade() =
        testScope.runTest {
            overrideResource(R.bool.config_use_split_notification_shade, true)
            overrideResource(R.dimen.large_screen_shade_header_height, 10)
            overrideResource(R.dimen.keyguard_split_shade_top_margin, 50)

            val dimens by collectLastValue(underTest.configurationBasedDimensions)

            configurationRepository.onAnyConfigurationChange()

            assertThat(dimens!!.paddingTop).isEqualTo(30)
        }

    @Test
    fun validatePaddingTop() =
        testScope.runTest {
            overrideResource(R.bool.config_use_split_notification_shade, false)
            overrideResource(R.dimen.large_screen_shade_header_height, 10)
            overrideResource(R.dimen.keyguard_split_shade_top_margin, 50)

            val dimens by collectLastValue(underTest.configurationBasedDimensions)

            configurationRepository.onAnyConfigurationChange()

            assertThat(dimens!!.paddingTop).isEqualTo(0)
        }

    @Test
    fun validateMarginEnd() =
        testScope.runTest {
@@ -226,9 +254,9 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
        }

    @Test
    fun positionOnLockscreenNotInSplitShade() =
    fun boundsOnLockscreenNotInSplitShade() =
        testScope.runTest {
            val position by collectLastValue(underTest.bounds)
            val bounds by collectLastValue(underTest.bounds)

            // When not in split shade
            overrideResource(R.bool.config_use_split_notification_shade, false)
@@ -242,16 +270,19 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
                NotificationContainerBounds(top = 1f, bottom = 2f)
            )

            assertThat(position).isEqualTo(NotificationContainerBounds(top = 1f, bottom = 2f))
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 1f, bottom = 2f))
        }

    @Test
    fun positionOnLockscreenInSplitShade() =
    fun boundsOnLockscreenInSplitShade() =
        testScope.runTest {
            val position by collectLastValue(underTest.bounds)
            val bounds by collectLastValue(underTest.bounds)

            // When in split shade
            overrideResource(R.bool.config_use_split_notification_shade, true)
            overrideResource(R.dimen.large_screen_shade_header_height, 10)
            overrideResource(R.dimen.keyguard_split_shade_top_margin, 50)

            configurationRepository.onAnyConfigurationChange()
            runCurrent()

@@ -263,8 +294,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            )
            runCurrent()

            // Top should be overridden to 0f
            assertThat(position).isEqualTo(NotificationContainerBounds(top = 0f, bottom = 2f))
            // Top should be equal to bounds (1) + padding adjustment (30)
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 31f, bottom = 2f))
        }

    @Test