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

Commit fdf1804b authored by Jeff DeCew's avatar Jeff DeCew
Browse files

[flexiglass] Add NotificationStackView (NSV) interface

* NSV is implemented by NSSL so that we can eventually stop injecting NSSL/NSSLC everywhere.
* Remove the NotificationStackAppearanceInteractor from the NSSLC and bind all fields to NSV instead of NSSLC.
* Add SceneContainerFlag.assertInLegacyMode() to some NSSLC methods where the new code can go directly to NSV.
* Add ShadeScrimShape which includes the actual rounding radii, and have the ViewModel take the radius flow and position flow to expose that directly, moving that ViewBinder logic to the ViewModel.

Bug: 296118689
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I87e6a5219c46f0cdbed569e004a016d6064fcc8f
parent d83844f8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -397,8 +397,8 @@ private fun Modifier.debugBackground(
    }

fun ShadeScrimRounding.toRoundedCornerShape(radius: Dp): RoundedCornerShape {
    val topRadius = if (roundTop) radius else 0.dp
    val bottomRadius = if (roundBottom) radius else 0.dp
    val topRadius = if (isTopRounded) radius else 0.dp
    val bottomRadius = if (isBottomRounded) radius else 0.dp
    return RoundedCornerShape(
        topStart = topRadius,
        topEnd = topRadius,
+31 −11
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.fakeSceneDataSource
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimShape
import com.android.systemui.statusbar.notification.stack.shared.model.ViewPosition
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationStackAppearanceViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel
import com.android.systemui.testKosmos
@@ -64,20 +66,38 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
    @Test
    fun updateBounds() =
        testScope.runTest {
            val clipping by collectLastValue(appearanceViewModel.shadeScrimClipping)
            val radius = MutableStateFlow(32)
            val viewPosition = MutableStateFlow(ViewPosition(0, 0))
            val shape by collectLastValue(appearanceViewModel.shadeScrimShape(radius, viewPosition))

            placeholderViewModel.onBoundsChanged(left = 0f, top = 200f, right = 100f, bottom = 550f)
            assertThat(shape)
                .isEqualTo(
                    ShadeScrimShape(
                        bounds =
                            ShadeScrimBounds(left = 0f, top = 200f, right = 100f, bottom = 550f),
                        topRadius = 32,
                        bottomRadius = 0
                    )
                )

            val top = 200f
            val left = 0f
            val bottom = 550f
            val right = 100f
            viewPosition.value = ViewPosition(200, 15)
            radius.value = 24
            placeholderViewModel.onBoundsChanged(
                left = left,
                top = top,
                right = right,
                bottom = bottom
                left = 210f,
                top = 200f,
                right = 300f,
                bottom = 550f
            )
            assertThat(shape)
                .isEqualTo(
                    ShadeScrimShape(
                        bounds =
                            ShadeScrimBounds(left = 10f, top = 185f, right = 100f, bottom = 535f),
                        topRadius = 24,
                        bottomRadius = 0
                    )
                )
            assertThat(clipping?.bounds)
                .isEqualTo(ShadeScrimBounds(left = left, top = top, right = right, bottom = bottom))
        }

    @Test
+2 −2
Original line number Diff line number Diff line
@@ -68,11 +68,11 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() {

            kosmos.shadeRepository.setShadeMode(ShadeMode.Single)
            assertThat(stackRounding)
                .isEqualTo(ShadeScrimRounding(roundTop = true, roundBottom = false))
                .isEqualTo(ShadeScrimRounding(isTopRounded = true, isBottomRounded = false))

            kosmos.shadeRepository.setShadeMode(ShadeMode.Split)
            assertThat(stackRounding)
                .isEqualTo(ShadeScrimRounding(roundTop = true, roundBottom = true))
                .isEqualTo(ShadeScrimRounding(isTopRounded = true, isBottomRounded = true))
        }

    @Test(expected = IllegalStateException::class)
+8 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.common.ui.view

import android.view.View
import kotlinx.coroutines.DisposableHandle

/**
 * Set this view's [View#importantForAccessibility] to [View#IMPORTANT_FOR_ACCESSIBILITY_YES] or
@@ -43,3 +44,10 @@ inline fun <reified T : View> View.getNearestParent(): T? {
    }
    return null
}

/** Adds a [View.OnLayoutChangeListener] and provides a [DisposableHandle] for teardown. */
fun View.onLayoutChanged(onLayoutChanged: (v: View) -> Unit): DisposableHandle {
    val listener = View.OnLayoutChangeListener { v, _, _, _, _, _, _, _, _ -> onLayoutChanged(v) }
    addOnLayoutChangeListener(listener)
    return DisposableHandle { removeOnLayoutChangeListener(listener) }
}
+7 −3
Original line number Diff line number Diff line
@@ -1588,7 +1588,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
     * @param forceClockUpdate Should the clock be updated even when not on keyguard
     */
    private void positionClockAndNotifications(boolean forceClockUpdate) {
        boolean animate = mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
        boolean animate = !SceneContainerFlag.isEnabled()
                && mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
        int stackScrollerPadding;
        boolean onKeyguard = isKeyguardShowing();

@@ -1675,7 +1676,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                mClockPositionResult.clockX, mClockPositionResult.clockY);
        }

        boolean animate = mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
        boolean animate = !SceneContainerFlag.isEnabled()
                && mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
        boolean animateClock = (animate || mAnimateNextPositionUpdate) && shouldAnimateClockChange;

        if (!MigrateClocksToBlueprint.isEnabled()) {
@@ -3963,7 +3965,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
            mShadeRepository.setLegacyShadeExpansion(mExpandedFraction);
            mQsController.setShadeExpansion(mExpandedHeight, mExpandedFraction);
            mExpansionDragDownAmountPx = h;
            if (!SceneContainerFlag.isEnabled()) {
                mAmbientState.setExpansionFraction(mExpandedFraction);
            }
            onHeightUpdated(mExpandedHeight);
            updateExpansionAndVisibility();
        });
Loading