lzanita09 / NotificationPeekPort

Port Paranoid Android's Notification Peek feature to an apk and make it compatible with any Kit-Kat ROM.
Apache License 2.0
120 stars 29 forks source link

Grouping of Notifications #14

Closed ddantzler closed 10 years ago

ddantzler commented 10 years ago

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.

lzanita09 commented 10 years ago

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.

ddantzler commented 10 years ago

Cool cool. Love the new look by the way.

lzanita09 commented 10 years ago

Me too, Jeppe is awesome.

ddantzler commented 10 years ago

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. :+1:

lzanita09 commented 10 years ago

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.

ddantzler commented 10 years ago

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.

lzanita09 commented 10 years ago

I've uploaded the code and apk.

ddantzler commented 10 years ago

Works great so far man. Thanks!

ddantzler commented 10 years ago

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

lzanita09 commented 10 years ago

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.

lzanita09 commented 10 years ago

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.

ddantzler commented 10 years ago

Works beautifully.