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

Commit cab97ebc authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fix decorated notification text colors in dark mode

This reverts an accidental style change to RVC behavior.

Fixes: 175449252
Test: Manual visual testing
Change-Id: Ie9b9c7687e21f2d4d08d7e18a7ae4a56904dacc5
parent 01af9eec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
    <style name="Theme.DeviceDefault.QuickSettings.Dialog" parent="Theme.DeviceDefault.Dialog" />

    <style name="TextAppearance.Material.Notification">
        <item name="textColor">?attr/textColorPrimary</item>
        <item name="textColor">@color/notification_secondary_text_color_dark</item>
        <item name="textSize">@dimen/notification_text_size</item>
    </style>
</resources>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -421,6 +421,9 @@
     vibrator is capable of subtle vibrations -->
    <bool name="config_vibrateOnIconAnimation">false</bool>

    <!-- Adjust the theme on fully custom and decorated custom view notifications -->
    <bool name="config_adjustThemeOnNotificationCustomViews">false</bool>

    <!-- If true, enable the advance anti-falsing classifier on the lockscreen. On some devices it
         does not work well, particularly with noisy touchscreens. Note that disabling it may
         increase the rate of unintentional unlocks. -->
+21 −24
Original line number Diff line number Diff line
@@ -36,12 +36,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.util.ContrastColorUtil;
import com.android.internal.widget.CachingIconView;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.TransformableView;
import com.android.systemui.statusbar.notification.TransformState;
@@ -61,6 +61,7 @@ public abstract class NotificationViewWrapper implements TransformableView {
    private int mLightTextColor;
    private int mDarkTextColor;
    private int mDefaultTextColor;
    private boolean mAdjustTheme;

    public static NotificationViewWrapper wrap(Context ctx, View v, ExpandableNotificationRow row) {
        if (v.getId() == com.android.internal.R.id.status_bar_latest_event_content) {
@@ -97,6 +98,8 @@ public abstract class NotificationViewWrapper implements TransformableView {
        mView = view;
        mRow = row;
        onReinflated();
        mAdjustTheme = ctx.getResources().getBoolean(
                R.bool.config_adjustThemeOnNotificationCustomViews);
    }

    /**
@@ -124,12 +127,12 @@ public abstract class NotificationViewWrapper implements TransformableView {
        mLightTextColor = mView.getContext().getColor(
                com.android.internal.R.color.notification_primary_text_color_light);
        mDarkTextColor = mView.getContext().getColor(
                R.color.notification_primary_text_color_dark);
                com.android.internal.R.color.notification_primary_text_color_dark);

        Context themedContext = new ContextThemeWrapper(mView.getContext(),
                R.style.Theme_DeviceDefault_DayNight);
        mDefaultTextColor = Utils.getColorAttr(themedContext, R.attr.textColorPrimary)
                .getDefaultColor();
                com.android.internal.R.style.Theme_DeviceDefault_DayNight);
        mDefaultTextColor = Utils.getColorAttr(themedContext,
                com.android.internal.R.attr.textColorPrimary).getDefaultColor();
    }

    protected boolean needsInversion(int defaultBackgroundColor, View view) {
@@ -208,7 +211,7 @@ public abstract class NotificationViewWrapper implements TransformableView {
    }

    protected void ensureThemeOnChildren() {
        if (mView == null) {
        if (!mAdjustTheme || mView == null) {
            return;
        }

@@ -219,26 +222,20 @@ public abstract class NotificationViewWrapper implements TransformableView {
        }

        // Now let's check if there's unprotected text somewhere, and apply the theme if we find it.
        if (!(mView instanceof ViewGroup)) {
            return;
        }
        processChildrenTextColor((ViewGroup) mView);
    }

    private void processChildrenTextColor(ViewGroup viewGroup) {
        if (viewGroup == null) {
            return;
        processTextColorRecursive(mView);
    }

        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            if (child instanceof TextView) {
                int foreground = ((TextView) child).getCurrentTextColor();
    private void processTextColorRecursive(View view) {
        if (view instanceof TextView) {
            TextView textView = (TextView) view;
            int foreground = textView.getCurrentTextColor();
            if (foreground == mLightTextColor || foreground == mDarkTextColor) {
                    ((TextView) child).setTextColor(mDefaultTextColor);
                textView.setTextColor(mDefaultTextColor);
            }
            } else if (child instanceof ViewGroup) {
                processChildrenTextColor((ViewGroup) child);
        } else if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                processTextColorRecursive(viewGroup.getChildAt(i));
            }
        }
    }