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

Commit 2a20d3e8 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[RONs] Exclude Strikethrough

This CL excludes Strikethrough from Live Updates because text meaning can change when the notification is demoted.

Bug: 430343270
Flag: android.app.ui_rich_ongoing
Test: manual (post a RON with Strikethrough and confirm that this notification does not render Strikethrough)
Change-Id: Ib18069efcde01597bb34ff74dd32c266bc3d300d
parent 31dd0cf5
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -3510,8 +3510,16 @@ public class Notification implements Parcelable
        return cs.toString();
    }
    @Nullable
    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 instanceof Spanned) {
@@ -3521,7 +3529,7 @@ public class Notification implements Parcelable
            for (Object span : spans) {
                final Object resultSpan;
                if (span instanceof StyleSpan
                        || span instanceof StrikethroughSpan
                        || (keepStrikethrough && (span instanceof StrikethroughSpan))
                        || span instanceof UnderlineSpan) {
                    resultSpan = span;
                } else if (span instanceof TextAppearanceSpan) {
@@ -7514,8 +7522,10 @@ public class Notification implements Parcelable
        public CharSequence ensureColorSpanContrastOrStripStyling(CharSequence cs,
                int buttonFillColor) {
            if ( mN.isPromotedOngoing()) {
                // RON keeps non style spans just like MessagingStyle
                return stripNonStyleSpans(cs);
                // RON keeps non style spans just like MessagingStyle but disallow strikethrough
                // 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()) {
                return stripStyling(cs);
            }