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

@@ -5671,8 +5671,8 @@
<!-- Title for accessibility hearing device page footer. [CHAR LIMIT=40] --> <!-- Title for accessibility hearing device page footer. [CHAR LIMIT=40] -->
<string name="accessibility_hearing_device_about_title">About hearing devices</string> <string name="accessibility_hearing_device_about_title">About hearing devices</string>
<!-- Description for text in accessibility hearing aids footer. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=7451899224828040581] --> <!-- Description for text in accessibility hearing aids footer. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=7451899224828040581] -->
<string name="accessibility_hearing_device_footer_summary">To find other hearing devices that arent supported by ASHA or LE Audio, tap <b>Pair new device</b> > <b>See more devices</b></string> <string name="accessibility_hearing_device_footer_summary"><![CDATA[To find other hearing devices that arent supported by ASHA or LE Audio, tap <b>Pair new device</b> > <b>See more devices</b>]]></string>
<!-- Description for text in accessibility hearing aids footer. Replace '>' to 'then' for TTS to announce. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=7451899224828040581] --> <!-- Content description for text in accessibility hearing aids footer to be announce. Replace '>' to 'then' compare to non tts version. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=7451899224828040581] -->
<string name="accessibility_hearing_device_footer_summary_tts">To find other hearing devices that arent supported by ASHA or LE Audio, tap <b>Pair new device</b> then <b>See more devices</b></string> <string name="accessibility_hearing_device_footer_summary_tts">To find other hearing devices that arent supported by ASHA or LE Audio, tap <b>Pair new device</b> then <b>See more devices</b></string>
<!-- Title for the pair hearing device page. [CHAR LIMIT=25] --> <!-- Title for the pair hearing device page. [CHAR LIMIT=25] -->
<string name="accessibility_hearing_device_pairing_page_title">Pair hearing device</string> <string name="accessibility_hearing_device_pairing_page_title">Pair hearing device</string>

View File

@@ -65,7 +65,6 @@
<com.android.settings.accessibility.AccessibilityFooterPreference <com.android.settings.accessibility.AccessibilityFooterPreference
android:key="hearing_device_footer" android:key="hearing_device_footer"
android:title="@string/accessibility_hearing_device_footer_summary"
android:selectable="false" android:selectable="false"
settings:searchable="false" settings:searchable="false"
settings:controller="com.android.settings.accessibility.HearingDeviceFooterPreferenceController"/> settings:controller="com.android.settings.accessibility.HearingDeviceFooterPreferenceController"/>

View File

@@ -17,6 +17,7 @@
package com.android.settings.accessibility; package com.android.settings.accessibility;
import android.content.Context; import android.content.Context;
import android.text.Html;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
@@ -42,6 +43,13 @@ public class HearingDeviceFooterPreferenceController extends
final AccessibilityFooterPreference footerPreference = final AccessibilityFooterPreference footerPreference =
screen.findPreference(getPreferenceKey()); 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 ">" // Need to update contentDescription string to announce "than" rather than ">"
final String summaryTts = mContext.getString( final String summaryTts = mContext.getString(
R.string.accessibility_hearing_device_footer_summary_tts); R.string.accessibility_hearing_device_footer_summary_tts);