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

Commit b8bd6954 authored by András Kurucz's avatar András Kurucz
Browse files

[Flexiglass] Correct NSSL#drawBounds for the horizontal padding of the NSSL

The received bounds from the placeholder are relative to the window, but NSSL.setDrawBounds
expects a rect that's relativet to the NSSL itself. This CL offsets these bounds in case the
NSSL has some horizontal margins e.g. in floating DualShade.

Bug: 417965077
Test: check the box drawn by the debug lines in all shade modes
Flag: com.android.systemui.scene_container
Change-Id: I925513e56c95ebe3a3c08bddf6ea34ffcb6e8317
parent 4294ec5e
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -262,8 +262,7 @@ fun ContentScope.ConstrainedNotificationStack(
                .onSizeChanged { viewModel.onConstrainedAvailableSpaceChanged(it.height) }
                .onGloballyPositioned {
                    if (shouldUseLockscreenStackBounds(layoutState.transitionState)) {
                        // TODO(417965077) correct drawBounds for the horizontal padding of the NSSL
                        stackScrollView.setDrawBounds(it.boundsInWindow().toAndroidRectF())
                        stackScrollView.updateDrawBounds(it.boundsInWindow().toAndroidRectF())
                    }
                }
    ) {
@@ -634,8 +633,7 @@ fun ContentScope.NotificationScrollingStack(
                    )
                    .onGloballyPositioned {
                        if (!shouldUseLockscreenStackBounds(layoutState.transitionState)) {
                            // TODO(417965077) correct for the horizontal padding of the NSSL
                            stackScrollView.setDrawBounds(it.boundsInWindow().toAndroidRectF())
                            stackScrollView.updateDrawBounds(it.boundsInWindow().toAndroidRectF())
                        }
                    }
                    .debugBackground(viewModel, DEBUG_BOX_COLOR)
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ constructor(
                notificationStackScrolLView.get().apply {
                    // use -headsUpInset to allow HUN translation outside bounds for snoozing
                    setStackTop(-headsUpInset)
                    setDrawBounds(RectF())
                    updateDrawBounds(RectF())
                }
            }
        }
+5 −5
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {

        // WHEN stackBottom changes
        final float newStackBottom = 800;
        mStackScroller.setDrawBounds(new RectF(0, stackTop, 400, newStackBottom));
        mStackScroller.updateDrawBounds(new RectF(0, stackTop, 400, newStackBottom));

        // THEN stackEndHeight is updated
        final float newStackHeight = newStackBottom - stackTop;
@@ -467,7 +467,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        float stackHeight = stackBottom - stackTop;
        float stackWidth = 400;
        mStackScroller.setStackTop(stackTop);
        mStackScroller.setDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));
        mStackScroller.updateDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));

        // When: panel is expanding
        mStackScroller.setExpandFraction(expandFraction);
@@ -496,7 +496,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        float stackHeight = stackBottom - stackTop;
        float stackWidth = 400;
        mStackScroller.setStackTop(stackTop);
        mStackScroller.setDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));
        mStackScroller.updateDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));

        // When: panel is fully expanded
        mStackScroller.setExpandFraction(expandFraction);
@@ -1059,7 +1059,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        float stackWidth = 400;
        float stackViewPortHeight = stackBottom - stackTop;
        mStackScroller.setStackTop(stackTop);
        mStackScroller.setDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));
        mStackScroller.updateDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));
        when(mStackSizeCalculator.computeHeight(
                eq(mStackScroller),
                eq(-1),
@@ -1097,7 +1097,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        float stackBottom = 1100;
        float stackWidth = 400;
        mStackScroller.setStackTop(stackTop);
        mStackScroller.setDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));
        mStackScroller.updateDrawBounds(new RectF(0, stackTop, stackWidth, stackBottom));

        // Given we have a limit on max displayed notifications
        int stackHeightBeforeUpdate = 100;
+4 −1
Original line number Diff line number Diff line
@@ -1273,8 +1273,11 @@ public class NotificationStackScrollLayout
    }

    @Override
    public void setDrawBounds(@NotNull RectF drawBounds) {
    public void updateDrawBounds(@NotNull RectF drawBounds) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        // The received drawBounds are relative to the Window, but NSSL  expects a rect relative to
        // its own position, so we need to offset it in case the NSSL has some horizontal margins.
        drawBounds.offset(-getX(), 0f);
        if (mAmbientState.getDrawBounds() != drawBounds) {
            mAmbientState.setDrawBounds(drawBounds);
            updateStackEndHeightAndStackHeight(mAmbientState.getExpansionFraction());
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ interface NotificationScrollView {
    fun setStackTop(stackTop: Float)

    /** set the area where this can place its content */
    fun setDrawBounds(bounds: RectF)
    fun updateDrawBounds(boundsInWindow: RectF)

    /** set the y position in px of the top of the HUN in this view's coordinates */
    fun setHeadsUpTop(headsUpTop: Float)