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

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

Make foreground color selection in SmartReplyView and RemoteInputView match Notification.

Fixes: 196585371
Test: post colorized notification with luminance between .2 and .5; validate that smart replies and remote input use black text to match the notification.
Change-Id: I5ea69181755ed5c2b48352a0379ae4e898202e21
parent 9967c7a2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6245,8 +6245,9 @@ public class Notification implements Parcelable
         *
         * @param color the color to check
         * @return true if the color has higher contrast with white than black
         * @hide
         */
        private static boolean isColorDark(int color) {
        public static boolean isColorDark(int color) {
            // as per ContrastColorUtil.shouldUseDark, this uses the color contrast midpoint.
            return ContrastColorUtil.calculateLuminance(color) <= 0.17912878474;
        }
+1 −2
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
@@ -205,7 +204,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
        final int stroke = colorized ? mContext.getResources().getDimensionPixelSize(
                R.dimen.remote_input_view_text_stroke) : 0;
        if (colorized) {
            final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor);
            final boolean dark = Notification.Builder.isColorDark(backgroundColor);
            final int foregroundColor = dark ? Color.WHITE : Color.BLACK;
            final int inverseColor = dark ? Color.BLACK : Color.WHITE;
            editBgColor = backgroundColor;
+1 −1
Original line number Diff line number Diff line
@@ -628,7 +628,7 @@ public class SmartReplyView extends ViewGroup {
        mCurrentBackgroundColor = backgroundColor;
        mCurrentColorized = colorized;

        final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor);
        final boolean dark = Notification.Builder.isColorDark(backgroundColor);

        mCurrentTextColor = ContrastColorUtil.ensureTextContrast(
                dark ? mDefaultTextColorDarkBg : mDefaultTextColor,