summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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(