Bug 921776 - Forced notifications to keep the same timestamp to preserve the order they are displayed in; fixed current notification mechanism in notification handler to update correctly the current foreground notification; r=wesj

This commit is contained in:
Federico Paolinelli
2013-10-14 13:38:57 -07:00
parent 2328fbc55e
commit 60f2a5e45a
2 changed files with 11 additions and 6 deletions

View File

@@ -33,6 +33,7 @@ public class NotificationHandler {
* one download is in progress.
*/
private Notification mForegroundNotification;
private int mForegroundNotificationId;
public NotificationHandler(Context context) {
mContext = context;
@@ -168,23 +169,26 @@ public class NotificationHandler {
}
protected void setForegroundNotification(int id, Notification notification) {
mForegroundNotificationId = id;
mForegroundNotification = notification;
}
private void updateForegroundNotification(int id, Notification oldNotification) {
if (mForegroundNotification == oldNotification) {
private void updateForegroundNotification(int oldId, Notification oldNotification) {
if (mForegroundNotificationId == oldId) {
// If we're removing the notification associated with the
// foreground, we need to pick another active notification to act
// as the foreground notification.
Notification foregroundNotification = null;
for (final Notification notification : mNotifications.values()) {
int foregroundId = 0;
for (final Integer id : mNotifications.keySet()) {
final Notification notification = mNotifications.get(id);
if (isOngoing(notification)) {
foregroundNotification = notification;
foregroundId = id;
break;
}
}
setForegroundNotification(id, foregroundNotification);
setForegroundNotification(foregroundId, foregroundNotification);
}
}
}