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

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

Merge "Correct colors on forcibly decorated custom notifications" into sc-dev am: 32906bfb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13506525

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idd88288cfb216b5f1459d706fc17e88071eaa6cc
parents 5e49759b 32906bfb
Loading
Loading
Loading
Loading
+25 −7
Original line number Diff line number Diff line
@@ -29,6 +29,30 @@ public class NotificationDecoratedCustomViewWrapper extends NotificationTemplate

    private View mWrappedView = null;

    /**
     * Determines if the standard template contains a custom view, injected by Notification.Builder
     */
    public static boolean hasCustomView(View v) {
        return getWrappedCustomView(v) != null;
    }

    private static View getWrappedCustomView(View view) {
        if (view == null) {
            return null;
        }
        ViewGroup container = view.findViewById(
                com.android.internal.R.id.notification_main_column);
        if (container == null) {
            return null;
        }
        Integer childIndex = (Integer) container.getTag(
                com.android.internal.R.id.notification_custom_view_index_tag);
        if (childIndex == null || childIndex == -1) {
            return null;
        }
        return container.getChildAt(childIndex);
    }

    protected NotificationDecoratedCustomViewWrapper(Context ctx, View view,
            ExpandableNotificationRow row) {
        super(ctx, view, row);
@@ -36,13 +60,7 @@ public class NotificationDecoratedCustomViewWrapper extends NotificationTemplate

    @Override
    public void onContentUpdated(ExpandableNotificationRow row) {
        ViewGroup container = mView.findViewById(
                com.android.internal.R.id.notification_main_column);
        Integer childIndex = (Integer) container.getTag(
                com.android.internal.R.id.notification_custom_view_index_tag);
        if (childIndex != null && childIndex != -1) {
            mWrappedView = container.getChildAt(childIndex);
        }
        mWrappedView = getWrappedCustomView(mView);

        // Custom views will most likely use just white or black as their text color.
        // We need to scan through and replace these colors by Material NEXT colors.
+3 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ public abstract class NotificationViewWrapper implements TransformableView {
            if (Notification.DecoratedCustomViewStyle.class.equals(style)) {
                return new NotificationDecoratedCustomViewWrapper(ctx, v, row);
            }
            if (NotificationDecoratedCustomViewWrapper.hasCustomView(v)) {
                return new NotificationDecoratedCustomViewWrapper(ctx, v, row);
            }
            return new NotificationTemplateViewWrapper(ctx, v, row);
        } else if (v instanceof NotificationHeaderView) {
            return new NotificationHeaderViewWrapper(ctx, v, row);