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

Commit 8fc93c90 authored by Selim Cinek's avatar Selim Cinek
Browse files

Cleaned up the updating of notifications

Some states were not correctly updated which could lead to
small bugs when the update was not in-place.

Change-Id: If133029acf65a9af8d297314fee5f1cd9e2015bd
parent eaa29ca6
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1550,7 +1550,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            row.setUserExpanded(userExpanded);
        }
        row.setUserLocked(userLocked);
        row.setEntry(entry);
        row.updateStatusBarNotification(entry.notification);
        applyRemoteInput(entry);
        return true;
    }
@@ -2184,8 +2184,7 @@ public abstract class BaseStatusBar extends SystemUI implements
        // update the contentIntent
        mNotificationClicker.register(entry.row, sbn);

        entry.row.setEntry(entry);
        entry.row.notifyContentUpdated();
        entry.row.updateStatusBarNotification(entry.notification);
        entry.row.resetHeight();

        applyRemoteInput(entry);
+10 −20
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private FalsingManager mFalsingManager;

    private boolean mJustClicked;
    private NotificationData.Entry mEntry;
    private boolean mShowNoBackground;
    private ExpandableNotificationRow mNotificationParent;
    private OnClickListener mExpandClickListener = new OnClickListener() {
@@ -171,10 +170,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    private void setStatusBarNotification(StatusBarNotification statusBarNotification) {
    public void updateStatusBarNotification(StatusBarNotification statusBarNotification) {
        mStatusBarNotification = statusBarNotification;
        mPrivateLayout.setStatusBarNotification(statusBarNotification);
        mPrivateLayout.onNotificationUpdated(statusBarNotification);
        mPublicLayout.onNotificationUpdated(statusBarNotification);
        updateVetoButton();
        if (mIsSummaryWithChildren) {
            recreateNotificationHeader();
        }
        onChildrenCountChanged();
    }

@@ -391,11 +394,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    public void setEntry(NotificationData.Entry entry) {
        mEntry = entry;
        setStatusBarNotification(entry.notification);
    }

    public CharSequence getSubText() {
        Notification notification = mStatusBarNotification.getNotification();
        CharSequence subText = notification.extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
@@ -687,17 +685,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }

    private void onChildrenCountChanged() {
        final boolean isSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
        mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
                && mGroupManager.hasGroupChildren(mStatusBarNotification);
        if (isSummaryWithChildren) {
        if (mIsSummaryWithChildren) {
            if (mChildrenContainer == null) {
                mChildrenContainerStub.inflate();
            }
            if (!mIsSummaryWithChildren) {
            if (mNotificationHeader == null) {
                recreateNotificationHeader();
            }
        }
        mIsSummaryWithChildren  = isSummaryWithChildren;
        mPrivateLayout.updateExpandButtons(isExpandable());
        updateHeaderChildCount();
        updateChildrenVisibility(true);
@@ -913,14 +910,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    public void notifyContentUpdated() {
        mPublicLayout.notifyContentUpdated();
        mPrivateLayout.notifyContentUpdated();
        if (mIsSummaryWithChildren) {
            recreateNotificationHeader();
        }
    }

    private void recreateNotificationHeader() {
        final Notification.Builder builder = Notification.Builder.recoverBuilder(getContext(),
                getStatusBarNotification().getNotification());
@@ -935,6 +924,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        } else {
            header.reapply(getContext(), mNotificationHeader);
        }
        updateHeaderChildCount();
    }

    public boolean isMaxExpandHeightInitialized() {
+13 −14
Original line number Diff line number Diff line
@@ -448,19 +448,6 @@ public class NotificationContentView extends FrameLayout {
        }
    }

    public void notifyContentUpdated() {
        updateSingleLineView();
        selectLayout(false /* animate */, true /* force */);
        if (mContractedChild != null) {
            mContractedWrapper.notifyContentUpdated();
            mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
        }
        if (mExpandedChild != null) {
            mExpandedWrapper.notifyContentUpdated();
        }
        updateRoundRectClipping();
    }

    public boolean isContentExpandable() {
        return mExpandedChild != null;
    }
@@ -493,9 +480,21 @@ public class NotificationContentView extends FrameLayout {
        updateSingleLineView();
    }

    public void setStatusBarNotification(StatusBarNotification statusBarNotification) {
    public void onNotificationUpdated(StatusBarNotification statusBarNotification) {
        mStatusBarNotification = statusBarNotification;
        updateSingleLineView();
        selectLayout(false /* animate */, true /* force */);
        if (mContractedChild != null) {
            mContractedWrapper.notifyContentUpdated();
            mContractedWrapper.setDark(mDark, false /* animate */, 0 /* delay */);
        }
        if (mExpandedChild != null) {
            mExpandedWrapper.notifyContentUpdated();
        }
        if (mHeadsUpChild != null) {
            mHeadsUpWrapper.notifyContentUpdated();
        }
        updateRoundRectClipping();
    }

    private void updateSingleLineView() {