OSDN Git Service

Fix incorrect content description on action bar home/up
authorAdam Powell <adamp@google.com>
Fri, 1 Nov 2013 23:32:37 +0000 (16:32 -0700)
committerAdam Powell <adamp@google.com>
Fri, 1 Nov 2013 23:36:49 +0000 (16:36 -0700)
Some stray code from a previous change caused an erroneous content
description to be set on the wrong view in the action bar. Correct
this and sync with the right behavior.

Bug 10969992

Change-Id: I4deaa3528b4bc222e25354679fa93f8316fa2d70

core/java/com/android/internal/widget/ActionBarView.java

index b5d74e8..5f9d8f2 100644 (file)
@@ -566,7 +566,11 @@ public class ActionBarView extends AbsActionBarView {
         mUpGoerFive.setEnabled(enable);
         mUpGoerFive.setFocusable(enable);
         // Make sure the home button has an accurate content description for accessibility.
-        if (!enable) {
+        updateHomeAccessibility(enable);
+    }
+
+    private void updateHomeAccessibility(boolean homeEnabled) {
+        if (!homeEnabled) {
             mUpGoerFive.setContentDescription(null);
             mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
         } else {
@@ -677,19 +681,7 @@ public class ActionBarView extends AbsActionBarView {
         }
 
         // Make sure the home button has an accurate content description for accessibility.
-        if (!mHomeLayout.isEnabled()) {
-            mHomeLayout.setContentDescription(null);
-            mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
-        } else {
-            mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO);
-            if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
-                mHomeLayout.setContentDescription(mContext.getResources().getText(
-                        R.string.action_bar_up_description));
-            } else {
-                mHomeLayout.setContentDescription(mContext.getResources().getText(
-                        R.string.action_bar_home_description));
-            }
-        }
+        updateHomeAccessibility(!mUpGoerFive.isEnabled());
     }
 
     public void setIcon(Drawable icon) {