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

Commit 24f8d93b authored by Steve Elliott's avatar Steve Elliott
Browse files

Reinflate notif when [un]marked as conversation

Fixes: 152799132
Test: manual, visual
Change-Id: Ie5bfc2f6ed3979398bef9f819b08ddc4fc1bf3df
parent 6e278add
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -38,10 +38,12 @@ public class NotificationUiAdjustment {
    public final String key;
    public final List<Notification.Action> smartActions;
    public final List<CharSequence> smartReplies;
    public final boolean isConversation;

    @VisibleForTesting
    NotificationUiAdjustment(
            String key, List<Notification.Action> smartActions, List<CharSequence> smartReplies) {
            String key, List<Notification.Action> smartActions, List<CharSequence> smartReplies,
            boolean isConversation) {
        this.key = key;
        this.smartActions = smartActions == null
                ? Collections.emptyList()
@@ -49,12 +51,14 @@ public class NotificationUiAdjustment {
        this.smartReplies = smartReplies == null
                ? Collections.emptyList()
                : smartReplies;
        this.isConversation = isConversation;
    }

    public static NotificationUiAdjustment extractFromNotificationEntry(
            NotificationEntry entry) {
        return new NotificationUiAdjustment(
                entry.getKey(), entry.getSmartActions(), entry.getSmartReplies());
                entry.getKey(), entry.getSmartActions(), entry.getSmartReplies(),
                entry.getRanking().isConversation());
    }

    public static boolean needReinflate(
@@ -63,6 +67,9 @@ public class NotificationUiAdjustment {
        if (oldAdjustment == newAdjustment) {
            return false;
        }
        if (oldAdjustment.isConversation != newAdjustment.isConversation) {
            return true;
        }
        if (areDifferent(oldAdjustment.smartActions, newAdjustment.smartActions)) {
            return true;
        }
+31 −2
Original line number Diff line number Diff line
@@ -188,6 +188,30 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase {
                .isFalse();
    }

    @Test
    public void needReinflate_bothConversation() {
        assertThat(NotificationUiAdjustment.needReinflate(
                createUiAdjustmentForConversation("first", true),
                createUiAdjustmentForConversation("first", true)))
                .isFalse();
    }

    @Test
    public void needReinflate_neitherConversation() {
        assertThat(NotificationUiAdjustment.needReinflate(
                createUiAdjustmentForConversation("first", false),
                createUiAdjustmentForConversation("first", false)))
                .isFalse();
    }

    @Test
    public void needReinflate_differentIsConversation() {
        assertThat(NotificationUiAdjustment.needReinflate(
                createUiAdjustmentForConversation("first", false),
                createUiAdjustmentForConversation("first", true)))
                .isTrue();
    }

    private Notification.Action.Builder createActionBuilder(
            String title, int drawableRes, PendingIntent pendingIntent) {
        return new Notification.Action.Builder(
@@ -200,11 +224,16 @@ public class NotificationUiAdjustmentTest extends SysuiTestCase {

    private NotificationUiAdjustment createUiAdjustmentFromSmartActions(
            String key, List<Notification.Action> actions) {
        return new NotificationUiAdjustment(key, actions, null);
        return new NotificationUiAdjustment(key, actions, null, false);
    }

    private NotificationUiAdjustment createUiAdjustmentFromSmartReplies(
            String key, CharSequence[] replies) {
        return new NotificationUiAdjustment(key, null, Arrays.asList(replies));
        return new NotificationUiAdjustment(key, null, Arrays.asList(replies), false);
    }

    private NotificationUiAdjustment createUiAdjustmentForConversation(
            String key, boolean isConversation) {
        return new NotificationUiAdjustment(key, null, null, isConversation);
    }
}