Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c1bfdfe authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Handle multi-user in notif log"

parents a4ef70fa 7e7271ff
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -71,6 +71,18 @@
            android:src="@drawable/ic_notifications_alert"
        />

        <ImageView
            android:id="@+id/profile_badge"
            android:layout_width="@*android:dimen/status_bar_icon_size"
            android:layout_height="@*android:dimen/status_bar_icon_size"
            android:layout_centerVertical="true"
            android:layout_marginEnd="6dp"
            android:paddingTop="1dp"
            android:scaleType="fitCenter"
            android:visibility="gone"
            android:layout_toStartOf="@id/timestamp"
        />

        <DateTimeView
            android:id="@+id/timestamp"
            android:layout_width="wrap_content"
+17 −10
Original line number Diff line number Diff line
@@ -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))