From 1969b8799085322f9ef6e75b78c2c9a5d5944801 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Tue, 22 Mar 2011 11:52:48 -0700 Subject: Fix bug 4142917 - Add support for specifying a custom home icon in action bar Add ActionBar methods for setting icon and logo. Change-Id: I6151689138c734b7212c3469b8ba8f28f0fd5ec4 --- api/current.xml | 52 +++++++++++++++++++ core/java/android/app/ActionBar.java | 60 ++++++++++++++++++++++ .../com/android/internal/app/ActionBarImpl.java | 33 ++++++------ .../com/android/internal/widget/ActionBarView.java | 15 ++++++ 4 files changed, 144 insertions(+), 16 deletions(-) diff --git a/api/current.xml b/api/current.xml index 16ba6be..3305a32 100644 --- a/api/current.xml +++ b/api/current.xml @@ -22045,6 +22045,32 @@ + + + + + + + + + + + + + + + + = 0 && mSelectedTabIndex < getTabCount()) { - mActionView.setTabSelected(mSelectedTabIndex); - } - } + @Override + public void setIcon(Drawable icon) { + mActionView.setIcon(icon); + } + + @Override + public void setLogo(int resId) { + mActionView.setLogo(mContext.getResources().getDrawable(resId)); + } + + @Override + public void setLogo(Drawable logo) { + mActionView.setLogo(logo); } } diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java index 81d02ee..2d9a9f2 100644 --- a/core/java/com/android/internal/widget/ActionBarView.java +++ b/core/java/com/android/internal/widget/ActionBarView.java @@ -416,6 +416,21 @@ public class ActionBarView extends ViewGroup { } } + public void setIcon(Drawable icon) { + mIcon = icon; + if (icon != null && + ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) { + mIconView.setImageDrawable(icon); + } + } + + public void setLogo(Drawable logo) { + mLogo = logo; + if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) { + mIconView.setImageDrawable(logo); + } + } + public void setNavigationMode(int mode) { final int oldMode = mNavigationMode; if (mode != oldMode) { -- cgit v1.1