public void setIcon(Drawable icon) { mIcon = icon; if (icon != null && ((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) { mHomeLayout.setIcon(icon); } }
public void setLogo(Drawable logo) { mLogo = logo; if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) { mHomeLayout.setIcon(logo); } }
public void setDisplayOptions(int options) { final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions; mDisplayOptions = options; if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) { final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0; final int vis = showHome && mExpandedActionView == null ? VISIBLE : GONE; mHomeLayout.setVisibility(vis); if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) { final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0; mHomeLayout.setUp(setUp); // Showing home as up implicitly enables interaction with it. // In honeycomb it was always enabled, so make this transition // a bit easier for developers in the common case. // (It would be silly to show it as up without responding to it.) if (setUp) { setHomeButtonEnabled(true); } } if ((flagsChanged & ActionBar.DISPLAY_USE_LOGO) != 0) { final boolean logoVis = mLogo != null && (options & ActionBar.DISPLAY_USE_LOGO) != 0; mHomeLayout.setIcon(logoVis ? mLogo : mIcon); } if ((flagsChanged & ActionBar.DISPLAY_SHOW_TITLE) != 0) { if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) { initTitle(); } else { removeView(mTitleLayout); } } if (mTitleLayout != null && (flagsChanged & (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) { final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); mTitleLayout.setEnabled(!showHome && homeAsUp); } if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { addView(mCustomNavView); } else { removeView(mCustomNavView); } } requestLayout(); } else { invalidate(); } // Make sure the home button has an accurate content description for accessibility. if (!mHomeLayout.isEnabled()) { mHomeLayout.setContentDescription(null); } else if ((options & ActionBar.DISPLAY_HOME_AS_UP) != 0) { mHomeLayout.setContentDescription( mContext.getResources().getText(R.string.abs__action_bar_up_description)); } else { mHomeLayout.setContentDescription( mContext.getResources().getText(R.string.abs__action_bar_home_description)); } }