Bug 906711 - Search buttons don't indicate the search engine. r=lucasr
authorMax Li <maxli@maxli.ca>
Fri, 23 Aug 2013 10:45:09 -0400
changeset 144143 9459d5c2e605aebf95c0fb2ff1e2e3f34c55477e
parent 144142 ebf9d108717c54f83c8aa7ed006cc154a493a843
child 144144 df05f5edf8caf2d4d2056cd41e25918b44d28d96
push id32885
push userryanvm@gmail.com
push dateFri, 23 Aug 2013 22:11:15 +0000
treeherdermozilla-inbound@d0fda982e6a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs906711
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 906711 - Search buttons don't indicate the search engine. r=lucasr
mobile/android/base/home/SearchEngineRow.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
--- a/mobile/android/base/home/SearchEngineRow.java
+++ b/mobile/android/base/home/SearchEngineRow.java
@@ -133,28 +133,40 @@ class SearchEngineRow extends AnimatedHe
         setOnLongClickListener(new OnLongClickListener() {
             @Override
             public boolean onLongClick(View v) {
                 return true;
             }
         });
     }
 
+    private void setDescriptionOnSuggestion(View v, String suggestion) {
+        v.setContentDescription(getResources().getString(R.string.suggestion_for_engine,
+                                                         mSearchEngine.name, suggestion));
+    }
+
     private String getSuggestionTextFromView(View v) {
         final TextView suggestionText = (TextView) v.findViewById(R.id.suggestion_text);
         return suggestionText.getText().toString();
     }
 
     private void setSuggestionOnView(View v, String suggestion) {
         final TextView suggestionText = (TextView) v.findViewById(R.id.suggestion_text);
         suggestionText.setText(suggestion);
+        setDescriptionOnSuggestion(suggestionText, suggestion);
     }
 
     public void setSearchTerm(String searchTerm) {
         mUserEnteredTextView.setText(searchTerm);
+
+        // mSearchEngine is not set in the first call to this method; the content description
+        // is instead initially set in updateFromSearchEngine.
+        if (mSearchEngine != null) {
+            setDescriptionOnSuggestion(mUserEnteredTextView, searchTerm);
+        }
     }
 
     public void setOnUrlOpenListener(OnUrlOpenListener listener) {
         mUrlOpenListener = listener;
     }
 
     public void setOnSearchListener(OnSearchListener listener) {
         mSearchListener = listener;
@@ -166,16 +178,19 @@ class SearchEngineRow extends AnimatedHe
 
     public void updateFromSearchEngine(SearchEngine searchEngine, boolean animate) {
         // Update search engine reference
         mSearchEngine = searchEngine;
 
         // Set the search engine icon (e.g., Google) for the row
         mIconView.updateImage(mSearchEngine.icon, mSearchEngine.name);
 
+        // Set the initial content description
+        setDescriptionOnSuggestion(mUserEnteredTextView, mUserEnteredTextView.getText().toString());
+
         // Add additional suggestions given by this engine
         final int recycledSuggestionCount = mSuggestionView.getChildCount();
         final int suggestionCount = mSearchEngine.suggestions.size();
 
         for (int i = 0; i < suggestionCount; i++) {
             final View suggestionItem;
 
             // Reuse suggestion views from recycled view, if possible
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -328,16 +328,21 @@ just addresses the organization to follo
 <!ENTITY bookmarkhistory_import_history "Importing history
                                          from Android">
 <!ENTITY bookmarkhistory_import_wait "Please wait...">
 
 <!-- Localization note (suggestions_prompt2): The placeholder &formatS; will be
      replaced with the name of the search engine. -->
 <!ENTITY suggestions_prompt2 "Would you like to turn on &formatS; search suggestions?">
 
+<!-- Localization note (suggestion_for_engine): The placeholder &formatS1; will be
+     replaced with the name of the search engine. The placeholder &formatS2; will be
+     replaced with the search query. -->
+<!ENTITY suggestion_for_engine "Search &formatS1; for &formatS2;">
+
 <!ENTITY webapp_generic_name "App">
 
 <!ENTITY searchable_description "Bookmarks and history">
 
 <!ENTITY devtools_remote_debugging_forward "Don\'t forget to set up port forwarding!">
 
  <!-- Updater notifications -->
 <!ENTITY updater_start_title2 "Update available for &brandShortName;">
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -6,16 +6,18 @@
 
 <!DOCTYPE resources [
 #includesubst @BRANDPATH@
 #includesubst @STRINGSPATH@
 #includesubst @SYNCSTRINGSPATH@
 
 <!-- C-style format strings. -->
 <!ENTITY formatS "&#037;s">
+<!ENTITY formatS1 "&#037;1&#036;s">
+<!ENTITY formatS2 "&#037;2&#036;s">
 <!ENTITY formatD "&#037;d">
 ]>
 
 #includesubst @BOOKMARKSPATH@
 <resources>
   <string name="moz_app_displayname">@MOZ_APP_DISPLAYNAME@</string>
 #include ../services/strings.xml.in
   <string name="no_space_to_start_error">&no_space_to_start_error;</string>
@@ -319,16 +321,18 @@
   <string name="updater_downloading_retry">&updater_downloading_retry2;</string>
 
   <string name="updater_apply_title">&updater_apply_title2;</string>
   <string name="updater_apply_select">&updater_apply_select2;</string>
 
   <!-- Search suggestions opt-in -->
   <string name="suggestions_prompt">&suggestions_prompt2;</string>
 
+  <string name="suggestion_for_engine">&suggestion_for_engine;</string>
+
   <!-- Set Image Notifications -->
   <string name="set_image_fail">&set_image_fail;</string>
   <string name="set_image_chooser_title">&set_image_chooser_title;</string>
 
   <!-- Contacts API -->
   <string name="contacts_account_chooser_dialog_title">Share contacts from...</string>