Display rich text notification messages on Android
ClosedPublic

Authored by vkrause on May 2 2020, 9:30 AM.

Diff Detail

Repository
R289 KNotifications
Branch
rich-text
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 26726
Build 26744: arc lint + arc unit
vkrause created this revision.May 2 2020, 9:30 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 2 2020, 9:30 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
vkrause requested review of this revision.May 2 2020, 9:30 AM
tfella accepted this revision.May 10 2020, 7:59 PM
This revision is now accepted and ready to land.May 10 2020, 7:59 PM
z3ntu added a subscriber: z3ntu.May 11 2020, 8:49 AM

I don't see a reason why rich text should be limited to API24+? Yes, the fromHtml(String source, int flags) method is API 24+ but for APIs lower than that you can use fromHtml(String source) as for example wrapped in androidx.core.text.HtmlCompat:

/**
    * Invokes {@link Html#fromHtml(String, int)} on API 24 and newer, otherwise {@code flags} are
    * ignored and {@link Html#fromHtml(String)} is used.
    */
@NonNull
public static Spanned fromHtml(@NonNull String source, @FromHtmlFlags int flags) {
    if (Build.VERSION.SDK_INT >= 24) {
        return Html.fromHtml(source, flags);
    }
    //noinspection deprecation
    return Html.fromHtml(source);
}
vkrause updated this revision to Diff 82566.May 11 2020, 4:19 PM

Support API level < 24 as well.

vkrause retitled this revision from Display rich text notification messages on Android (API level 24+) to Display rich text notification messages on Android.May 11 2020, 4:20 PM
This revision was automatically updated to reflect the committed changes.