Merge "Handle multi-user in notif log"
This commit is contained in:
committed by
Android (Google) Code Review
commit
4c1bfdfe73
@@ -83,6 +83,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
public Drawable pkgicon;
|
||||
public CharSequence pkgname;
|
||||
public Drawable icon;
|
||||
public boolean badged;
|
||||
public CharSequence title;
|
||||
public CharSequence text;
|
||||
public int priority;
|
||||
@@ -268,8 +269,8 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
if (needsAdd) {
|
||||
mNotificationInfos.addFirst(newInfo);
|
||||
getPreferenceScreen().addPreference(new HistoricalNotificationPreference(
|
||||
getPrefContext(),
|
||||
mNotificationInfos.peekFirst(), -1 * mNotificationInfos.size()));
|
||||
getPrefContext(), mNotificationInfos.peekFirst(),
|
||||
-1 * mNotificationInfos.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,9 +339,9 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
return text == null ? null : String.valueOf(text);
|
||||
}
|
||||
|
||||
private static Drawable loadIcon(Context context, StatusBarNotification sbn) {
|
||||
private Drawable loadIcon(HistoricalNotificationInfo info, StatusBarNotification sbn) {
|
||||
Drawable draw = sbn.getNotification().getSmallIcon().loadDrawableAsUser(
|
||||
sbn.getPackageContext(context), sbn.getUserId());
|
||||
sbn.getPackageContext(mContext), info.user);
|
||||
if (draw == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -367,7 +368,6 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
* booted), stores the data we need to present them, and sorts them chronologically for display.
|
||||
*/
|
||||
private void loadNotifications() {
|
||||
final int currentUserId = ActivityManager.getCurrentUser();
|
||||
try {
|
||||
StatusBarNotification[] active = mNoMan.getActiveNotifications(
|
||||
mContext.getPackageName());
|
||||
@@ -380,9 +380,6 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
for (StatusBarNotification[] resultSet
|
||||
: new StatusBarNotification[][] { active, dismissed }) {
|
||||
for (StatusBarNotification sbn : resultSet) {
|
||||
if (sbn.getUserId() != UserHandle.USER_ALL & sbn.getUserId() != currentUserId) {
|
||||
continue;
|
||||
}
|
||||
if (sbn.getNotification().isGroupSummary()) {
|
||||
continue;
|
||||
}
|
||||
@@ -406,8 +403,10 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
final Notification n = sbn.getNotification();
|
||||
final HistoricalNotificationInfo info = new HistoricalNotificationInfo();
|
||||
info.pkg = sbn.getPackageName();
|
||||
info.user = sbn.getUserId();
|
||||
info.icon = loadIcon(mContext, sbn);
|
||||
info.user = sbn.getUserId() == UserHandle.USER_ALL
|
||||
? UserHandle.USER_SYSTEM : sbn.getUserId();
|
||||
info.badged = info.user != ActivityManager.getCurrentUser();
|
||||
info.icon = loadIcon(info, sbn);
|
||||
if (info.icon == null) {
|
||||
info.icon = loadPackageIconDrawable(info.pkg, info.user);
|
||||
}
|
||||
@@ -645,6 +644,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
private final HistoricalNotificationInfo mInfo;
|
||||
private static long sLastExpandedTimestamp; // quick hack to keep things from collapsing
|
||||
public ViewGroup mItemView; // hack to update prefs fast;
|
||||
private Context mContext;
|
||||
|
||||
public HistoricalNotificationPreference(Context context, HistoricalNotificationInfo info,
|
||||
int order) {
|
||||
@@ -653,6 +653,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
setOrder(order);
|
||||
setKey(info.key);
|
||||
mInfo = info;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -697,6 +698,12 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
||||
((ImageView) mItemView.findViewById(R.id.icon)).setImageDrawable(info.icon);
|
||||
}
|
||||
|
||||
ImageView profileBadge = mItemView.findViewById(R.id.profile_badge);
|
||||
Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
|
||||
UserHandle.of(info.user), -1);
|
||||
profileBadge.setImageDrawable(profile);
|
||||
profileBadge.setVisibility(info.badged ? View.VISIBLE : View.GONE);
|
||||
|
||||
((DateTimeView) mItemView.findViewById(R.id.timestamp)).setTime(mInfo.timestamp);
|
||||
|
||||
((TextView) mItemView.findViewById(R.id.notification_extra))
|
||||
|
Reference in New Issue
Block a user