Fix '<b>' did not get bold in HearingDevice footer.

Root Cause: Did not use <![CDATA[ ...]]> to represent it contains html tag <b>.

Solution: Use <![CDATA[ and Html.fromHtml to add Spanned for the footer string.

Bug: 378806589
Test: Enable bold text to test the effect
Flag: EXEMPT bugfix
Change-Id: I56827dc18e7183c0458c83dac0dbeca7eb8bb16d
This commit is contained in:
jasonwshsu
2024-12-19 15:54:37 +08:00
parent 7bb0c30688
commit 9b4575a52a
3 changed files with 10 additions and 3 deletions

View File

@@ -17,6 +17,7 @@
package com.android.settings.accessibility;
import android.content.Context;
import android.text.Html;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceScreen;
@@ -42,6 +43,13 @@ public class HearingDeviceFooterPreferenceController extends
final AccessibilityFooterPreference footerPreference =
screen.findPreference(getPreferenceKey());
// We use html tag inside footer string, so it is better to load from html to have better
// html tag support.
final CharSequence title = Html.fromHtml(
mContext.getString(R.string.accessibility_hearing_device_footer_summary),
Html.FROM_HTML_MODE_COMPACT, /* imageGetter= */ null, /* tagHandler= */ null);
footerPreference.setTitle(title);
// Need to update contentDescription string to announce "than" rather than ">"
final String summaryTts = mContext.getString(
R.string.accessibility_hearing_device_footer_summary_tts);