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

Commit d4b6e352 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "[RONs] Exclude Strikethrough" into main

parents 54ac6934 2a20d3e8
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -3510,8 +3510,16 @@ public class Notification implements Parcelable
        return cs.toString();
        return cs.toString();
    }
    }
    @Nullable
    private static CharSequence stripNonStyleSpans(@Nullable CharSequence text) {
    private static CharSequence stripNonStyleSpans(@Nullable CharSequence text) {
        // Keep Strikethrough spans for MessagingStyle notifications.
        // Strikethrough can be an important part of the meaning of the message
        // e.g.the corrections, cancelations etc.
        return stripNonStyleSpans(text, /* keepStrikethrough= */ true);
    }
    @Nullable
    private static CharSequence stripNonStyleSpans(@Nullable CharSequence text,
        boolean keepStrikethrough) {
        if (text == null) return null;
        if (text == null) return null;
        if (text instanceof Spanned) {
        if (text instanceof Spanned) {
@@ -3521,7 +3529,7 @@ public class Notification implements Parcelable
            for (Object span : spans) {
            for (Object span : spans) {
                final Object resultSpan;
                final Object resultSpan;
                if (span instanceof StyleSpan
                if (span instanceof StyleSpan
                        || span instanceof StrikethroughSpan
                        || (keepStrikethrough && (span instanceof StrikethroughSpan))
                        || span instanceof UnderlineSpan) {
                        || span instanceof UnderlineSpan) {
                    resultSpan = span;
                    resultSpan = span;
                } else if (span instanceof TextAppearanceSpan) {
                } else if (span instanceof TextAppearanceSpan) {
@@ -7514,8 +7522,10 @@ public class Notification implements Parcelable
        public CharSequence ensureColorSpanContrastOrStripStyling(CharSequence cs,
        public CharSequence ensureColorSpanContrastOrStripStyling(CharSequence cs,
                int buttonFillColor) {
                int buttonFillColor) {
            if ( mN.isPromotedOngoing()) {
            if ( mN.isPromotedOngoing()) {
                // RON keeps non style spans just like MessagingStyle
                // RON keeps non style spans just like MessagingStyle but disallow strikethrough
                return stripNonStyleSpans(cs);
                // as that could change the text's meaning between promoted (which allows spans)
                // and demoted (which removes spans).
                return stripNonStyleSpans(cs, /* keepStrikethrough= */ false);
            } else if (Flags.cleanUpSpansAndNewLines()) {
            } else if (Flags.cleanUpSpansAndNewLines()) {
                return stripStyling(cs);
                return stripStyling(cs);
            }
            }