OSDN Git Service

Remove duplicate Toolbar method for setting content description
authorAlan Viverette <alanv@google.com>
Fri, 25 Jul 2014 19:57:31 +0000 (12:57 -0700)
committerAlan Viverette <alanv@google.com>
Fri, 25 Jul 2014 19:57:31 +0000 (12:57 -0700)
Also moves the setNavigationIcon(int) method closer to the one that
takes a Drawable.

BUG: 16491458
Change-Id: Ia02f05e6270c9d420f61f7ab34117b4c7e6548ec

api/current.txt
core/java/android/widget/Toolbar.java
core/java/com/android/internal/app/ToolbarActionBar.java

index d482260..f7c24db 100644 (file)
@@ -39749,8 +39749,6 @@ package android.widget {
     method public void setLogoDescription(java.lang.CharSequence);
     method public void setNavigationContentDescription(java.lang.CharSequence);
     method public void setNavigationContentDescription(int);
-    method public void setNavigationDescription(int);
-    method public void setNavigationDescription(java.lang.CharSequence);
     method public void setNavigationIcon(int);
     method public void setNavigationIcon(android.graphics.drawable.Drawable);
     method public void setNavigationOnClickListener(android.view.View.OnClickListener);
index 71102e8..0b15eb6 100644 (file)
@@ -17,6 +17,7 @@
 package android.widget;
 
 import android.annotation.NonNull;
+import android.annotation.Nullable;
 import android.app.ActionBar;
 import android.content.Context;
 import android.content.res.TypedArray;
@@ -654,27 +655,13 @@ public class Toolbar extends ViewGroup {
     }
 
     /**
-     * Set the icon to use for the toolbar's navigation button.
-     *
-     * <p>The navigation button appears at the start of the toolbar if present. Setting an icon
-     * will make the navigation button visible.</p>
-     *
-     * <p>If you use a navigation icon you should also set a description for its action using
-     * {@link #setNavigationDescription(int)}. This is used for accessibility and tooltips.</p>
-     *
-     * @param resId Resource ID of a drawable to set
-     */
-    public void setNavigationIcon(int resId) {
-        setNavigationIcon(getContext().getDrawable(resId));
-    }
-
-    /**
      * Retrieve the currently configured content description for the navigation button view.
      * This will be used to describe the navigation action to users through mechanisms such
      * as screen readers or tooltips.
      *
      * @return The navigation button's content description
      */
+    @Nullable
     public CharSequence getNavigationContentDescription() {
         return mNavButtonView != null ? mNavButtonView.getContentDescription() : null;
     }
@@ -684,11 +671,11 @@ public class Toolbar extends ViewGroup {
      * description will be read via screen readers or other accessibility systems to explain
      * the action of the navigation button.
      *
-     * @param description Content description to set
+     * @param resId Resource ID of a content description string to set, or 0 to
+     *              clear the description
      */
-    public void setNavigationContentDescription(CharSequence description) {
-        ensureNavButtonView();
-        mNavButtonView.setContentDescription(description);
+    public void setNavigationContentDescription(int resId) {
+        setNavigationContentDescription(resId != 0 ? getContext().getText(resId) : null);
     }
 
     /**
@@ -696,11 +683,32 @@ public class Toolbar extends ViewGroup {
      * description will be read via screen readers or other accessibility systems to explain
      * the action of the navigation button.
      *
-     * @param resId Resource ID of a content description string to set
+     * @param description Content description to set, or <code>null</code> to
+     *                    clear the content description
      */
-    public void setNavigationContentDescription(int resId) {
-        ensureNavButtonView();
-        mNavButtonView.setContentDescription(resId != 0 ? getContext().getText(resId) : null);
+    public void setNavigationContentDescription(@Nullable CharSequence description) {
+        if (!TextUtils.isEmpty(description)) {
+            ensureNavButtonView();
+        }
+        if (mNavButtonView != null) {
+            mNavButtonView.setContentDescription(description);
+        }
+    }
+
+    /**
+     * Set the icon to use for the toolbar's navigation button.
+     *
+     * <p>The navigation button appears at the start of the toolbar if present. Setting an icon
+     * will make the navigation button visible.</p>
+     *
+     * <p>If you use a navigation icon you should also set a description for its action using
+     * {@link #setNavigationContentDescription(int)}. This is used for accessibility and
+     * tooltips.</p>
+     *
+     * @param resId Resource ID of a drawable to set
+     */
+    public void setNavigationIcon(int resId) {
+        setNavigationIcon(getContext().getDrawable(resId));
     }
 
     /**
@@ -710,11 +718,12 @@ public class Toolbar extends ViewGroup {
      * will make the navigation button visible.</p>
      *
      * <p>If you use a navigation icon you should also set a description for its action using
-     * {@link #setNavigationDescription(int)}. This is used for accessibility and tooltips.</p>
+     * {@link #setNavigationContentDescription(int)}. This is used for accessibility and
+     * tooltips.</p>
      *
-     * @param icon Drawable to set
+     * @param icon Drawable to set, may be null to clear the icon
      */
-    public void setNavigationIcon(Drawable icon) {
+    public void setNavigationIcon(@Nullable Drawable icon) {
         if (icon != null) {
             ensureNavButtonView();
             if (mNavButtonView.getParent() == null) {
@@ -733,40 +742,12 @@ public class Toolbar extends ViewGroup {
      *
      * @return The navigation icon drawable
      */
+    @Nullable
     public Drawable getNavigationIcon() {
         return mNavButtonView != null ? mNavButtonView.getDrawable() : null;
     }
 
     /**
-     * Set a description for the navigation button.
-     *
-     * <p>This description string is used for accessibility, tooltips and other facilities
-     * to improve discoverability.</p>
-     *
-     * @param resId Resource ID of a string to set
-     */
-    public void setNavigationDescription(int resId) {
-        setNavigationDescription(getContext().getText(resId));
-    }
-
-    /**
-     * Set a description for the navigation button.
-     *
-     * <p>This description string is used for accessibility, tooltips and other facilities
-     * to improve discoverability.</p>
-     *
-     * @param description String to set as the description
-     */
-    public void setNavigationDescription(CharSequence description) {
-        if (!TextUtils.isEmpty(description)) {
-            ensureNavButtonView();
-        }
-        if (mNavButtonView != null) {
-            mNavButtonView.setContentDescription(description);
-        }
-    }
-
-    /**
      * Set a listener to respond to navigation events.
      *
      * <p>This listener will be called whenever the user clicks the navigation button
index 1bcb684..298dd44 100644 (file)
@@ -154,7 +154,7 @@ public class ToolbarActionBar extends ActionBar {
 
     @Override
     public void setHomeActionContentDescription(CharSequence description) {
-        mToolbar.setNavigationDescription(description);
+        mToolbar.setNavigationContentDescription(description);
     }
 
     @Override
@@ -164,7 +164,7 @@ public class ToolbarActionBar extends ActionBar {
 
     @Override
     public void setHomeActionContentDescription(int resId) {
-        mToolbar.setNavigationDescription(resId);
+        mToolbar.setNavigationContentDescription(resId);
     }
 
     @Override