From 7c13bc2a7090544a04fc93813794a8b97bc86ff7 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Thu, 28 Aug 2014 18:19:59 -0700 Subject: [PATCH] Add xml attributes to Toolbar for navigation icon ...to match the existing setters/getters. Change-Id: I9814c5d7f2aa0559c93fbb74881e29064473f186 --- api/current.txt | 2 ++ core/java/android/widget/Toolbar.java | 10 ++++++++++ core/res/res/values/attrs.xml | 2 ++ core/res/res/values/public.xml | 2 ++ 4 files changed, 16 insertions(+) diff --git a/api/current.txt b/api/current.txt index ec00363112126..43b5d9b05d31d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -905,6 +905,8 @@ package android { field public static final int multiprocess = 16842771; // 0x1010013 field public static final int name = 16842755; // 0x1010003 field public static final int navigationBarColor = 16843858; // 0x1010452 + field public static final int navigationContentDescription = 16843970; // 0x10104c2 + field public static final int navigationIcon = 16843969; // 0x10104c1 field public static final int navigationMode = 16843471; // 0x10102cf field public static final int negativeButtonText = 16843254; // 0x10101f6 field public static final int nestedScrollingEnabled = 16843830; // 0x1010436 diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java index 818efaa2f8dc4..30ea7fbf2f113 100644 --- a/core/java/android/widget/Toolbar.java +++ b/core/java/android/widget/Toolbar.java @@ -244,6 +244,16 @@ public class Toolbar extends ViewGroup { // Set the default context, since setPopupTheme() may be a no-op. mPopupContext = mContext; setPopupTheme(a.getResourceId(R.styleable.Toolbar_popupTheme, 0)); + + final Drawable navIcon = a.getDrawable(R.styleable.Toolbar_navigationIcon); + if (navIcon != null) { + setNavigationIcon(navIcon); + final CharSequence navDesc = a.getText( + R.styleable.Toolbar_navigationContentDescription); + if (!TextUtils.isEmpty(navDesc)) { + setNavigationContentDescription(navDesc); + } + } a.recycle(); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index f825c29f2d42e..cf1794bac2a77 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -7322,6 +7322,8 @@ + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 3b49bed3fdc44..d452739c9c6e2 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2280,6 +2280,8 @@ + +