diff options
-rw-r--r-- | packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java | 18 | ||||
-rw-r--r-- | packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java | 22 |
2 files changed, 37 insertions, 3 deletions
diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java index ae71bda..5c7a90c 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java @@ -30,8 +30,8 @@ public class NotificationData { public static final class Entry { public IBinder key; public StatusBarNotification notification; - public StatusBarIconView icon; public View expanded; + public StatusBarIconView icon; } private final ArrayList<Entry> mEntries = new ArrayList<Entry>(); @@ -43,16 +43,30 @@ public class NotificationData { return mEntries.get(index); } - public int add(IBinder key, StatusBarNotification notification, View expanded) { + public int add(IBinder key, StatusBarNotification notification, View expanded, + StatusBarIconView icon) { Entry entry = new Entry(); entry.key = key; entry.notification = notification; entry.expanded = expanded; + entry.icon = icon; final int index = chooseIndex(notification.notification.when); mEntries.add(index, entry); return index; } + public Entry remove(IBinder key) { + final int N = mEntries.size(); + for (int i=0; i<N; i++) { + Entry entry = mEntries.get(i); + if (entry.key == key) { + mEntries.remove(i); + return entry; + } + } + return null; + } + private int chooseIndex(final long when) { final int N = mEntries.size(); for (int i=0; i<N; i++) { diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java index 97b38b6..bd9ecb6 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java @@ -341,7 +341,7 @@ public class PhoneStatusBarService extends StatusBarService { iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel)); // Add the expanded view. - final int viewIndex = list.add(key, notification, view); + final int viewIndex = list.add(key, notification, view, iconView); parent.addView(view, viewIndex); // Add the icon. final int iconIndex = chooseIconIndex(isOngoing, viewIndex); @@ -359,6 +359,26 @@ public class PhoneStatusBarService extends StatusBarService { } public void removeNotification(IBinder key) { + Slog.d(TAG, "removeNotification key=" + key); + NotificationData.Entry entry = mOngoing.remove(key); + if (entry == null) { + entry = mLatest.remove(key); + if (entry == null) { + Slog.w(TAG, "removeNotification for nonexistent key: " + key); + return; + } + } + // Remove the expanded view. + ((ViewGroup)entry.expanded.getParent()).removeView(entry.expanded); + // Remove the icon. + ((ViewGroup)entry.icon.getParent()).removeView(entry.icon); + + // Cancel the ticker if it's still running + // TODO + + // Recalculate the position of the sliding windows and the titles. + setAreThereNotifications(); + updateExpandedViewPos(EXPANDED_LEAVE_ALONE); } /** |