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

Commit e03f4e1f authored by Chris Wren's avatar Chris Wren
Browse files

handle updates to the notification in the heads up

Bug: 10226356
Change-Id: I5bc9aecc3849617092e863868a6df610c615048b
parent 83208e34
Loading
Loading
Loading
Loading
+33 −25
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@ public abstract class BaseStatusBar extends SystemUI implements
    }

    public void onHeadsUpDismissed() {
        // pass
        mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
    }

    @Override
@@ -958,20 +958,20 @@ public abstract class BaseStatusBar extends SystemUI implements
            if (DEBUG) Log.d(TAG, "reusing notification for key: " + key);
            oldEntry.notification = notification;
            try {
                // Reapply the RemoteViews
                contentView.reapply(mContext, oldEntry.expanded, mOnClickHandler);
                if (bigContentView != null && oldEntry.getBigContentView() != null) {
                    bigContentView.reapply(mContext, oldEntry.getBigContentView(), mOnClickHandler);
                }
                // update the contentIntent
                final PendingIntent contentIntent = notification.getNotification().contentIntent;
                if (contentIntent != null) {
                    final View.OnClickListener listener = makeClicker(contentIntent,
                            notification.getPackageName(), notification.getTag(), notification.getId());
                    oldEntry.content.setOnClickListener(listener);
                updateNotificationViews(oldEntry, notification);

                if (ENABLE_HEADS_UP && mInterruptingNotificationEntry != null
                        && oldNotification == mInterruptingNotificationEntry.notification) {
                    if (!shouldInterrupt(notification)) {
                        if (DEBUG) Log.d(TAG, "no longer interrupts!");
                        mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
                    } else {
                    oldEntry.content.setOnClickListener(null);
                        if (DEBUG) Log.d(TAG, "updating the current heads up:" + notification);
                        mInterruptingNotificationEntry.notification = notification;
                        updateNotificationViews(mInterruptingNotificationEntry, notification);
                    }
                }

                // Update the icon.
                final StatusBarIcon ic = new StatusBarIcon(notification.getPackageName(),
                        notification.getUser(),
@@ -997,7 +997,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            if (DEBUG) Log.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top"));
            final boolean wasExpanded = oldEntry.row.isUserExpanded();
            removeNotificationViews(key);
            addNotificationViews(key, notification);
            addNotificationViews(key, notification);  // will also replace the heads up
            if (wasExpanded) {
                final NotificationData.Entry newEntry = mNotificationData.findByKey(key);
                newEntry.row.setExpanded(true);
@@ -1022,17 +1022,25 @@ public abstract class BaseStatusBar extends SystemUI implements
        // Recalculate the position of the sliding windows and the titles.
        setAreThereNotifications();
        updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
    }

        // See if we need to update the heads up.
        if (ENABLE_HEADS_UP && mInterruptingNotificationEntry != null
                && oldNotification == mInterruptingNotificationEntry.notification) {
            if (DEBUG) Log.d(TAG, "updating the current heads up:" + notification);
            // XXX: this is a hack for Alarms. The real implementation will need to *update*
            // the heads up.
            if (!shouldInterrupt(notification)) {
                if (DEBUG) Log.d(TAG, "no longer interrupts!");
                mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
    private void updateNotificationViews(NotificationData.Entry entry,
            StatusBarNotification notification) {
        final RemoteViews contentView = notification.getNotification().contentView;
        final RemoteViews bigContentView = notification.getNotification().bigContentView;
        // Reapply the RemoteViews
        contentView.reapply(mContext, entry.expanded, mOnClickHandler);
        if (bigContentView != null && entry.getBigContentView() != null) {
            bigContentView.reapply(mContext, entry.getBigContentView(), mOnClickHandler);
        }
        // update the contentIntent
        final PendingIntent contentIntent = notification.getNotification().contentIntent;
        if (contentIntent != null) {
            final View.OnClickListener listener = makeClicker(contentIntent,
                    notification.getPackageName(), notification.getTag(), notification.getId());
            entry.content.setOnClickListener(listener);
        } else {
            entry.content.setOnClickListener(null);
        }
    }

+4 −2
Original line number Diff line number Diff line
@@ -1319,12 +1319,10 @@ public class PhoneStatusBar extends BaseStatusBar {
                    break;
                case MSG_HIDE_HEADS_UP:
                    setHeadsUpVisibility(false);
                    mInterruptingNotificationEntry = null;
                    break;
                case MSG_ESCALATE_HEADS_UP:
                    escalateHeadsUp();
                    setHeadsUpVisibility(false);
                    mInterruptingNotificationEntry = null;
                    break;
            }
        }
@@ -2507,6 +2505,10 @@ public class PhoneStatusBar extends BaseStatusBar {
        if (!ENABLE_HEADS_UP) return;
        if (DEBUG) Log.v(TAG, (vis ? "showing" : "hiding") + " heads up window");
        mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
        if (!vis) {
            if (DEBUG) Log.d(TAG, "setting heads up entry to null");
            mInterruptingNotificationEntry = null;
        }
    }

    public void animateHeadsUp(boolean animateInto, float frac) {