am 6f922cbe
: Merge "Implement priority ordering in notifications." into honeycomb
* commit '6f922cbe823c19234bc15eea9ac709f399e9a63c': Implement priority ordering in notifications.
This commit is contained in:
@ -35,12 +35,18 @@ if (truncatedTicker != null && truncatedTicker.length() > maxTickerLen) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class StatusBarNotification implements Parcelable {
|
public class StatusBarNotification implements Parcelable {
|
||||||
|
public static int PRIORITY_JIFFY_EXPRESS = -100;
|
||||||
|
public static int PRIORITY_NORMAL = 0;
|
||||||
|
public static int PRIORITY_ONGOING = 100;
|
||||||
|
public static int PRIORITY_SYSTEM = 200;
|
||||||
|
|
||||||
public String pkg;
|
public String pkg;
|
||||||
public int id;
|
public int id;
|
||||||
public String tag;
|
public String tag;
|
||||||
public int uid;
|
public int uid;
|
||||||
public int initialPid;
|
public int initialPid;
|
||||||
public Notification notification;
|
public Notification notification;
|
||||||
|
public int priority = PRIORITY_NORMAL;
|
||||||
|
|
||||||
public StatusBarNotification() {
|
public StatusBarNotification() {
|
||||||
}
|
}
|
||||||
@ -56,6 +62,9 @@ public class StatusBarNotification implements Parcelable {
|
|||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
this.initialPid = initialPid;
|
this.initialPid = initialPid;
|
||||||
this.notification = notification;
|
this.notification = notification;
|
||||||
|
|
||||||
|
this.priority = ((notification.flags & Notification.FLAG_ONGOING_EVENT) != 0)
|
||||||
|
? PRIORITY_ONGOING : PRIORITY_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusBarNotification(Parcel in) {
|
public StatusBarNotification(Parcel in) {
|
||||||
@ -72,6 +81,7 @@ public class StatusBarNotification implements Parcelable {
|
|||||||
}
|
}
|
||||||
this.uid = in.readInt();
|
this.uid = in.readInt();
|
||||||
this.initialPid = in.readInt();
|
this.initialPid = in.readInt();
|
||||||
|
this.priority = in.readInt();
|
||||||
this.notification = new Notification(in);
|
this.notification = new Notification(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +96,7 @@ public class StatusBarNotification implements Parcelable {
|
|||||||
}
|
}
|
||||||
out.writeInt(this.uid);
|
out.writeInt(this.uid);
|
||||||
out.writeInt(this.initialPid);
|
out.writeInt(this.initialPid);
|
||||||
|
out.writeInt(this.priority);
|
||||||
this.notification.writeToParcel(out, flags);
|
this.notification.writeToParcel(out, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +125,7 @@ public class StatusBarNotification implements Parcelable {
|
|||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StatusBarNotification(package=" + pkg + " id=" + id + " tag=" + tag
|
return "StatusBarNotification(package=" + pkg + " id=" + id + " tag=" + tag
|
||||||
+ " notification=" + notification + ")";
|
+ " notification=" + notification + " priority=" + priority + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOngoing() {
|
public boolean isOngoing() {
|
||||||
|
@ -48,7 +48,12 @@ public class NotificationData {
|
|||||||
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
|
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
|
||||||
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
|
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
|
||||||
public int compare(Entry a, Entry b) {
|
public int compare(Entry a, Entry b) {
|
||||||
return (int)(a.notification.notification.when - b.notification.notification.when);
|
final StatusBarNotification na = a.notification;
|
||||||
|
final StatusBarNotification nb = b.notification;
|
||||||
|
int priDiff = na.priority - nb.priority;
|
||||||
|
return (priDiff != 0)
|
||||||
|
? priDiff
|
||||||
|
: (int)(na.notification.when - nb.notification.when);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -670,7 +670,8 @@ public class TabletStatusBar extends StatusBar implements
|
|||||||
&& oldContentView.getLayoutId() == contentView.getLayoutId();
|
&& oldContentView.getLayoutId() == contentView.getLayoutId();
|
||||||
ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent();
|
ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent();
|
||||||
boolean orderUnchanged = notification.notification.when==oldNotification.notification.when
|
boolean orderUnchanged = notification.notification.when==oldNotification.notification.when
|
||||||
&& notification.isOngoing() == oldNotification.isOngoing();
|
&& notification.priority == oldNotification.priority;
|
||||||
|
// priority now encompasses isOngoing()
|
||||||
boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1;
|
boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1;
|
||||||
if (contentsUnchanged && (orderUnchanged || isLastAnyway)) {
|
if (contentsUnchanged && (orderUnchanged || isLastAnyway)) {
|
||||||
if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key);
|
if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key);
|
||||||
@ -1187,7 +1188,10 @@ public class TabletStatusBar extends StatusBar implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the icon.
|
// Add the icon.
|
||||||
mNotns.add(entry);
|
int pos = mNotns.add(entry);
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.d(TAG, "addNotificationViews: added at " + pos);
|
||||||
|
}
|
||||||
updateNotificationIcons();
|
updateNotificationIcons();
|
||||||
|
|
||||||
return iconView;
|
return iconView;
|
||||||
@ -1274,7 +1278,7 @@ public class TabletStatusBar extends StatusBar implements
|
|||||||
for (int i=0; i<toShow.size(); i++) {
|
for (int i=0; i<toShow.size(); i++) {
|
||||||
View v = toShow.get(i);
|
View v = toShow.get(i);
|
||||||
if (v.getParent() == null) {
|
if (v.getParent() == null) {
|
||||||
mPile.addView(toShow.get(i));
|
mPile.addView(v, N-1-i); // the notification panel has newest at the bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user