Merge "heads up notifications always take the top spot"
This commit is contained in:
@@ -818,10 +818,10 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
return entry.notification;
|
return entry.notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StatusBarIconView addNotificationViews(IBinder key,
|
protected NotificationData.Entry createNotificationViews(IBinder key,
|
||||||
StatusBarNotification notification) {
|
StatusBarNotification notification) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification);
|
Log.d(TAG, "createNotificationViews(key=" + key + ", notification=" + notification);
|
||||||
}
|
}
|
||||||
// Construct the icon.
|
// Construct the icon.
|
||||||
final StatusBarIconView iconView = new StatusBarIconView(mContext,
|
final StatusBarIconView iconView = new StatusBarIconView(mContext,
|
||||||
@@ -846,7 +846,10 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
+ notification);
|
+ notification);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addNotificationViews(NotificationData.Entry entry) {
|
||||||
// Add the expanded view and icon.
|
// Add the expanded view and icon.
|
||||||
int pos = mNotificationData.add(entry);
|
int pos = mNotificationData.add(entry);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -854,8 +857,10 @@ public abstract class BaseStatusBar extends SystemUI implements
|
|||||||
}
|
}
|
||||||
updateExpansionStates();
|
updateExpansionStates();
|
||||||
updateNotificationIcons();
|
updateNotificationIcons();
|
||||||
|
}
|
||||||
|
|
||||||
return iconView;
|
private void addNotificationViews(IBinder key, StatusBarNotification notification) {
|
||||||
|
addNotificationViews(createNotificationViews(key, notification));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateExpansionStates() {
|
protected void updateExpansionStates() {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class NotificationData {
|
|||||||
public View expanded; // the inflated RemoteViews
|
public View expanded; // the inflated RemoteViews
|
||||||
public ImageView largeIcon;
|
public ImageView largeIcon;
|
||||||
private View expandedBig;
|
private View expandedBig;
|
||||||
|
private boolean interruption;
|
||||||
public Entry() {}
|
public Entry() {}
|
||||||
public Entry(IBinder key, StatusBarNotification n, StatusBarIconView ic) {
|
public Entry(IBinder key, StatusBarNotification n, StatusBarIconView ic) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
@@ -58,6 +59,10 @@ public class NotificationData {
|
|||||||
public void setUserLocked(boolean userLocked) {
|
public void setUserLocked(boolean userLocked) {
|
||||||
row.setUserLocked(userLocked);
|
row.setUserLocked(userLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInterruption() {
|
||||||
|
interruption = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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>() {
|
||||||
@@ -66,9 +71,13 @@ public class NotificationData {
|
|||||||
final StatusBarNotification na = a.notification;
|
final StatusBarNotification na = a.notification;
|
||||||
final StatusBarNotification nb = b.notification;
|
final StatusBarNotification nb = b.notification;
|
||||||
int d = na.getScore() - nb.getScore();
|
int d = na.getScore() - nb.getScore();
|
||||||
return (d != 0)
|
if (a.interruption != b.interruption) {
|
||||||
? d
|
return a.interruption ? 1 : -1;
|
||||||
: (int)(na.getNotification().when - nb.getNotification().when);
|
} else if (d != 0) {
|
||||||
|
return d;
|
||||||
|
} else {
|
||||||
|
return (int) (na.getNotification().when - nb.getNotification().when);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -897,15 +897,17 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
|
|
||||||
public void addNotification(IBinder key, StatusBarNotification notification) {
|
public void addNotification(IBinder key, StatusBarNotification notification) {
|
||||||
if (DEBUG) Log.d(TAG, "addNotification score=" + notification.getScore());
|
if (DEBUG) Log.d(TAG, "addNotification score=" + notification.getScore());
|
||||||
StatusBarIconView iconView = addNotificationViews(key, notification);
|
Entry shadeEntry = createNotificationViews(key, notification);
|
||||||
if (iconView == null) return;
|
if (shadeEntry == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mUseHeadsUp && shouldInterrupt(notification)) {
|
if (mUseHeadsUp && shouldInterrupt(notification)) {
|
||||||
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
|
if (DEBUG) Log.d(TAG, "launching notification in heads up mode");
|
||||||
Entry interruptionCandidate = new Entry(key, notification, null);
|
Entry interruptionCandidate = new Entry(key, notification, null);
|
||||||
if (inflateViews(interruptionCandidate, mHeadsUpNotificationView.getHolder())) {
|
if (inflateViews(interruptionCandidate, mHeadsUpNotificationView.getHolder())) {
|
||||||
mInterruptingNotificationTime = System.currentTimeMillis();
|
mInterruptingNotificationTime = System.currentTimeMillis();
|
||||||
mInterruptingNotificationEntry = interruptionCandidate;
|
mInterruptingNotificationEntry = interruptionCandidate;
|
||||||
|
shadeEntry.setInterruption();
|
||||||
|
|
||||||
// 1. Populate mHeadsUpNotificationView
|
// 1. Populate mHeadsUpNotificationView
|
||||||
mHeadsUpNotificationView.setNotification(mInterruptingNotificationEntry);
|
mHeadsUpNotificationView.setNotification(mInterruptingNotificationEntry);
|
||||||
@@ -935,7 +937,7 @@ public class PhoneStatusBar extends BaseStatusBar {
|
|||||||
tick(null, notification, true);
|
tick(null, notification, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
addNotificationViews(shadeEntry);
|
||||||
// Recalculate the position of the sliding windows and the titles.
|
// Recalculate the position of the sliding windows and the titles.
|
||||||
setAreThereNotifications();
|
setAreThereNotifications();
|
||||||
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
|
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user