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

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

Keep FSI HUNs visible in the shade regardless the scroll position

HUNs with an FSI will remain pinned, regardless whether the shade is
open, or if we've called ENR#markHeadsUpSeen() on them.
Pinned HUNs are always clamped to the minHeadsUpInset, meaning that they
can never be overscrolled offscreen, but their z-translation was never
adjusted, after they have been marked as seen. This was causing a visual
bug, where we were scrolling stack's content collided with the pinned HUN.

This CL changes fixes the z translation by making the FSI HUNs return
true for ENR#mustStayOnScreen(), thus forcing the StackScrollAlgorithm
to keep it visible to the user.

Fixes: 385041854
Flag: com.android.systemui.notifications_pinned_hun_in_shade
Test: ensure that FSI HUNs are displayed correctly in the shade
	- open the shade
	- scroll up the stack
	- receive a HUN with FSI
Test: ensure that regular HUNs are displayed correctly in the shade
        - open the shade
	- scroll up the stack
	- receive a HUN (without FSI)
Change-Id: I32b3ba20d2b42c8c984575b702b5c54db27912af
parent a8e18bc7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -192,6 +192,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;
@@ -3179,7 +3180,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);