From 8f99df4908da110555b6bd5aa42dc6f48dc1a724 Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Thu, 20 Feb 2014 13:11:24 -0800 Subject: [PATCH] Bug 950698 - Part 0: Use formatted strings for image. r=bnicholson --- mobile/android/base/home/ReadingListPanel.java | 9 ++++++--- mobile/android/base/locales/en-US/android_strings.dtd | 6 +++--- mobile/android/base/strings.xml.in | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mobile/android/base/home/ReadingListPanel.java b/mobile/android/base/home/ReadingListPanel.java index 228a0c122e8..797583c9b86 100644 --- a/mobile/android/base/home/ReadingListPanel.java +++ b/mobile/android/base/home/ReadingListPanel.java @@ -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); } diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 8691a5184ce..706d5c4793d 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -311,9 +311,9 @@ size. --> - + The placeholder &formatI; will be replaced by a small image of the icon described, and can be moved to wherever + it is applicable. --> + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 71092d5bcd6..63d7469dfaf 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -10,6 +10,7 @@ #includesubst @SYNCSTRINGSPATH@ + @@ -289,7 +290,7 @@ &home_most_recent_title; &home_most_recent_empty; &home_reading_list_empty; - &home_reading_list_hint; + &home_reading_list_hint2; &home_reading_list_hint_accessible; &pin_site_dialog_hint;