am 66b4c5bb: Implement removeNotification.
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user