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

Commit 67f4f005 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix work badge becoming black in groups" into main

parents c55a4fbe 1eb82adf
Loading
Loading
Loading
Loading
+27 −27
Original line number Original line Diff line number Diff line
@@ -61,15 +61,6 @@ public class NotificationGroupingUtil {
            return row.getEntry().getSbn().getNotification();
            return row.getEntry().getSbn().getNotification();
        }
        }
    };
    };
    private static final ResultApplicator GREY_APPLICATOR = new ResultApplicator() {
        @Override
        public void apply(View parent, View view, boolean apply, boolean reset) {
            CachingIconView icon = view.findViewById(com.android.internal.R.id.icon);
            if (icon != null) {
                icon.setGrayedOut(apply);
            }
        }
    };


    private final ExpandableNotificationRow mRow;
    private final ExpandableNotificationRow mRow;
    private final ArrayList<Processor> mProcessors = new ArrayList<>();
    private final ArrayList<Processor> mProcessors = new ArrayList<>();
@@ -78,14 +69,18 @@ public class NotificationGroupingUtil {
    public NotificationGroupingUtil(ExpandableNotificationRow row) {
    public NotificationGroupingUtil(ExpandableNotificationRow row) {
        mRow = row;
        mRow = row;


        final IconComparator iconVisibilityComparator = new IconComparator(mRow) {
        final IconComparator iconVisibilityComparator = new IconComparator() {
            public boolean compare(View parent, View child, Object parentData,
            public boolean compare(View parent, View child, Object parentData,
                    Object childData) {
                    Object childData) {
                if (Flags.notificationsRedesignAppIcons() && mRow.isShowingAppIcon()) {
                    // Icon is always the same when we're showing the app icon.
                    return true;
                }
                return hasSameIcon(parentData, childData)
                return hasSameIcon(parentData, childData)
                        && hasSameColor(parentData, childData);
                        && hasSameColor(parentData, childData);
            }
            }
        };
        };
        final IconComparator greyComparator = new IconComparator(mRow) {
        final IconComparator greyComparator = new IconComparator() {
            public boolean compare(View parent, View child, Object parentData,
            public boolean compare(View parent, View child, Object parentData,
                    Object childData) {
                    Object childData) {
                if (Flags.notificationsRedesignAppIcons() && mRow.isShowingAppIcon()) {
                if (Flags.notificationsRedesignAppIcons() && mRow.isShowingAppIcon()) {
@@ -95,6 +90,19 @@ public class NotificationGroupingUtil {
                        || hasSameColor(parentData, childData);
                        || hasSameColor(parentData, childData);
            }
            }
        };
        };
        final ResultApplicator greyApplicator = new ResultApplicator() {
            @Override
            public void apply(View parent, View view, boolean apply, boolean reset) {
                if (Flags.notificationsRedesignAppIcons() && mRow.isShowingAppIcon()) {
                    // Do nothing.
                    return;
                }
                CachingIconView icon = view.findViewById(com.android.internal.R.id.icon);
                if (icon != null) {
                    icon.setGrayedOut(apply);
                }
            }
        };


        // To hide the icons if they are the same and the color is the same
        // To hide the icons if they are the same and the color is the same
        mProcessors.add(new Processor(mRow,
        mProcessors.add(new Processor(mRow,
@@ -107,7 +115,7 @@ public class NotificationGroupingUtil {
                com.android.internal.R.id.status_bar_latest_event_content,
                com.android.internal.R.id.status_bar_latest_event_content,
                ICON_EXTRACTOR,
                ICON_EXTRACTOR,
                greyComparator,
                greyComparator,
                GREY_APPLICATOR));
                greyApplicator));
        // To show the large icon on the left side instead if all the small icons are the same
        // To show the large icon on the left side instead if all the small icons are the same
        mProcessors.add(new Processor(mRow,
        mProcessors.add(new Processor(mRow,
                com.android.internal.R.id.status_bar_latest_event_content,
                com.android.internal.R.id.status_bar_latest_event_content,
@@ -326,6 +334,7 @@ public class NotificationGroupingUtil {
         * @return whether to views are the same
         * @return whether to views are the same
         */
         */
        boolean compare(View parent, View child, Object parentData, Object childData);
        boolean compare(View parent, View child, Object parentData, Object childData);

        boolean isEmpty(View view);
        boolean isEmpty(View view);
    }
    }


@@ -368,21 +377,12 @@ public class NotificationGroupingUtil {
    }
    }


    private abstract static class IconComparator implements ViewComparator {
    private abstract static class IconComparator implements ViewComparator {
        private final ExpandableNotificationRow mRow;

        IconComparator(ExpandableNotificationRow row) {
            mRow = row;
        }

        @Override
        @Override
        public boolean compare(View parent, View child, Object parentData, Object childData) {
        public boolean compare(View parent, View child, Object parentData, Object childData) {
            return false;
            return false;
        }
        }


        protected boolean hasSameIcon(Object parentData, Object childData) {
        protected boolean hasSameIcon(Object parentData, Object childData) {
            if (Flags.notificationsRedesignAppIcons() && mRow.isShowingAppIcon()) {
                return true;
            }
            Icon parentIcon = getIcon((Notification) parentData);
            Icon parentIcon = getIcon((Notification) parentData);
            Icon childIcon = getIcon((Notification) childData);
            Icon childIcon = getIcon((Notification) childData);
            return parentIcon.sameAs(childIcon);
            return parentIcon.sameAs(childIcon);