summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2014-07-19 16:01:12 -0700
committerAdam Powell <adamp@google.com>2014-07-19 16:01:12 -0700
commit2aa09a94dd540650d3ebad7363e4fb3aab2ebc95 (patch)
treefa1b6f4005689ac78253745105cbf6c1cabf7889
parent5abc26e00a18abb7547c11bd06a0eece49f8eb09 (diff)
downloadframeworks_base-2aa09a94dd540650d3ebad7363e4fb3aab2ebc95.zip
frameworks_base-2aa09a94dd540650d3ebad7363e4fb3aab2ebc95.tar.gz
frameworks_base-2aa09a94dd540650d3ebad7363e4fb3aab2ebc95.tar.bz2
Don't apply the ActionBar style to a Toolbar as a result of setActionBar
While this is a convenient idea, it effectively means that any styling directly applied to a Toolbar in a layout gets stomped by the theme-global ActionBar style. Obey the more local, specific styling from the Toolbar instead. Change-Id: Ief6a7cb90052bdced87f1dc0925c1dfbc0df4792
-rw-r--r--core/java/android/widget/Toolbar.java2
-rw-r--r--core/java/com/android/internal/app/ToolbarActionBar.java2
-rw-r--r--core/java/com/android/internal/widget/ToolbarWidgetWrapper.java110
3 files changed, 59 insertions, 55 deletions
diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java
index c1b4286..64d03be 100644
--- a/core/java/android/widget/Toolbar.java
+++ b/core/java/android/widget/Toolbar.java
@@ -1593,7 +1593,7 @@ public class Toolbar extends ViewGroup {
/** @hide */
public DecorToolbar getWrapper() {
if (mWrapper == null) {
- mWrapper = new ToolbarWidgetWrapper(this);
+ mWrapper = new ToolbarWidgetWrapper(this, true);
}
return mWrapper;
}
diff --git a/core/java/com/android/internal/app/ToolbarActionBar.java b/core/java/com/android/internal/app/ToolbarActionBar.java
index 50effd0..1bcb684 100644
--- a/core/java/com/android/internal/app/ToolbarActionBar.java
+++ b/core/java/com/android/internal/app/ToolbarActionBar.java
@@ -63,7 +63,7 @@ public class ToolbarActionBar extends ActionBar {
public ToolbarActionBar(Toolbar toolbar, CharSequence title, Window.Callback windowCallback) {
mToolbar = toolbar;
- mDecorToolbar = new ToolbarWidgetWrapper(toolbar);
+ mDecorToolbar = new ToolbarWidgetWrapper(toolbar, false);
mWindowCallback = windowCallback;
mDecorToolbar.setWindowCallback(mWindowCallback);
toolbar.setOnMenuItemClickListener(mMenuClicker);
diff --git a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java
index 8213cb7..e1a4909 100644
--- a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java
+++ b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java
@@ -81,77 +81,81 @@ public class ToolbarWidgetWrapper implements DecorToolbar {
private int mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
- public ToolbarWidgetWrapper(Toolbar toolbar) {
+ public ToolbarWidgetWrapper(Toolbar toolbar, boolean style) {
mToolbar = toolbar;
mTitle = toolbar.getTitle();
mSubtitle = toolbar.getSubtitle();
mTitleSet = !TextUtils.isEmpty(mTitle);
- final TypedArray a = toolbar.getContext().obtainStyledAttributes(null,
- R.styleable.ActionBar, R.attr.actionBarStyle, 0);
+ if (style) {
+ final TypedArray a = toolbar.getContext().obtainStyledAttributes(null,
+ R.styleable.ActionBar, R.attr.actionBarStyle, 0);
- final CharSequence title = a.getText(R.styleable.ActionBar_title);
- if (!TextUtils.isEmpty(title)) {
- setTitle(title);
- }
+ final CharSequence title = a.getText(R.styleable.ActionBar_title);
+ if (!TextUtils.isEmpty(title)) {
+ setTitle(title);
+ }
- final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
- if (!TextUtils.isEmpty(subtitle)) {
- setSubtitle(subtitle);
- }
+ final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle);
+ if (!TextUtils.isEmpty(subtitle)) {
+ setSubtitle(subtitle);
+ }
- final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
- if (logo != null) {
- setLogo(logo);
- }
+ final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo);
+ if (logo != null) {
+ setLogo(logo);
+ }
- final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
- if (icon != null) {
- setIcon(icon);
- }
+ final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon);
+ if (icon != null) {
+ setIcon(icon);
+ }
- final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
- if (navIcon != null) {
- setNavigationIcon(navIcon);
- }
+ final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
+ if (navIcon != null) {
+ setNavigationIcon(navIcon);
+ }
- setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));
+ setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0));
- final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
- if (customNavId != 0) {
- setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId,
- mToolbar, false));
- setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
- }
+ final int customNavId = a.getResourceId(
+ R.styleable.ActionBar_customNavigationLayout, 0);
+ if (customNavId != 0) {
+ setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId,
+ mToolbar, false));
+ setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM);
+ }
- final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
- if (height > 0) {
- final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
- lp.height = height;
- mToolbar.setLayoutParams(lp);
- }
+ final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
+ if (height > 0) {
+ final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams();
+ lp.height = height;
+ mToolbar.setLayoutParams(lp);
+ }
- final int contentInsetStart = a.getDimensionPixelOffset(
- R.styleable.ActionBar_contentInsetStart, -1);
- final int contentInsetEnd = a.getDimensionPixelOffset(
- R.styleable.ActionBar_contentInsetEnd, -1);
- if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
- mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0),
- Math.max(contentInsetEnd, 0));
- }
+ final int contentInsetStart = a.getDimensionPixelOffset(
+ R.styleable.ActionBar_contentInsetStart, -1);
+ final int contentInsetEnd = a.getDimensionPixelOffset(
+ R.styleable.ActionBar_contentInsetEnd, -1);
+ if (contentInsetStart >= 0 || contentInsetEnd >= 0) {
+ mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0),
+ Math.max(contentInsetEnd, 0));
+ }
- final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
- if (titleTextStyle != 0) {
- mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
- }
+ final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
+ if (titleTextStyle != 0) {
+ mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle);
+ }
- final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
- if (subtitleTextStyle != 0) {
- mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
- }
+ final int subtitleTextStyle = a.getResourceId(
+ R.styleable.ActionBar_subtitleTextStyle, 0);
+ if (subtitleTextStyle != 0) {
+ mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle);
+ }
- a.recycle();
+ a.recycle();
+ }
if (TextUtils.isEmpty(mToolbar.getNavigationContentDescription())) {
mToolbar.setNavigationContentDescription(