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

Commit 5cd2638e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix notif content when child updated to top level" into rvc-dev am:...

Merge "Fix notif content when child updated to top level" into rvc-dev am: e52160f4 am: fec15a24 am: d1ba6bcd

Change-Id: Ifa45a88e963140dbda8e30f3d976089b75282308
parents dbc535c3 d1ba6bcd
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -61,7 +61,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle


    private final Handler mHandler;
    private final Handler mHandler;


    /** Re-usable map of notifications to their sorted children.*/
    /** Re-usable map of top-level notifications to their sorted children if any.*/
    private final HashMap<NotificationEntry, List<NotificationEntry>> mTmpChildOrderMap =
    private final HashMap<NotificationEntry, List<NotificationEntry>> mTmpChildOrderMap =
            new HashMap<>();
            new HashMap<>();


@@ -211,6 +211,8 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
                }
                }
                orderedChildren.add(ent);
                orderedChildren.add(ent);
            } else {
            } else {
                // Top-level notif
                mTmpChildOrderMap.put(ent, null);
                toShow.add(ent.getRow());
                toShow.add(ent.getRow());
            }
            }
        }
        }
@@ -288,7 +290,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle


        }
        }


        mDynamicChildBindController.updateChildContentViews(mTmpChildOrderMap);
        mDynamicChildBindController.updateContentViews(mTmpChildOrderMap);
        mVisualStabilityManager.onReorderingFinished();
        mVisualStabilityManager.onReorderingFinished();
        // clear the map again for the next usage
        // clear the map again for the next usage
        mTmpChildOrderMap.clear();
        mTmpChildOrderMap.clear();
+19 −11
Original line number Original line Diff line number Diff line
@@ -63,44 +63,52 @@ public class DynamicChildBindController {
    }
    }


    /**
    /**
     * Update the child content views, unbinding content views on children that won't be visible
     * Update the content views, unbinding content views on children that won't be visible
     * and binding content views on children that will be visible eventually.
     * and binding content views on children that will be visible eventually and previously unbound
     * children that are no longer children.
     *
     *
     * @param groupNotifs map of notification summaries to their children
     * @param groupNotifs map of top-level notifs to their children, if any
     */
     */
    public void updateChildContentViews(
    public void updateContentViews(
            Map<NotificationEntry, List<NotificationEntry>> groupNotifs) {
            Map<NotificationEntry, List<NotificationEntry>> groupNotifs) {
        for (NotificationEntry entry : groupNotifs.keySet()) {
        for (NotificationEntry entry : groupNotifs.keySet()) {
            List<NotificationEntry> children = groupNotifs.get(entry);
            List<NotificationEntry> children = groupNotifs.get(entry);
            if (children == null) {
                if (!hasContent(entry)) {
                    // Case where child is updated to be top level
                    bindContent(entry);
                }
                continue;
            }
            for (int j = 0; j < children.size(); j++) {
            for (int j = 0; j < children.size(); j++) {
                NotificationEntry childEntry = children.get(j);
                NotificationEntry childEntry = children.get(j);
                if (j >= mChildBindCutoff) {
                if (j >= mChildBindCutoff) {
                    if (hasChildContent(childEntry)) {
                    if (hasContent(childEntry)) {
                        freeChildContent(childEntry);
                        freeContent(childEntry);
                    }
                    }
                } else {
                } else {
                    if (!hasChildContent(childEntry)) {
                    if (!hasContent(childEntry)) {
                        bindChildContent(childEntry);
                        bindContent(childEntry);
                    }
                    }
                }
                }
            }
            }
        }
        }
    }
    }


    private boolean hasChildContent(NotificationEntry entry) {
    private boolean hasContent(NotificationEntry entry) {
        ExpandableNotificationRow row = entry.getRow();
        ExpandableNotificationRow row = entry.getRow();
        return row.getPrivateLayout().getContractedChild() != null
        return row.getPrivateLayout().getContractedChild() != null
                || row.getPrivateLayout().getExpandedChild() != null;
                || row.getPrivateLayout().getExpandedChild() != null;
    }
    }


    private void freeChildContent(NotificationEntry entry) {
    private void freeContent(NotificationEntry entry) {
        RowContentBindParams params = mStage.getStageParams(entry);
        RowContentBindParams params = mStage.getStageParams(entry);
        params.markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED);
        params.markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED);
        params.markContentViewsFreeable(FLAG_CONTENT_VIEW_EXPANDED);
        params.markContentViewsFreeable(FLAG_CONTENT_VIEW_EXPANDED);
        mStage.requestRebind(entry, null);
        mStage.requestRebind(entry, null);
    }
    }


    private void bindChildContent(NotificationEntry entry) {
    private void bindContent(NotificationEntry entry) {
        RowContentBindParams params = mStage.getStageParams(entry);
        RowContentBindParams params = mStage.getStageParams(entry);
        params.requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);
        params.requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);
        params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED);
        params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED);
+2 −2
Original line number Original line Diff line number Diff line
@@ -80,7 +80,7 @@ public class DynamicChildBindControllerTest extends SysuiTestCase {
        when(mBindStage.getStageParams(lastChild)).thenReturn(bindParams);
        when(mBindStage.getStageParams(lastChild)).thenReturn(bindParams);


        // WHEN the controller gets the list
        // WHEN the controller gets the list
        mDynamicChildBindController.updateChildContentViews(mGroupNotifs);
        mDynamicChildBindController.updateContentViews(mGroupNotifs);


        // THEN we free content views
        // THEN we free content views
        verify(bindParams).markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED);
        verify(bindParams).markContentViewsFreeable(FLAG_CONTENT_VIEW_CONTRACTED);
@@ -101,7 +101,7 @@ public class DynamicChildBindControllerTest extends SysuiTestCase {
        when(mBindStage.getStageParams(lastChild)).thenReturn(bindParams);
        when(mBindStage.getStageParams(lastChild)).thenReturn(bindParams);


        // WHEN the controller gets the list
        // WHEN the controller gets the list
        mDynamicChildBindController.updateChildContentViews(mGroupNotifs);
        mDynamicChildBindController.updateContentViews(mGroupNotifs);


        // THEN we bind content views
        // THEN we bind content views
        verify(bindParams).requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);
        verify(bindParams).requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);