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

Commit 0ad5b9de authored by Mady Mellor's avatar Mady Mellor
Browse files

NotificationEntryListener: pre & post onEntryUpdated

Some of the listeners care about doing things to notifications prior
to the entries being filtered and some of them care about it after the
entries are filtered.

This CL introduces new method onPreEntryUpdated and alters the existing
method to be onPostEntryUpdated so that listeners can know about both
events.

Test: atest NotificationEntryManagerTest#estUpdateNotification_prePostEntryOrder
Change-Id: Ifa56fbf27cbc8f58c8eda9c95c79a57f1a52c9ac
parent 634d8656
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class ForegroundServiceNotificationListener {
            }

            @Override
            public void onEntryUpdated(NotificationEntry entry) {
            public void onPostEntryUpdated(NotificationEntry entry) {
                updateNotification(entry.notification, entry.importance);
            }

+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class NotificationAlertingManager {
            }

            @Override
            public void onEntryUpdated(NotificationEntry entry) {
            public void onPostEntryUpdated(NotificationEntry entry) {
                updateAlertState(entry);
            }

+8 −2
Original line number Diff line number Diff line
@@ -40,9 +40,15 @@ public interface NotificationEntryListener {
    }

    /**
     * Called when a notification was updated.
     * Called when a notification is updated, before any filtering of notifications have occurred.
     */
    default void onEntryUpdated(NotificationEntry entry) {
    default void onPreEntryUpdated(NotificationEntry entry) {
    }

    /**
     * Called when a notification was updated, after any filtering of notifications have occurred.
     */
    default void onPostEntryUpdated(NotificationEntry entry) {
    }

    /**
+5 −1
Original line number Diff line number Diff line
@@ -463,6 +463,10 @@ public class NotificationEntryManager implements
        getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification),
                mNotificationData.get(entry.key) != null);

        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onPreEntryUpdated(entry);
        }

        updateNotifications();

        if (DEBUG) {
@@ -473,7 +477,7 @@ public class NotificationEntryManager implements
        }

        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onEntryUpdated(entry);
            listener.onPostEntryUpdated(entry);
        }

        maybeScheduleUpdateNotificationViews(entry);
+1 −1
Original line number Diff line number Diff line
@@ -521,7 +521,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd

        mEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
            public void onEntryUpdated(NotificationEntry entry) {
            public void onPostEntryUpdated(NotificationEntry entry) {
                if (!entry.notification.isClearable()) {
                    // The user may have performed a dismiss action on the notification, since it's
                    // not clearable we should snap it back.
Loading