Grouping of Notifications
Closed this issue · 12 comments
I don't have PA, but looking at videos such as this one:
https://www.youtube.com/watch?v=ypxg1P0lJ1g
It appears like the notifications from the same app get grouped.
In NotificationPeek, it seems they are getting grouped, but somethings not working quite right.
https://www.youtube.com/watch?v=BXVADYnv_BE
My video is boring, and it jumps from 1 Gmail notification to 3, because I sent 2 really quick. However, you get the idea of the differences between the two.
Ah that's right! Currently the notifications are not grouped, the case you saw that some of them were grouped is simply caused by the original notifications are removed automatically.
Right now I have a ArrayList that stores all notifications that are unread, I can change to use a HashMap and only store one instance of the notification (the latest one). This will also matches the behavior of removing notifications, because I remove all notifications from the same app at the same time.
Cool cool. Love the new look by the way.
Me too, Jeppe is awesome.
Looking back at the first video of the review of Peek, it would seem that they may be doing that as well. The grouping is occuring automatically, and they are simply showing only the last notification per app. Using the HashMap methodology that you described should work beautifully. 👍
I have updated the code for changes we discussed here. I also tried to replace the original Peek implementation of single tap blank space to unlock with double-tap to unlock. It's a little late here, I'll update the code and apk when I get up in 6 hours.
Wow man you are fast! Double-tap to unlock will be sweet. When trying to select a notification, it's easy to accidentally unlock with single-tap. Double-tap should solve that. Looking forward to this update in the AM.
I've uploaded the code and apk.
Works great so far man. Thanks!
Looked at this a little more, and while it works great, the notifications are being displayed in what appears to be reverse of the order that they should be. IE: In Peek, the notifications show up from oldest to newest, left to right. Right now, NotificationPeek is showing up with the newest on the left. Was going to fork and help you out, but I'm honestly a better tester than Android developer. Maybe I'll dive in some other time. Researching this problem though, my understanding is that HashMap has a non-deterministic iteration order and you may need to use LinkedHashMap instead.
http://developer.android.com/reference/java/util/HashMap.html
That's right, HashMap doesn't guarantee the order of iteration. Maybe a LinkedHashMap. Or maybe our own data structure, which can update according to the new notifications.
Code and apk updated. I added a Comparator, and let NotificationHub returns a sorted list of notifications instead of a set of notifications without order.
Works beautifully.