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

Commit 282ff9ae authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Fix issues with DND display in status bar.

Bug: 3478116
Bug: 3480339
Change-Id: I513f0c2696dc3fe5aa3a6f071f1e4793f9f9645c
parent ad788884
Loading
Loading
Loading
Loading
+33 −28
Original line number Diff line number Diff line
@@ -668,7 +668,7 @@ public class TabletStatusBar extends StatusBar implements
    }

    public void updateNotification(IBinder key, StatusBarNotification notification) {
        if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ") // TODO");
        if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")");

        final NotificationData.Entry oldEntry = mNotificationData.findByKey(key);
        if (oldEntry == null) {
@@ -685,7 +685,8 @@ public class TabletStatusBar extends StatusBar implements
            Slog.d(TAG, "old notification: when=" + oldNotification.notification.when
                    + " ongoing=" + oldNotification.isOngoing()
                    + " expanded=" + oldEntry.expanded
                    + " contentView=" + oldContentView);
                    + " contentView=" + oldContentView
                    + " rowParent=" + oldEntry.row.getParent());
            Slog.d(TAG, "new notification: when=" + notification.notification.when
                    + " ongoing=" + oldNotification.isOngoing()
                    + " contentView=" + contentView);
@@ -806,16 +807,17 @@ public class TabletStatusBar extends StatusBar implements
            }
        }
        if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
            mNotificationDNDMode = Prefs.read(mContext)
                        .getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT);

            if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
                Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
                Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: yes" + (mNotificationDNDMode?" (DND)":""));
                mTicker.halt();
            } else {
                Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: no");
                Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: no" + (mNotificationDNDMode?" (DND)":""));
            }

            // refresh icons to show either notifications or the DND message
            mNotificationDNDMode = Prefs.read(mContext)
                        .getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT);
            Slog.d(TAG, "DND: " + mNotificationDNDMode);
            reloadAllNotificationIcons();
        } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) {
            if ((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) {
@@ -1241,11 +1243,15 @@ public class TabletStatusBar extends StatusBar implements

        if (mIconLayout == null) return;

        // first, populate the main notification panel
        loadNotificationPanel();

        final LinearLayout.LayoutParams params
            = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight);

        // alternate behavior in DND mode
        if (mNotificationDNDMode && mIconLayout.getChildCount() == 0) {
        if (mNotificationDNDMode) {
            if (mIconLayout.getChildCount() == 0) {
                final StatusBarIconView iconView = new StatusBarIconView(mContext, "_dnd");
                iconView.setImageResource(R.drawable.ic_notification_dnd);
                iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
@@ -1264,6 +1270,7 @@ public class TabletStatusBar extends StatusBar implements
                        iconView);

                mIconLayout.addView(iconView, params);
            }

            return;
        }
@@ -1305,8 +1312,6 @@ public class TabletStatusBar extends StatusBar implements
                mIconLayout.addView(v, i, params);
            }
        }

        loadNotificationPanel();
    }

    private void loadNotificationPanel() {