Methods Summary |
---|
private java.lang.CharSequence | buildHomeContentDescription()Compose a content description for the Home/Up affordance.
As this encompasses the icon/logo, title and subtitle all in one, we need
a description for the whole wad of stuff that can be localized properly.
final CharSequence homeDesc;
if (mHomeDescription != null) {
homeDesc = mHomeDescription;
} else {
if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
homeDesc = mContext.getResources().getText(mDefaultUpDescription);
} else {
homeDesc = mContext.getResources().getText(R.string.action_bar_home_description);
}
}
final CharSequence title = getTitle();
final CharSequence subtitle = getSubtitle();
if (!TextUtils.isEmpty(title)) {
final String result;
if (!TextUtils.isEmpty(subtitle)) {
result = getResources().getString(
R.string.action_bar_home_subtitle_description_format,
title, subtitle, homeDesc);
} else {
result = getResources().getString(R.string.action_bar_home_description_format,
title, homeDesc);
}
return result;
}
return homeDesc;
|
public boolean | canSplit()
return true;
|
public void | collapseActionView()
final MenuItemImpl item = mExpandedMenuPresenter == null ? null :
mExpandedMenuPresenter.mCurrentExpandedItem;
if (item != null) {
item.collapseActionView();
}
|
private void | configPresenters(com.android.internal.view.menu.MenuBuilder builder)
if (builder != null) {
builder.addMenuPresenter(mActionMenuPresenter, mPopupContext);
builder.addMenuPresenter(mExpandedMenuPresenter, mPopupContext);
} else {
mActionMenuPresenter.initForMenu(mPopupContext, null);
mExpandedMenuPresenter.initForMenu(mPopupContext, null);
mActionMenuPresenter.updateMenuView(true);
mExpandedMenuPresenter.updateMenuView(true);
}
|
protected ViewGroup.LayoutParams | generateDefaultLayoutParams()
// Used by custom nav views if they don't supply layout params. Everything else
// added to an ActionBarView should have them already.
return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY);
|
public ViewGroup.LayoutParams | generateLayoutParams(android.util.AttributeSet attrs)
return new ActionBar.LayoutParams(getContext(), attrs);
|
public ViewGroup.LayoutParams | generateLayoutParams(ViewGroup.LayoutParams lp)
if (lp == null) {
lp = generateDefaultLayoutParams();
}
return lp;
|
public android.view.View | getCustomView()
return mCustomNavView;
|
public int | getDisplayOptions()
return mDisplayOptions;
|
public int | getDropdownItemCount()
return mSpinnerAdapter != null ? mSpinnerAdapter.getCount() : 0;
|
public int | getDropdownSelectedPosition()
return mSpinner.getSelectedItemPosition();
|
public android.view.Menu | getMenu()
return mOptionsMenu;
|
public int | getNavigationMode()
return mNavigationMode;
|
public java.lang.CharSequence | getSubtitle()
return mSubtitle;
|
public java.lang.CharSequence | getTitle()
return mTitle;
|
public android.view.ViewGroup | getViewGroup()
return this;
|
public boolean | hasEmbeddedTabs()
return mIncludeTabs;
|
public boolean | hasExpandedActionView()
return mExpandedMenuPresenter != null &&
mExpandedMenuPresenter.mCurrentExpandedItem != null;
|
public boolean | hasIcon()
return mIcon != null;
|
public boolean | hasLogo()
return mLogo != null;
|
public void | initIndeterminateProgress()
mIndeterminateProgressView = new ProgressBar(mContext, null, 0,
mIndeterminateProgressStyle);
mIndeterminateProgressView.setId(R.id.progress_circular);
mIndeterminateProgressView.setVisibility(GONE);
addView(mIndeterminateProgressView);
|
public void | initProgress()
mProgressView = new ProgressBar(mContext, null, 0, mProgressStyle);
mProgressView.setId(R.id.progress_horizontal);
mProgressView.setMax(10000);
mProgressView.setVisibility(GONE);
addView(mProgressView);
|
private void | initTitle()
if (mTitleLayout == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
mTitleLayout = (LinearLayout) inflater.inflate(R.layout.action_bar_title_item,
this, false);
mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
if (mTitleStyleRes != 0) {
mTitleView.setTextAppearance(mContext, mTitleStyleRes);
}
if (mTitle != null) {
mTitleView.setText(mTitle);
}
if (mSubtitleStyleRes != 0) {
mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
}
if (mSubtitle != null) {
mSubtitleView.setText(mSubtitle);
mSubtitleView.setVisibility(VISIBLE);
}
}
ActionBarTransition.beginDelayedTransition(this);
mUpGoerFive.addView(mTitleLayout);
if (mExpandedActionView != null ||
(TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
// Don't show while in expanded mode or with empty text
mTitleLayout.setVisibility(GONE);
} else {
mTitleLayout.setVisibility(VISIBLE);
}
|
public boolean | isSplit()
return mSplitActionBar;
|
public boolean | isTitleTruncated()
if (mTitleView == null) {
return false;
}
final Layout titleLayout = mTitleView.getLayout();
if (titleLayout == null) {
return false;
}
final int lineCount = titleLayout.getLineCount();
for (int i = 0; i < lineCount; i++) {
if (titleLayout.getEllipsisCount(i) > 0) {
return true;
}
}
return false;
|
protected void | onConfigurationChanged(android.content.res.Configuration newConfig)
super.onConfigurationChanged(newConfig);
mTitleView = null;
mSubtitleView = null;
if (mTitleLayout != null && mTitleLayout.getParent() == mUpGoerFive) {
mUpGoerFive.removeView(mTitleLayout);
}
mTitleLayout = null;
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
initTitle();
}
if (mHomeDescriptionRes != 0) {
setNavigationContentDescription(mHomeDescriptionRes);
}
if (mTabScrollView != null && mIncludeTabs) {
ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
if (lp != null) {
lp.width = LayoutParams.WRAP_CONTENT;
lp.height = LayoutParams.MATCH_PARENT;
}
mTabScrollView.setAllowCollapse(true);
}
|
public void | onDetachedFromWindow()
super.onDetachedFromWindow();
removeCallbacks(mTabSelector);
if (mActionMenuPresenter != null) {
mActionMenuPresenter.hideOverflowMenu();
mActionMenuPresenter.hideSubMenus();
}
|
protected void | onFinishInflate()
super.onFinishInflate();
mUpGoerFive.addView(mHomeLayout, 0);
addView(mUpGoerFive);
if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
final ViewParent parent = mCustomNavView.getParent();
if (parent != this) {
if (parent instanceof ViewGroup) {
((ViewGroup) parent).removeView(mCustomNavView);
}
addView(mCustomNavView);
}
}
|
protected void | onLayout(boolean changed, int l, int t, int r, int b)
final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();
if (contentHeight <= 0) {
// Nothing to do if we can't see anything.
return;
}
final boolean isLayoutRtl = isLayoutRtl();
final int direction = isLayoutRtl ? 1 : -1;
int menuStart = isLayoutRtl ? getPaddingLeft() : r - l - getPaddingRight();
// In LTR mode, we start from left padding and go to the right; in RTL mode, we start
// from the padding right and go to the left (in reverse way)
int x = isLayoutRtl ? r - l - getPaddingRight() : getPaddingLeft();
final int y = getPaddingTop();
HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
(mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
int startOffset = 0;
if (homeLayout.getParent() == mUpGoerFive) {
if (homeLayout.getVisibility() != GONE) {
startOffset = homeLayout.getStartOffset();
} else if (showTitle) {
startOffset = homeLayout.getUpWidth();
}
}
// Position the up container based on where the edge of the home layout should go.
x += positionChild(mUpGoerFive,
next(x, startOffset, isLayoutRtl), y, contentHeight, isLayoutRtl);
x = next(x, startOffset, isLayoutRtl);
if (mExpandedActionView == null) {
switch (mNavigationMode) {
case ActionBar.NAVIGATION_MODE_STANDARD:
break;
case ActionBar.NAVIGATION_MODE_LIST:
if (mListNavLayout != null) {
if (showTitle) {
x = next(x, mItemPadding, isLayoutRtl);
}
x += positionChild(mListNavLayout, x, y, contentHeight, isLayoutRtl);
x = next(x, mItemPadding, isLayoutRtl);
}
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null) {
if (showTitle) x = next(x, mItemPadding, isLayoutRtl);
x += positionChild(mTabScrollView, x, y, contentHeight, isLayoutRtl);
x = next(x, mItemPadding, isLayoutRtl);
}
break;
}
}
if (mMenuView != null && mMenuView.getParent() == this) {
positionChild(mMenuView, menuStart, y, contentHeight, !isLayoutRtl);
menuStart += direction * mMenuView.getMeasuredWidth();
}
if (mIndeterminateProgressView != null &&
mIndeterminateProgressView.getVisibility() != GONE) {
positionChild(mIndeterminateProgressView, menuStart, y, contentHeight, !isLayoutRtl);
menuStart += direction * mIndeterminateProgressView.getMeasuredWidth();
}
View customView = null;
if (mExpandedActionView != null) {
customView = mExpandedActionView;
} else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 &&
mCustomNavView != null) {
customView = mCustomNavView;
}
if (customView != null) {
final int layoutDirection = getLayoutDirection();
ViewGroup.LayoutParams lp = customView.getLayoutParams();
final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
(ActionBar.LayoutParams) lp : null;
final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY;
final int navWidth = customView.getMeasuredWidth();
int topMargin = 0;
int bottomMargin = 0;
if (ablp != null) {
x = next(x, ablp.getMarginStart(), isLayoutRtl);
menuStart += direction * ablp.getMarginEnd();
topMargin = ablp.topMargin;
bottomMargin = ablp.bottomMargin;
}
int hgravity = gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK;
// See if we actually have room to truly center; if not push against left or right.
if (hgravity == Gravity.CENTER_HORIZONTAL) {
final int centeredLeft = ((mRight - mLeft) - navWidth) / 2;
if (isLayoutRtl) {
final int centeredStart = centeredLeft + navWidth;
final int centeredEnd = centeredLeft;
if (centeredStart > x) {
hgravity = Gravity.RIGHT;
} else if (centeredEnd < menuStart) {
hgravity = Gravity.LEFT;
}
} else {
final int centeredStart = centeredLeft;
final int centeredEnd = centeredLeft + navWidth;
if (centeredStart < x) {
hgravity = Gravity.LEFT;
} else if (centeredEnd > menuStart) {
hgravity = Gravity.RIGHT;
}
}
} else if (gravity == Gravity.NO_GRAVITY) {
hgravity = Gravity.START;
}
int xpos = 0;
switch (Gravity.getAbsoluteGravity(hgravity, layoutDirection)) {
case Gravity.CENTER_HORIZONTAL:
xpos = ((mRight - mLeft) - navWidth) / 2;
break;
case Gravity.LEFT:
xpos = isLayoutRtl ? menuStart : x;
break;
case Gravity.RIGHT:
xpos = isLayoutRtl ? x - navWidth : menuStart - navWidth;
break;
}
int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
if (gravity == Gravity.NO_GRAVITY) {
vgravity = Gravity.CENTER_VERTICAL;
}
int ypos = 0;
switch (vgravity) {
case Gravity.CENTER_VERTICAL:
final int paddedTop = getPaddingTop();
final int paddedBottom = mBottom - mTop - getPaddingBottom();
ypos = ((paddedBottom - paddedTop) - customView.getMeasuredHeight()) / 2;
break;
case Gravity.TOP:
ypos = getPaddingTop() + topMargin;
break;
case Gravity.BOTTOM:
ypos = getHeight() - getPaddingBottom() - customView.getMeasuredHeight()
- bottomMargin;
break;
}
final int customWidth = customView.getMeasuredWidth();
customView.layout(xpos, ypos, xpos + customWidth,
ypos + customView.getMeasuredHeight());
x = next(x, customWidth, isLayoutRtl);
}
if (mProgressView != null) {
mProgressView.bringToFront();
final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2;
mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight);
}
|
protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec)
final int childCount = getChildCount();
if (mIsCollapsible) {
int visibleChildren = 0;
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() != GONE &&
!(child == mMenuView && mMenuView.getChildCount() == 0) &&
child != mUpGoerFive) {
visibleChildren++;
}
}
final int upChildCount = mUpGoerFive.getChildCount();
for (int i = 0; i < upChildCount; i++) {
final View child = mUpGoerFive.getChildAt(i);
if (child.getVisibility() != GONE) {
visibleChildren++;
}
}
if (visibleChildren == 0) {
// No size for an empty action bar when collapsable.
setMeasuredDimension(0, 0);
return;
}
}
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
if (widthMode != MeasureSpec.EXACTLY) {
throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
"with android:layout_width=\"match_parent\" (or fill_parent)");
}
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (heightMode != MeasureSpec.AT_MOST) {
throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
"with android:layout_height=\"wrap_content\"");
}
int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
int maxHeight = mContentHeight >= 0 ?
mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
final int verticalPadding = getPaddingTop() + getPaddingBottom();
final int paddingLeft = getPaddingLeft();
final int paddingRight = getPaddingRight();
final int height = maxHeight - verticalPadding;
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
final int exactHeightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
int availableWidth = contentWidth - paddingLeft - paddingRight;
int leftOfCenter = availableWidth / 2;
int rightOfCenter = leftOfCenter;
final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
(mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
final ViewGroup.LayoutParams homeLp = homeLayout.getLayoutParams();
int homeWidthSpec;
if (homeLp.width < 0) {
homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
} else {
homeWidthSpec = MeasureSpec.makeMeasureSpec(homeLp.width, MeasureSpec.EXACTLY);
}
/*
* This is a little weird.
* We're only measuring the *home* affordance within the Up container here
* on purpose, because we want to give the available space to all other views before
* the title text. We'll remeasure the whole up container again later.
* We need to measure this container so we know the right offset for the up affordance
* no matter what.
*/
homeLayout.measure(homeWidthSpec, exactHeightSpec);
int homeWidth = 0;
if ((homeLayout.getVisibility() != GONE && homeLayout.getParent() == mUpGoerFive)
|| showTitle) {
homeWidth = homeLayout.getMeasuredWidth();
final int homeOffsetWidth = homeWidth + homeLayout.getStartOffset();
availableWidth = Math.max(0, availableWidth - homeOffsetWidth);
leftOfCenter = Math.max(0, availableWidth - homeOffsetWidth);
}
if (mMenuView != null && mMenuView.getParent() == this) {
availableWidth = measureChildView(mMenuView, availableWidth, exactHeightSpec, 0);
rightOfCenter = Math.max(0, rightOfCenter - mMenuView.getMeasuredWidth());
}
if (mIndeterminateProgressView != null &&
mIndeterminateProgressView.getVisibility() != GONE) {
availableWidth = measureChildView(mIndeterminateProgressView, availableWidth,
childSpecHeight, 0);
rightOfCenter = Math.max(0,
rightOfCenter - mIndeterminateProgressView.getMeasuredWidth());
}
if (mExpandedActionView == null) {
switch (mNavigationMode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mListNavLayout != null) {
final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
availableWidth = Math.max(0, availableWidth - itemPaddingSize);
leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize);
mListNavLayout.measure(
MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
final int listNavWidth = mListNavLayout.getMeasuredWidth();
availableWidth = Math.max(0, availableWidth - listNavWidth);
leftOfCenter = Math.max(0, leftOfCenter - listNavWidth);
}
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null) {
final int itemPaddingSize = showTitle ? mItemPadding * 2 : mItemPadding;
availableWidth = Math.max(0, availableWidth - itemPaddingSize);
leftOfCenter = Math.max(0, leftOfCenter - itemPaddingSize);
mTabScrollView.measure(
MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
final int tabWidth = mTabScrollView.getMeasuredWidth();
availableWidth = Math.max(0, availableWidth - tabWidth);
leftOfCenter = Math.max(0, leftOfCenter - tabWidth);
}
break;
}
}
View customView = null;
if (mExpandedActionView != null) {
customView = mExpandedActionView;
} else if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 &&
mCustomNavView != null) {
customView = mCustomNavView;
}
if (customView != null) {
final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams());
final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
(ActionBar.LayoutParams) lp : null;
int horizontalMargin = 0;
int verticalMargin = 0;
if (ablp != null) {
horizontalMargin = ablp.leftMargin + ablp.rightMargin;
verticalMargin = ablp.topMargin + ablp.bottomMargin;
}
// If the action bar is wrapping to its content height, don't allow a custom
// view to MATCH_PARENT.
int customNavHeightMode;
if (mContentHeight <= 0) {
customNavHeightMode = MeasureSpec.AT_MOST;
} else {
customNavHeightMode = lp.height != LayoutParams.WRAP_CONTENT ?
MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
}
final int customNavHeight = Math.max(0,
(lp.height >= 0 ? Math.min(lp.height, height) : height) - verticalMargin);
final int customNavWidthMode = lp.width != LayoutParams.WRAP_CONTENT ?
MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
int customNavWidth = Math.max(0,
(lp.width >= 0 ? Math.min(lp.width, availableWidth) : availableWidth)
- horizontalMargin);
final int hgrav = (ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY) &
Gravity.HORIZONTAL_GRAVITY_MASK;
// Centering a custom view is treated specially; we try to center within the whole
// action bar rather than in the available space.
if (hgrav == Gravity.CENTER_HORIZONTAL && lp.width == LayoutParams.MATCH_PARENT) {
customNavWidth = Math.min(leftOfCenter, rightOfCenter) * 2;
}
customView.measure(
MeasureSpec.makeMeasureSpec(customNavWidth, customNavWidthMode),
MeasureSpec.makeMeasureSpec(customNavHeight, customNavHeightMode));
availableWidth -= horizontalMargin + customView.getMeasuredWidth();
}
/*
* Measure the whole up container now, allowing for the full home+title sections.
* (This will re-measure the home view.)
*/
availableWidth = measureChildView(mUpGoerFive, availableWidth + homeWidth,
MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0);
if (mTitleLayout != null) {
leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth());
}
if (mContentHeight <= 0) {
int measuredHeight = 0;
for (int i = 0; i < childCount; i++) {
View v = getChildAt(i);
int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
if (paddedViewHeight > measuredHeight) {
measuredHeight = paddedViewHeight;
}
}
setMeasuredDimension(contentWidth, measuredHeight);
} else {
setMeasuredDimension(contentWidth, maxHeight);
}
if (mContextView != null) {
mContextView.setContentHeight(getMeasuredHeight());
}
if (mProgressView != null && mProgressView.getVisibility() != GONE) {
mProgressView.measure(MeasureSpec.makeMeasureSpec(
contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST));
}
|
public void | onRestoreInstanceState(android.os.Parcelable p)
SavedState state = (SavedState) p;
super.onRestoreInstanceState(state.getSuperState());
if (state.expandedMenuItemId != 0 &&
mExpandedMenuPresenter != null && mOptionsMenu != null) {
final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId);
if (item != null) {
item.expandActionView();
}
}
if (state.isOverflowOpen) {
postShowOverflowMenu();
}
|
public android.os.Parcelable | onSaveInstanceState()
Parcelable superState = super.onSaveInstanceState();
SavedState state = new SavedState(superState);
if (mExpandedMenuPresenter != null && mExpandedMenuPresenter.mCurrentExpandedItem != null) {
state.expandedMenuItemId = mExpandedMenuPresenter.mCurrentExpandedItem.getItemId();
}
state.isOverflowOpen = isOverflowMenuShowing();
return state;
|
public void | setCollapsible(boolean collapsible)
mIsCollapsible = collapsible;
|
public void | setContextView(ActionBarContextView view)
mContextView = view;
|
public void | setCustomView(android.view.View view)
final boolean showCustom = (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0;
if (showCustom) {
ActionBarTransition.beginDelayedTransition(this);
}
if (mCustomNavView != null && showCustom) {
removeView(mCustomNavView);
}
mCustomNavView = view;
if (mCustomNavView != null && showCustom) {
addView(mCustomNavView);
}
|
public void | setDefaultNavigationContentDescription(int defaultNavigationContentDescription)
if (mDefaultUpDescription == defaultNavigationContentDescription) {
return;
}
mDefaultUpDescription = defaultNavigationContentDescription;
updateHomeAccessibility(mUpGoerFive.isEnabled());
|
public void | setDefaultNavigationIcon(android.graphics.drawable.Drawable icon)
mHomeLayout.setDefaultUpIndicator(icon);
|
public void | setDisplayOptions(int options)
final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
mDisplayOptions = options;
if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
ActionBarTransition.beginDelayedTransition(this);
if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
final boolean setUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
mHomeLayout.setShowUp(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 {
mUpGoerFive.removeView(mTitleLayout);
}
}
final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
final boolean titleUp = !showHome && homeAsUp;
mHomeLayout.setShowIcon(showHome);
final int homeVis = (showHome || titleUp) && mExpandedActionView == null ?
VISIBLE : GONE;
mHomeLayout.setVisibility(homeVis);
if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
addView(mCustomNavView);
} else {
removeView(mCustomNavView);
}
}
if (mTitleLayout != null &&
(flagsChanged & ActionBar.DISPLAY_TITLE_MULTIPLE_LINES) != 0) {
if ((options & ActionBar.DISPLAY_TITLE_MULTIPLE_LINES) != 0) {
mTitleView.setSingleLine(false);
mTitleView.setMaxLines(2);
} else {
mTitleView.setMaxLines(1);
mTitleView.setSingleLine(true);
}
}
requestLayout();
} else {
invalidate();
}
// Make sure the home button has an accurate content description for accessibility.
updateHomeAccessibility(mUpGoerFive.isEnabled());
|
public void | setDropdownParams(android.widget.SpinnerAdapter adapter, AdapterView.OnItemSelectedListener l)
mSpinnerAdapter = adapter;
mNavItemSelectedListener = l;
if (mSpinner != null) {
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(l);
}
|
public void | setDropdownSelectedPosition(int position)
mSpinner.setSelection(position);
|
public void | setEmbeddedTabView(ScrollingTabContainerView tabs)
if (mTabScrollView != null) {
removeView(mTabScrollView);
}
mTabScrollView = tabs;
mIncludeTabs = tabs != null;
if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
addView(mTabScrollView);
ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
lp.width = LayoutParams.WRAP_CONTENT;
lp.height = LayoutParams.MATCH_PARENT;
tabs.setAllowCollapse(true);
}
|
public void | setHomeButtonEnabled(boolean enable)
setHomeButtonEnabled(enable, true);
|
private void | setHomeButtonEnabled(boolean enable, boolean recordState)
if (recordState) {
mWasHomeEnabled = enable;
}
if (mExpandedActionView != null) {
// There's an action view currently showing and we want to keep the state
// configured for the action view at the moment. If we needed to record the
// new state for later we will have done so above.
return;
}
mUpGoerFive.setEnabled(enable);
mUpGoerFive.setFocusable(enable);
// Make sure the home button has an accurate content description for accessibility.
updateHomeAccessibility(enable);
|
public void | setIcon(android.graphics.drawable.Drawable icon)
mIcon = icon;
if (icon != null &&
((mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) == 0 || mLogo == null)) {
mHomeLayout.setIcon(icon);
}
if (mExpandedActionView != null) {
mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(getResources()));
}
|
public void | setIcon(int resId)
setIcon(resId != 0 ? mContext.getDrawable(resId) : null);
|
public void | setLogo(android.graphics.drawable.Drawable logo)
mLogo = logo;
if (logo != null && (mDisplayOptions & ActionBar.DISPLAY_USE_LOGO) != 0) {
mHomeLayout.setIcon(logo);
}
|
public void | setLogo(int resId)
setLogo(resId != 0 ? mContext.getDrawable(resId) : null);
|
public void | setMenu(android.view.Menu menu, MenuPresenter.Callback cb)
if (menu == mOptionsMenu) return;
if (mOptionsMenu != null) {
mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
}
MenuBuilder builder = (MenuBuilder) menu;
mOptionsMenu = builder;
if (mMenuView != null) {
final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
if (oldParent != null) {
oldParent.removeView(mMenuView);
}
}
if (mActionMenuPresenter == null) {
mActionMenuPresenter = new ActionMenuPresenter(mContext);
mActionMenuPresenter.setCallback(cb);
mActionMenuPresenter.setId(com.android.internal.R.id.action_menu_presenter);
mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
}
ActionMenuView menuView;
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT);
if (!mSplitActionBar) {
mActionMenuPresenter.setExpandedActionViewsExclusive(
getResources().getBoolean(
com.android.internal.R.bool.action_bar_expanded_action_views_exclusive));
configPresenters(builder);
menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
final ViewGroup oldParent = (ViewGroup) menuView.getParent();
if (oldParent != null && oldParent != this) {
oldParent.removeView(menuView);
}
addView(menuView, layoutParams);
} else {
mActionMenuPresenter.setExpandedActionViewsExclusive(false);
// Allow full screen width in split mode.
mActionMenuPresenter.setWidthLimit(
getContext().getResources().getDisplayMetrics().widthPixels, true);
// No limit to the item count; use whatever will fit.
mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
// Span the whole width
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
configPresenters(builder);
menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
if (mSplitView != null) {
final ViewGroup oldParent = (ViewGroup) menuView.getParent();
if (oldParent != null && oldParent != mSplitView) {
oldParent.removeView(menuView);
}
menuView.setVisibility(getAnimatedVisibility());
mSplitView.addView(menuView, layoutParams);
} else {
// We'll add this later if we missed it this time.
menuView.setLayoutParams(layoutParams);
}
}
mMenuView = menuView;
|
public void | setMenuCallbacks(MenuPresenter.Callback presenterCallback, MenuBuilder.Callback menuBuilderCallback)
if (mActionMenuPresenter != null) {
mActionMenuPresenter.setCallback(presenterCallback);
}
if (mOptionsMenu != null) {
mOptionsMenu.setCallback(menuBuilderCallback);
}
|
public void | setMenuPrepared()
mMenuPrepared = true;
|
public void | setNavigationContentDescription(java.lang.CharSequence description)
mHomeDescription = description;
updateHomeAccessibility(mUpGoerFive.isEnabled());
|
public void | setNavigationContentDescription(int resId)
mHomeDescriptionRes = resId;
mHomeDescription = resId != 0 ? getResources().getText(resId) : null;
updateHomeAccessibility(mUpGoerFive.isEnabled());
|
public void | setNavigationIcon(android.graphics.drawable.Drawable indicator)
mHomeLayout.setUpIndicator(indicator);
|
public void | setNavigationIcon(int resId)
mHomeLayout.setUpIndicator(resId);
|
public void | setNavigationMode(int mode)
final int oldMode = mNavigationMode;
if (mode != oldMode) {
ActionBarTransition.beginDelayedTransition(this);
switch (oldMode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mListNavLayout != null) {
removeView(mListNavLayout);
}
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null && mIncludeTabs) {
removeView(mTabScrollView);
}
}
switch (mode) {
case ActionBar.NAVIGATION_MODE_LIST:
if (mSpinner == null) {
mSpinner = new Spinner(mContext, null,
com.android.internal.R.attr.actionDropDownStyle);
mSpinner.setId(com.android.internal.R.id.action_bar_spinner);
mListNavLayout = new LinearLayout(mContext, null,
com.android.internal.R.attr.actionBarTabBarStyle);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
params.gravity = Gravity.CENTER;
mListNavLayout.addView(mSpinner, params);
}
if (mSpinner.getAdapter() != mSpinnerAdapter) {
mSpinner.setAdapter(mSpinnerAdapter);
}
mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);
addView(mListNavLayout);
break;
case ActionBar.NAVIGATION_MODE_TABS:
if (mTabScrollView != null && mIncludeTabs) {
addView(mTabScrollView);
}
break;
}
mNavigationMode = mode;
requestLayout();
}
|
public void | setSplitToolbar(boolean splitActionBar)
if (mSplitActionBar != splitActionBar) {
if (mMenuView != null) {
final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
if (oldParent != null) {
oldParent.removeView(mMenuView);
}
if (splitActionBar) {
if (mSplitView != null) {
mSplitView.addView(mMenuView);
}
mMenuView.getLayoutParams().width = LayoutParams.MATCH_PARENT;
} else {
addView(mMenuView);
mMenuView.getLayoutParams().width = LayoutParams.WRAP_CONTENT;
}
mMenuView.requestLayout();
}
if (mSplitView != null) {
mSplitView.setVisibility(splitActionBar ? VISIBLE : GONE);
}
if (mActionMenuPresenter != null) {
if (!splitActionBar) {
mActionMenuPresenter.setExpandedActionViewsExclusive(
getResources().getBoolean(
com.android.internal.R.bool.action_bar_expanded_action_views_exclusive));
} else {
mActionMenuPresenter.setExpandedActionViewsExclusive(false);
// Allow full screen width in split mode.
mActionMenuPresenter.setWidthLimit(
getContext().getResources().getDisplayMetrics().widthPixels, true);
// No limit to the item count; use whatever will fit.
mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
}
}
super.setSplitToolbar(splitActionBar);
}
|
public void | setSubtitle(java.lang.CharSequence subtitle)
ActionBarTransition.beginDelayedTransition(this);
mSubtitle = subtitle;
if (mSubtitleView != null) {
mSubtitleView.setText(subtitle);
mSubtitleView.setVisibility(subtitle != null ? VISIBLE : GONE);
final boolean visible = mExpandedActionView == null &&
(mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 &&
(!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle));
mTitleLayout.setVisibility(visible ? VISIBLE : GONE);
}
updateHomeAccessibility(mUpGoerFive.isEnabled());
|
public void | setTitle(java.lang.CharSequence title)Set the action bar title. This will always replace or override window titles.
mUserTitle = true;
setTitleImpl(title);
|
private void | setTitleImpl(java.lang.CharSequence title)
ActionBarTransition.beginDelayedTransition(this);
mTitle = title;
if (mTitleView != null) {
mTitleView.setText(title);
final boolean visible = mExpandedActionView == null &&
(mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0 &&
(!TextUtils.isEmpty(mTitle) || !TextUtils.isEmpty(mSubtitle));
mTitleLayout.setVisibility(visible ? VISIBLE : GONE);
}
if (mLogoNavItem != null) {
mLogoNavItem.setTitle(title);
}
updateHomeAccessibility(mUpGoerFive.isEnabled());
|
public void | setWindowCallback(Window.Callback cb)Set the window callback used to invoke menu items; used for dispatching home button presses.
mWindowCallback = cb;
|
public void | setWindowTitle(java.lang.CharSequence title)Set the window title. A window title will always be replaced or overridden by a user title.
if (!mUserTitle) {
setTitleImpl(title);
}
|
public boolean | shouldDelayChildPressedState()
return false;
|
private void | updateHomeAccessibility(boolean homeEnabled)
if (!homeEnabled) {
mUpGoerFive.setContentDescription(null);
mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
} else {
mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO);
mUpGoerFive.setContentDescription(buildHomeContentDescription());
}
|