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

Commit 7d96c65d authored by Danny Baumann's avatar Danny Baumann
Browse files

Close notification view when swiping away the last notification.

If the user swiped away all swipable notifications, chances are high he
expanded the notification area just for doing so.
parent 59755678
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class NotificationData {
        public View row; // the outer expanded view
        public View content; // takes the click events and sends the PendingIntent
        public View expanded; // the inflated RemoteViews
        public boolean cancelled;
    }
    private final ArrayList<Entry> mEntries = new ArrayList<Entry>();

@@ -66,6 +67,7 @@ public class NotificationData {
        entry.content = content;
        entry.expanded = expanded;
        entry.icon = icon;
        entry.cancelled = false;
        final int index = chooseIndex(notification.notification.when);
        mEntries.add(index, entry);
        return index;
+12 −3
Original line number Diff line number Diff line
@@ -716,7 +716,7 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        }
    }

    View[] makeNotificationView(final StatusBarNotification notification, ViewGroup parent) {
    View[] makeNotificationView(final IBinder key, final StatusBarNotification notification, ViewGroup parent) {
        Notification n = notification.notification;
        RemoteViews remoteViews = n.contentView;
        if (remoteViews == null) {
@@ -731,6 +731,11 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
                public void run() {
                    try {
                        mBarService.onNotificationClear(notification.pkg, notification.tag, notification.id);

                        int index = mLatest.findEntry(key);
                        if (index >= 0) {
                            mLatest.getEntryAt(index).cancelled = true;
                        }
                     } catch (RemoteException e) {
                        // Skip it, don't crash.
                    }
@@ -780,7 +785,7 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
            parent = mLatestItems;
        }
        // Construct the expanded view.
        final View[] views = makeNotificationView(notification, parent);
        final View[] views = makeNotificationView(key, notification, parent);
        if (views == null) {
            handleNotificationError(key, notification, "Couldn't expand RemoteViews for: "
                    + notification);
@@ -821,6 +826,10 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        // Remove the icon.
        ((ViewGroup)entry.icon.getParent()).removeView(entry.icon);

        if (entry.cancelled && !mLatest.hasClearableItems()) {
            animateCollapse();
        }

        return entry.notification;
    }