summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-07-25 20:09:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-24 22:06:48 +0000
commit78b7211507eefdf48a23050284195e39bced9313 (patch)
tree434e6e3939e0d431ed0e37a38391d5aaddb00fcb
parentc437f6eef2e92fd1ca1c542a8e41315253ec7747 (diff)
parente88700a2ad69e9b99824f2de3d8ba3d44054b24c (diff)
downloadframeworks_base-78b7211507eefdf48a23050284195e39bced9313.zip
frameworks_base-78b7211507eefdf48a23050284195e39bced9313.tar.gz
frameworks_base-78b7211507eefdf48a23050284195e39bced9313.tar.bz2
Merge "Remove duplicate Toolbar method for setting content description" into lmp-dev
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/widget/Toolbar.java91
-rw-r--r--core/java/com/android/internal/app/ToolbarActionBar.java4
3 files changed, 38 insertions, 59 deletions
diff --git a/api/current.txt b/api/current.txt
index fe66f19..a94d10b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -39754,8 +39754,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);
diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java
index 71102e8..0b15eb6 100644
--- a/core/java/android/widget/Toolbar.java
+++ b/core/java/android/widget/Toolbar.java
@@ -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
diff --git a/core/java/com/android/internal/app/ToolbarActionBar.java b/core/java/com/android/internal/app/ToolbarActionBar.java
index 1bcb684..298dd44 100644
--- a/core/java/com/android/internal/app/ToolbarActionBar.java
+++ b/core/java/com/android/internal/app/ToolbarActionBar.java
@@ -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