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

Commit ccb4330c authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "Keep the shade footer visible during clear-all, if there is a button to...

Merge "Keep the shade footer visible during clear-all, if there is a button to display" into udc-qpr-dev
parents 63153a29 5646c5ad
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -497,14 +497,14 @@ public class StackScrollAlgorithm {
        return stackHeight / stackEndHeight;
    }

    private boolean hasNonDismissableNotifs(StackScrollAlgorithmState algorithmState) {
    private boolean hasNonClearableNotifs(StackScrollAlgorithmState algorithmState) {
        for (int i = 0; i < algorithmState.visibleChildren.size(); i++) {
            View child = algorithmState.visibleChildren.get(i);
            if (!(child instanceof ExpandableNotificationRow)) {
                continue;
            }
            final ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (!row.canViewBeDismissed()) {
            if (!row.canViewBeCleared()) {
                return true;
            }
        }
@@ -579,7 +579,7 @@ public class StackScrollAlgorithm {
                ((FooterView.FooterViewState) viewState).hideContent =
                        isShelfShowing || noSpaceForFooter
                                || (ambientState.isClearAllInProgress()
                                && !hasNonDismissableNotifs(algorithmState));
                                && !hasNonClearableNotifs(algorithmState));
            }
        } else {
            if (view instanceof EmptyShadeView) {
+54 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ import com.android.systemui.statusbar.NotificationShelf
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.row.FooterView
import com.android.systemui.statusbar.notification.row.FooterView.FooterViewState
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.util.mockito.mock
import com.google.common.truth.Expect
@@ -47,6 +49,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
    private val emptyShadeView = EmptyShadeView(context, /* attrs= */ null).apply {
        layout(/* l= */ 0, /* t= */ 0, /* r= */ 100, /* b= */ 100)
    }
    private val footerView = FooterView(context, /*attrs=*/null)
    private val ambientState = AmbientState(
            context,
            dumpManager,
@@ -324,6 +327,57 @@ class StackScrollAlgorithmTest : SysuiTestCase() {
        assertThat(notificationRow.viewState.alpha).isEqualTo(expected)
    }

    @Test
    fun resetViewStates_noSpaceForFooter_footerHidden() {
        ambientState.isShadeExpanded = true
        ambientState.stackEndHeight = 0f // no space for the footer in the stack
        hostView.addView(footerView)

        stackScrollAlgorithm.resetViewStates(ambientState, 0)

        assertThat((footerView.viewState as FooterViewState).hideContent).isTrue()
    }

    @Test
    fun resetViewStates_clearAllInProgress_hasNonClearableRow_footerVisible() {
        whenever(notificationRow.canViewBeCleared()).thenReturn(false)
        ambientState.isClearAllInProgress = true
        ambientState.isShadeExpanded = true
        ambientState.stackEndHeight = 1000f // plenty space for the footer in the stack
        hostView.addView(footerView)

        stackScrollAlgorithm.resetViewStates(ambientState, 0)

        assertThat(footerView.viewState.hidden).isFalse()
        assertThat((footerView.viewState as FooterViewState).hideContent).isFalse()
    }

    @Test
    fun resetViewStates_clearAllInProgress_allRowsClearable_footerHidden() {
        whenever(notificationRow.canViewBeCleared()).thenReturn(true)
        ambientState.isClearAllInProgress = true
        ambientState.isShadeExpanded = true
        ambientState.stackEndHeight = 1000f // plenty space for the footer in the stack
        hostView.addView(footerView)

        stackScrollAlgorithm.resetViewStates(ambientState, 0)

        assertThat((footerView.viewState as FooterViewState).hideContent).isTrue()
    }

    @Test
    fun resetViewStates_clearAllInProgress_allRowsRemoved_emptyShade_footerHidden() {
        ambientState.isClearAllInProgress = true
        ambientState.isShadeExpanded = true
        ambientState.stackEndHeight = 1000f // plenty space for the footer in the stack
        hostView.removeAllViews() // remove all rows
        hostView.addView(footerView)

        stackScrollAlgorithm.resetViewStates(ambientState, 0)

        assertThat((footerView.viewState as FooterViewState).hideContent).isTrue()
    }

    @Test
    fun getGapForLocation_onLockscreen_returnsSmallGap() {
        val gap = stackScrollAlgorithm.getGapForLocation(