Bug 950698 - Part 0: Use formatted strings for image. r=bnicholson

This commit is contained in:
Chenxia Liu 2014-02-20 13:11:24 -08:00
parent 73306afda2
commit 2f8a210663
3 changed files with 11 additions and 7 deletions

View File

@ -41,6 +41,9 @@ public class ReadingListPanel extends HomeFragment {
// Cursor loader ID for reading list
private static final int LOADER_ID_READING_LIST = 0;
// Formatted string in hint text to be replaced with an icon.
private final String MATCH_STRING = "%I";
// Adapter for the list of reading list items
private ReadingListAdapter mAdapter;
@ -171,17 +174,17 @@ public class ReadingListPanel extends HomeFragment {
String readingListHint = emptyHint.getText().toString();
// Use an ImageSpan to include the reader icon in the "Tip".
int imageSpanIndex = readingListHint.indexOf("%I");
int imageSpanIndex = readingListHint.indexOf(MATCH_STRING);
if (imageSpanIndex != -1) {
final ImageSpan readingListIcon = new ImageSpan(getActivity(), R.drawable.reader_cropped, ImageSpan.ALIGN_BOTTOM);
final SpannableStringBuilder hintBuilder = new SpannableStringBuilder(readingListHint);
// Add additional spacing.
hintBuilder.insert(imageSpanIndex + 2, " ");
hintBuilder.insert(imageSpanIndex + MATCH_STRING.length(), " ");
hintBuilder.insert(imageSpanIndex, " ");
// Add icon.
hintBuilder.setSpan(readingListIcon, imageSpanIndex + 1, imageSpanIndex + 3, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
hintBuilder.setSpan(readingListIcon, imageSpanIndex + 1, imageSpanIndex + MATCH_STRING.length() + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
emptyHint.setText(hintBuilder, TextView.BufferType.SPANNABLE);
}

View File

@ -311,9 +311,9 @@ size. -->
<!ENTITY home_reading_list_empty "Articles you save for later show up here.">
<!-- Localization note (home_reading_list_hint): The "TIP" string is synonymous to "hint", "clue", etc. This string is displayed
as an advisory message on how to add content to the reading list when the reading list empty.
The "&#37;I" in the string will be replaced by a small image of the icon described, and can be moved to wherever
it is applicable. Please keep the spacing around the "&#37;I" string. -->
<!ENTITY home_reading_list_hint "TIP: Save articles to your reading list by long pressing the &#37;I icon when it appears in the title bar.">
The placeholder &formatI; will be replaced by a small image of the icon described, and can be moved to wherever
it is applicable. -->
<!ENTITY home_reading_list_hint2 "TIP: Save articles to your reading list by long pressing the &formatI; icon when it appears in the title bar.">
<!-- Localization note (home_reading_list_hint_accessible): This string is used
as alternate text for accessibility. It is not visible in the UI. -->
<!ENTITY home_reading_list_hint_accessible "TIP: Save articles to your reading list by long pressing the reader mode button when it appears in the title bar.">

View File

@ -10,6 +10,7 @@
#includesubst @SYNCSTRINGSPATH@
<!-- C-style format strings. -->
<!ENTITY formatI "&#037;I">
<!ENTITY formatS "&#037;s">
<!ENTITY formatS1 "&#037;1&#036;s">
<!ENTITY formatS2 "&#037;2&#036;s">
@ -289,7 +290,7 @@
<string name="home_most_recent_title">&home_most_recent_title;</string>
<string name="home_most_recent_empty">&home_most_recent_empty;</string>
<string name="home_reading_list_empty">&home_reading_list_empty;</string>
<string name="home_reading_list_hint">&home_reading_list_hint;</string>
<string name="home_reading_list_hint">&home_reading_list_hint2;</string>
<string name="home_reading_list_hint_accessible">&home_reading_list_hint_accessible;</string>
<string name="pin_site_dialog_hint">&pin_site_dialog_hint;</string>