Display rich text notification messages on Android
ClosedPublic

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

Diff Detail

Repository
R289 KNotifications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
vkrause created this revision.Sat, May 2, 9:30 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptSat, May 2, 9:30 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
vkrause requested review of this revision.Sat, May 2, 9:30 AM
tfella accepted this revision.Sun, May 10, 7:59 PM
This revision is now accepted and ready to land.Sun, May 10, 7:59 PM
z3ntu added a subscriber: z3ntu.Mon, May 11, 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.Mon, May 11, 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.Mon, May 11, 4:20 PM
This revision was automatically updated to reflect the committed changes.