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

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

Merge "Keep FSI HUNs visible in the shade regardless the scroll position" into main

parents f0f09aac af97f126
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -185,6 +185,16 @@ flag {
   }
}

flag {
    name: "notifications_pinned_hun_in_shade"
    namespace: "systemui"
    description: "Fixes displaying pinned HUNs in the Shade, making sure that their y and z positions are correct."
    bug: "385041854"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
   name: "pss_app_selector_recents_split_screen"
   namespace: "systemui"
+5 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.Notification.Action.SEMANTIC_ACTION_MARK_CONVERSATION_
import static android.service.notification.NotificationListenerService.REASON_CANCEL;

import static com.android.systemui.flags.Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE;
import static com.android.systemui.Flags.notificationsPinnedHunInShade;
import static com.android.systemui.statusbar.notification.collection.NotificationEntry.DismissState.PARENT_DISMISSED;
import static com.android.systemui.statusbar.notification.row.NotificationContentView.VISIBLE_TYPE_HEADSUP;
import static com.android.systemui.statusbar.policy.RemoteInputView.FOCUS_ANIMATION_MIN_SCALE;
@@ -3184,7 +3185,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    @Override
    public boolean mustStayOnScreen() {
        return mIsHeadsUp && mMustStayOnScreen;
        // Must stay on screen in the open shade regardless how much the stack is scrolled if:
        // 1. Is HUN and not marked as seen yet (isHeadsUp && mustStayOnScreen)
        // 2. Is an FSI HUN (isPinned)
        return mIsHeadsUp && mMustStayOnScreen || notificationsPinnedHunInShade() && isPinned();
    }

    /**
+51 −0
Original line number Diff line number Diff line
@@ -941,6 +941,57 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
        assertThat(row.getImageResolver().getContext()).isSameInstanceAs(userContext);
    }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_NOTIFICATIONS_PINNED_HUN_IN_SHADE)
    public void mustStayOnScreen_false() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
        assertThat(row.mustStayOnScreen()).isFalse();
    }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_NOTIFICATIONS_PINNED_HUN_IN_SHADE)
    public void mustStayOnScreen_isHeadsUp_markedAsSeen() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
        // When the row is a HUN
        row.setHeadsUp(true);
        //Then it must stay on screen
        assertThat(row.mustStayOnScreen()).isTrue();
        // And when the user has seen it
        row.markHeadsUpSeen();
        // Then it should NOT stay on screen anymore
        assertThat(row.mustStayOnScreen()).isFalse();
    }

    @Test
    @EnableFlags(com.android.systemui.Flags.FLAG_NOTIFICATIONS_PINNED_HUN_IN_SHADE)
    public void mustStayOnScreen_isPinned_markedAsSeen() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
        // When a HUN is pinned
        row.setHeadsUp(true);
        row.setPinnedStatus(PinnedStatus.PinnedBySystem);
        //Then it must stay on screen
        assertThat(row.mustStayOnScreen()).isTrue();
        // And when the user has seen it
        row.markHeadsUpSeen();
        // Then it should still stay on screen
        assertThat(row.mustStayOnScreen()).isTrue();
    }

    @Test
    @DisableFlags(com.android.systemui.Flags.FLAG_NOTIFICATIONS_PINNED_HUN_IN_SHADE)
    public void mustStayOnScreen_isPinned_markedAsSeen_false() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();
        // When a HUN is pinned
        row.setHeadsUp(true);
        row.setPinnedStatus(PinnedStatus.PinnedBySystem);
        //Then it must stay on screen
        assertThat(row.mustStayOnScreen()).isTrue();
        // And when the user has seen it
        row.markHeadsUpSeen();
        // Then it should NOT stay on screen anymore
        assertThat(row.mustStayOnScreen()).isFalse();
    }

    private void setDrawableIconsInImageView(CachingIconView icon, Drawable iconDrawable,
            Drawable rightIconDrawable) {
        ImageView iconView = mock(ImageView.class);