Bug 895000 - Set content descriptions on page action buttons. r=wesj
authorMax Li <maxli@maxli.ca>
Thu, 18 Jul 2013 14:50:42 -0400
changeset 139155 7b3d37195619800e49ec8effedb383808e99fb6a
parent 139132 0d0263a58f06f92d9648d23c9368cd05ea5241f9
child 139156 ecc75387637acab4120f6f062a9c900dd1abad82
push id1890
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 17:44:21 +0000
treeherderfx-team@20848adc9980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs895000
milestone25.0a1
Bug 895000 - Set content descriptions on page action buttons. r=wesj
mobile/android/base/PageActionLayout.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
--- a/mobile/android/base/PageActionLayout.java
+++ b/mobile/android/base/PageActionLayout.java
@@ -161,43 +161,60 @@ public class PageActionLayout extends Li
         if (buttonClickedId.equals(MENU_BUTTON_KEY)) {
             showMenu(v, mPageActionList.size() - mMaxVisiblePageActions + 1);
             return true;
         } else {
             return mPageActionList.get(buttonClickedId).onLongClick();
         }
     }
 
+    private void setActionForView(final ImageButton view, final PageAction pageAction) {
+        if (pageAction == null) {
+            view.setTag(null);
+            ThreadUtils.postToUiThread(new Runnable() {
+                @Override
+                public void run () {
+                    view.setImageDrawable(null);
+                    view.setVisibility(View.GONE);
+                    view.setContentDescription(null);
+                }
+            });
+            return;
+        }
+
+        view.setTag(pageAction.getID());
+        ThreadUtils.postToUiThread(new Runnable() {
+            @Override
+            public void run () {
+                view.setImageDrawable(pageAction.getDrawable());
+                view.setVisibility(View.VISIBLE);
+                view.setContentDescription(pageAction.getTitle());
+            }
+        });
+    }
+
     private void refreshPageActionIcons() {
         final Resources resources = mContext.getResources();
         for(int index = 0; index < this.getChildCount(); index++) {
             final ImageButton v = (ImageButton)this.getChildAt(index);
             final PageAction pageAction = getPageActionForViewAt(index);
 
-            if (index == (this.getChildCount() - 1)) {
-                String id = (pageAction != null) ? pageAction.getID() : null;
-                v.setTag((mPageActionList.size() > mMaxVisiblePageActions) ? MENU_BUTTON_KEY : id);
+            // If there are more pageactions then buttons, set the menu icon. Otherwise set the page action's icon if there is a page action.
+            if (index == (this.getChildCount() - 1) && mPageActionList.size() > mMaxVisiblePageActions) {
+                v.setTag(MENU_BUTTON_KEY);
                 ThreadUtils.postToUiThread(new Runnable() {
                     @Override
                     public void run () {
-                        // If there are more pageactions then buttons, set the menu icon. Otherwise set the page action's icon if there is a page action.
-                        Drawable d = (pageAction != null) ? pageAction.getDrawable() : null;
-                        v.setImageDrawable((mPageActionList.size() > mMaxVisiblePageActions) ? resources.getDrawable(R.drawable.icon_pageaction) : d);
+                        v.setImageDrawable(resources.getDrawable(R.drawable.icon_pageaction));
                         v.setVisibility((pageAction != null) ? View.VISIBLE : View.GONE);
+                        v.setContentDescription(resources.getString(R.string.page_action_dropmarker_description));
                     }
                 });
             } else {
-                v.setTag((pageAction != null) ? pageAction.getID() : null);
-                ThreadUtils.postToUiThread(new Runnable() {
-                    @Override
-                    public void run () {
-                        v.setImageDrawable((pageAction != null) ? pageAction.getDrawable() : null);
-                        v.setVisibility((pageAction != null) ? View.VISIBLE : View.GONE);
-                    }
-                });
+                setActionForView(v, pageAction);
             }
         }
     }
 
     private PageAction getPageActionForViewAt(int index) {
         /**
          * We show the user the most recent pageaction added since this keeps the user aware of any new page actions being added
          * Also, the order of the pageAction is important i.e. if a page action is added, instead of shifting the pagactions to the
@@ -308,9 +325,9 @@ public class PageActionLayout extends Li
 
         public boolean onLongClick() {
             if (mOnPageActionClickListeners != null) {
                 return mOnPageActionClickListeners.onLongClick(mId);
             }
             return false;
         }
     }
-}
\ No newline at end of file
+}
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -247,17 +247,20 @@ size. -->
 <!ENTITY site_settings_clear        "Clear">
 <!ENTITY site_settings_no_settings  "There are no settings to clear.">
 
 <!ENTITY reading_list "Reading List">
 <!ENTITY reading_list_added "Page added to your Reading List">
 <!ENTITY reading_list_removed "Page removed from your Reading List">
 <!ENTITY reading_list_failed "Failed to add page to your Reading List">
 <!ENTITY reading_list_duplicate "Page already in your Reading List">
-<!ENTITY reader "Reader">
+
+<!-- Localization note : These strings are used as alternate text for accessibility.
+     They are not visible in the UI. -->
+<!ENTITY page_action_dropmarker_description "Additional Actions">
 
 <!ENTITY masterpassword_create_title "Create Master Password">
 <!ENTITY masterpassword_remove_title "Remove Master Password">
 <!ENTITY masterpassword_password "Password">
 <!ENTITY masterpassword_confirm "Confirm password">
 
 <!ENTITY button_ok "OK">
 <!ENTITY button_cancel "Cancel">
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -191,16 +191,18 @@
   <string name="site_settings_no_settings">&site_settings_no_settings;</string>
 
   <string name="reading_list">&reading_list;</string>
   <string name="reading_list_added">&reading_list_added;</string>
   <string name="reading_list_removed">&reading_list_removed;</string>
   <string name="reading_list_failed">&reading_list_failed;</string>
   <string name="reading_list_duplicate">&reading_list_duplicate;</string>
 
+  <string name="page_action_dropmarker_description">&page_action_dropmarker_description;</string>
+
   <string name="contextmenu_open_new_tab">&contextmenu_open_new_tab;</string>
   <string name="contextmenu_open_private_tab">&contextmenu_open_private_tab;</string>
   <string name="contextmenu_open_in_reader">&contextmenu_open_in_reader;</string>
   <string name="contextmenu_remove_history">&contextmenu_remove_history;</string>
   <string name="contextmenu_remove_bookmark">&contextmenu_remove_bookmark;</string>
   <string name="contextmenu_add_to_launcher">&contextmenu_add_to_launcher;</string>
   <string name="contextmenu_share">&contextmenu_share;</string>
   <string name="contextmenu_pasteandgo">&contextmenu_pasteandgo;</string>