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

Commit d3f525dc authored by Valentin Iftime's avatar Valentin Iftime
Browse files

Increase gap height between expanded bundles

Flag: com.android.systemui.notification_bundle_ui

Test: atest StackScrollAlgorithmTest

Bug: 427744345
Change-Id: I0c4792d47026dadc6440d0576e9c15fee5ff69b8
parent 5d23bdf5
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    private val notifSectionDividerGap = px(R.dimen.notification_section_divider_height)
    private val bundleGap = px(R.dimen.bundle_divider_height)
    private val bundleExpandedGap = px(R.dimen.bundle_expanded_divider_height)
    private val scrimPadding = px(R.dimen.notification_side_paddings)
    private val baseZ by lazy { ambientState.baseZHeight }
    private val headsUpZ = px(R.dimen.heads_up_pinned_elevation)
@@ -426,6 +427,58 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {
        assertThat(gapHeight).isEqualTo(0f) // childNeedsGapHeight should return false
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getGapHeightForChild_returnsBundleExpandedGapHeight_whenChildIsExpandedBundle() {
        // Assemble
        val child = mock<ExpandableNotificationRow>()
        val previousChild = mock<View>()
        whenever(child.isBundle()).thenReturn(true)
        whenever(child.isGroupExpanded()).thenReturn(true)
        whenever(kosmos.stackScrollAlgorithmSectionProvider.beginsSection(any(), any()))
            .thenReturn(false)

        // Act
        val gapHeight =
            stackScrollAlgorithm.getGapHeightForChild(
                kosmos.stackScrollAlgorithmSectionProvider,
                1,
                child,
                previousChild,
                0.5f,
                false,
            )

        // Assert
        assertThat(gapHeight).isEqualTo(bundleExpandedGap)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getGapHeightForChild_returnsBundleExpandedGapHeight_whenPreviousChildIsExpandedBundle() {
        // Assemble
        val child = mock<View>()
        val previousChild = mock<ExpandableNotificationRow>()
        whenever(previousChild.isBundle()).thenReturn(true) // Previous child is a bundle
        whenever(previousChild.isGroupExpanded()).thenReturn(true)
        whenever(kosmos.stackScrollAlgorithmSectionProvider.beginsSection(any(), any()))
            .thenReturn(false)

        // Act
        val gapHeight =
            stackScrollAlgorithm.getGapHeightForChild(
                kosmos.stackScrollAlgorithmSectionProvider,
                1,
                child,
                previousChild,
                0.5f,
                false,
            )

        // Assert
        assertThat(gapHeight).isEqualTo(bundleExpandedGap)
    }

    @Test
    @EnableSceneContainer
    fun resetViewStates_childPositionedAtStackTop() {
+3 −0
Original line number Diff line number Diff line
@@ -815,6 +815,9 @@
    <!-- The *additional* height of the divider between bundles. -->
    <dimen name="bundle_divider_height">2dp</dimen>

    <!-- The *additional* height of the divider between bundles when expanded. -->
    <dimen name="bundle_expanded_divider_height">6dp</dimen>

    <!-- The min distance the notifications should be from the lock icon on the lock screen. -->
    <dimen name="min_lock_icon_padding">48dp</dimen>

+14 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class StackScrollAlgorithm {

    private float mPaddingBetweenElements;
    private float mBundleGapHeight;
    private float mBundleExpandedGapHeight;
    private float mGapHeight;
    private float mGapHeightOnLockscreen;
    private int mCollapsedSize;
@@ -118,6 +119,8 @@ public class StackScrollAlgorithm {
                R.dimen.notification_section_divider_height_lockscreen);
        mBundleGapHeight = res.getDimensionPixelSize(
                R.dimen.bundle_divider_height);
        mBundleExpandedGapHeight = res.getDimensionPixelSize(
                R.dimen.bundle_expanded_divider_height);
        mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
        mMarginBottom = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
        mQuickQsOffsetHeight = SystemBarUtils.getQuickQsOffsetHeight(context);
@@ -826,7 +829,11 @@ public class StackScrollAlgorithm {
            boolean onKeyguard) {

        if (NotificationBundleUi.isEnabled() && childNeedsBundleGap(child, previousChild))  {
            if (childNeedsBundleExpandedGap(child, previousChild)) {
                return mBundleExpandedGapHeight;
            } else {
                return mBundleGapHeight;
            }
        } else if (childNeedsGapHeight(sectionProvider, visibleIndex, child, previousChild)) {
            return getGapForLocation(fractionToShade, onKeyguard);
        } else {
@@ -840,6 +847,12 @@ public class StackScrollAlgorithm {
                && !(child instanceof FooterView);
    }

    private boolean childNeedsBundleExpandedGap(View child, View previousChild) {
        return ((isBundle(child) && ((ExpandableNotificationRow) child).isGroupExpanded())
            || (isBundle(previousChild)
                    && ((ExpandableNotificationRow) previousChild).isGroupExpanded()));
    }

    private boolean isBundle(View view) {
        return view instanceof ExpandableNotificationRow
                && ((ExpandableNotificationRow) view).isBundle();