Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e88700a2 authored by Alan Viverette's avatar Alan Viverette
Browse files

Remove duplicate Toolbar method for setting content description

Also moves the setNavigationIcon(int) method closer to the one that
takes a Drawable.

BUG: 16491458
Change-Id: Ia02f05e6270c9d420f61f7ab34117b4c7e6548ec
parent 63e44bd9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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);
+36 −55
Original line number Diff line number Diff line
@@ -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;
@@ -653,21 +654,6 @@ 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
@@ -675,6 +661,7 @@ public class Toolbar extends ViewGroup {
     *
     * @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,16 @@ 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) {
    public void setNavigationContentDescription(@Nullable CharSequence description) {
        if (!TextUtils.isEmpty(description)) {
            ensureNavButtonView();
        mNavButtonView.setContentDescription(resId != 0 ? getContext().getText(resId) : null);
        }
        if (mNavButtonView != null) {
            mNavButtonView.setContentDescription(description);
        }
    }

    /**
@@ -710,11 +702,28 @@ 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 resId Resource ID of a drawable to set
     */
    public void setNavigationIcon(Drawable icon) {
    public void setNavigationIcon(int resId) {
        setNavigationIcon(getContext().getDrawable(resId));
    }

    /**
     * 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 icon Drawable to set, may be null to clear the icon
     */
    public void setNavigationIcon(@Nullable Drawable icon) {
        if (icon != null) {
            ensureNavButtonView();
            if (mNavButtonView.getParent() == null) {
@@ -733,39 +742,11 @@ 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.
     *
+2 −2
Original line number Diff line number Diff line
@@ -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