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

Commit 7d300795 authored by András Kurucz's avatar András Kurucz Committed by Automerger Merge Worker
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 am: ccb4330c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24526910



Change-Id: Icd3e8b94b1ff179d10c1dcefecb4e46faa03e98c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f3f8760c ccb4330c
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -497,14 +497,14 @@ public class StackScrollAlgorithm {
        return stackHeight / stackEndHeight;
        return stackHeight / stackEndHeight;
    }
    }


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