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

Commit 4d810b76 authored by Matt Pietal's avatar Matt Pietal
Browse files

Use consistent NSSL margins across devices

There were some edge cases that were leading to inconsistencies with
the size of the NSSL placeholder and the actual space available. This
was due to differences in how the margins were calculated for the
placeholder.

Test: atest SharedNotificationContainerViewModelTest
Test: manual - use notifications in all orientations and ensure it
matches the legacy location. swipe up/down to make sure animations are
stable
Fixes: 322350556
Fixes: 322554526
Flag: ACONFIG com.android.systemui.keyguard_shade_migration_nssl
DEVELOPMENT
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint
DEVELOPMENT

Change-Id: I99c73a8de19010505cde1a7b41383d304f3d28be
parent 2f5c581d
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -24,11 +24,13 @@ import androidx.constraintlayout.widget.ConstraintSet.END
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.systemui.Flags.centralizedStatusBarDimensRefactor
import com.android.systemui.Flags.migrateClocksToBlueprint
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlags
import com.android.systemui.shade.LargeScreenHeaderHelper
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.statusbar.notification.stack.AmbientState
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
@@ -36,6 +38,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCa
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationStackAppearanceViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher

@@ -52,6 +55,7 @@ constructor(
    ambientState: AmbientState,
    controller: NotificationStackScrollLayoutController,
    notificationStackSizeCalculator: NotificationStackSizeCalculator,
    private val largeScreenHeaderHelperLazy: Lazy<LargeScreenHeaderHelper>,
    @Main mainDispatcher: CoroutineDispatcher,
) :
    NotificationStackScrollLayoutSection(
@@ -74,12 +78,27 @@ constructor(
            val bottomMargin =
                context.resources.getDimensionPixelSize(R.dimen.keyguard_status_view_bottom_margin)
            if (migrateClocksToBlueprint()) {
                val useLargeScreenHeader =
                    context.resources.getBoolean(R.bool.config_use_large_screen_shade_header)
                val marginTopLargeScreen =
                    if (centralizedStatusBarDimensRefactor()) {
                        largeScreenHeaderHelperLazy.get().getLargeScreenHeaderHeight()
                    } else {
                        context.resources.getDimensionPixelSize(
                            R.dimen.large_screen_shade_header_height
                        )
                    }
                connect(
                    R.id.nssl_placeholder,
                    TOP,
                    R.id.smart_space_barrier_bottom,
                    BOTTOM,
                    bottomMargin
                    bottomMargin +
                        if (useLargeScreenHeader) {
                            marginTopLargeScreen
                        } else {
                            0
                        }
                )
            } else {
                connect(R.id.nssl_placeholder, TOP, R.id.keyguard_status_view, BOTTOM, bottomMargin)
+7 −14
Original line number Diff line number Diff line
@@ -23,13 +23,11 @@ import androidx.constraintlayout.widget.ConstraintSet.END
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.systemui.Flags.centralizedStatusBarDimensRefactor
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlags
import com.android.systemui.shade.LargeScreenHeaderHelper
import com.android.systemui.shade.NotificationPanelView
import com.android.systemui.statusbar.notification.stack.AmbientState
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
@@ -37,7 +35,6 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCa
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationStackAppearanceViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher

@@ -56,7 +53,6 @@ constructor(
    notificationStackSizeCalculator: NotificationStackSizeCalculator,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
    @Main mainDispatcher: CoroutineDispatcher,
    private val largeScreenHeaderHelperLazy: Lazy<LargeScreenHeaderHelper>,
) :
    NotificationStackScrollLayoutSection(
        context,
@@ -75,16 +71,13 @@ constructor(
            return
        }
        constraintSet.apply {
            val splitShadeTopMargin =
                if (centralizedStatusBarDimensRefactor()) {
                    largeScreenHeaderHelperLazy.get().getLargeScreenHeaderHeight()
                } else {
                    context.resources.getDimensionPixelSize(
                        R.dimen.large_screen_shade_header_height
            connect(
                R.id.nssl_placeholder,
                TOP,
                PARENT_ID,
                TOP,
                context.resources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)
            )
                }
            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)

+4 −8
Original line number Diff line number Diff line
@@ -76,14 +76,10 @@ class SharedNotificationContainer(
            }
        val nsslId = R.id.notification_stack_scroller
        constraintSet.apply {
            connect(nsslId, START, startConstraintId, START)
            connect(nsslId, END, PARENT_ID, END)
            connect(nsslId, BOTTOM, PARENT_ID, BOTTOM)
            connect(nsslId, TOP, PARENT_ID, TOP)
            setMargin(nsslId, START, marginStart)
            setMargin(nsslId, END, marginEnd)
            setMargin(nsslId, TOP, marginTop)
            setMargin(nsslId, BOTTOM, marginBottom)
            connect(nsslId, START, startConstraintId, START, marginStart)
            connect(nsslId, END, PARENT_ID, END, marginEnd)
            connect(nsslId, BOTTOM, PARENT_ID, BOTTOM, marginBottom)
            connect(nsslId, TOP, PARENT_ID, TOP, marginTop)
        }
        constraintSet.applyTo(this)
    }
+12 −11
Original line number Diff line number Diff line
@@ -151,21 +151,20 @@ constructor(
    val configurationBasedDimensions: Flow<ConfigurationBasedDimensions> =
        interactor.configurationBasedDimensions
            .map {
                val marginTop =
                    if (it.useLargeScreenHeader) it.marginTopLargeScreen else it.marginTop
                ConfigurationBasedDimensions(
                    marginStart = if (it.useSplitShade) 0 else it.marginHorizontal,
                    marginEnd = it.marginHorizontal,
                    marginBottom = it.marginBottom,
                    marginTop =
                        if (it.useLargeScreenHeader) it.marginTopLargeScreen else it.marginTop,
                    marginTop = 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
                            marginTop
                        } else {
                            0
                        }
                        },
                )
            }
            .distinctUntilChanged()
@@ -255,13 +254,15 @@ constructor(
                isOnLockscreenWithoutShade,
                keyguardInteractor.notificationContainerBounds,
                configurationBasedDimensions,
                interactor.topPosition.sampleCombine(
                interactor.topPosition
                    .sampleCombine(
                        keyguardTransitionInteractor.isInTransitionToAnyState,
                        shadeInteractor.qsExpansion,
                ),
                    )
                    .onStart { emit(Triple(0f, false, 0f)) }
            ) { onLockscreen, bounds, config, (top, isInTransitionToAnyState, qsExpansion) ->
                if (onLockscreen) {
                    bounds.copy(top = bounds.top + config.paddingTop)
                    bounds.copy(top = bounds.top - config.paddingTop)
                } else {
                    // When QS expansion > 0, it should directly set the top padding so do not
                    // animate it
+8 −6
Original line number Diff line number Diff line
@@ -138,7 +138,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {

            configurationRepository.onAnyConfigurationChange()

            assertThat(dimens!!.paddingTop).isEqualTo(30)
            // Should directly use the header height (flagged off value)
            assertThat(dimens!!.paddingTop).isEqualTo(10)
        }

    @Test
@@ -154,7 +155,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {

            configurationRepository.onAnyConfigurationChange()

            assertThat(dimens!!.paddingTop).isEqualTo(40)
            // Should directly use the header height (flagged on value)
            assertThat(dimens!!.paddingTop).isEqualTo(5)
        }

    @Test
@@ -456,8 +458,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            )
            runCurrent()

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

    @Test
@@ -483,8 +485,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            )
            runCurrent()

            // Top should be equal to bounds (1) + padding adjustment (40)
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = 41f, bottom = 2f))
            // Top should be equal to bounds (1) - padding adjustment (5)
            assertThat(bounds).isEqualTo(NotificationContainerBounds(top = -4f, bottom = 2f))
        }

    @Test