Methods Summary |
---|
public void | closeMode()
if (mAnimationMode == ANIMATE_OUT) {
// Called again during close; just finish what we were doing.
return;
}
if (mClose == null) {
killMode();
return;
}
finishAnimation();
mAnimationMode = ANIMATE_OUT;
mCurrentAnimation = makeOutAnimation();
mCurrentAnimation.start();
|
private void | finishAnimation()
final ViewPropertyAnimatorCompatSet a = mCurrentAnimation;
if (a != null) {
mCurrentAnimation = null;
a.cancel();
}
|
protected ViewGroup.LayoutParams | generateDefaultLayoutParams()
// Used by custom views if they don't supply layout params. Everything else
// added to an ActionBarContextView should have them already.
return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
public ViewGroup.LayoutParams | generateLayoutParams(android.util.AttributeSet attrs)
return new MarginLayoutParams(getContext(), attrs);
|
public java.lang.CharSequence | getSubtitle()
return mSubtitle;
|
public java.lang.CharSequence | getTitle()
return mTitle;
|
public boolean | hideOverflowMenu()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.hideOverflowMenu();
}
return false;
|
public void | initForMode(android.support.v7.view.ActionMode mode)
if (mClose == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
mClose = inflater.inflate(mCloseItemLayout, this, false);
addView(mClose);
} else if (mClose.getParent() == null) {
addView(mClose);
}
View closeButton = mClose.findViewById(R.id.action_mode_close_button);
closeButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mode.finish();
}
});
final MenuBuilder menu = (MenuBuilder) mode.getMenu();
if (mActionMenuPresenter != null) {
mActionMenuPresenter.dismissPopupMenus();
}
mActionMenuPresenter = new ActionMenuPresenter(getContext());
mActionMenuPresenter.setReserveOverflow(true);
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT);
if (!mSplitActionBar) {
menu.addMenuPresenter(mActionMenuPresenter, mPopupContext);
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(null);
addView(mMenuView, layoutParams);
} else {
// 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 = mContentHeight;
menu.addMenuPresenter(mActionMenuPresenter, mPopupContext);
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(mSplitBackground);
mSplitView.addView(mMenuView, layoutParams);
}
mAnimateInOnLayout = true;
|
private void | initTitle()
if (mTitleLayout == null) {
LayoutInflater inflater = LayoutInflater.from(getContext());
inflater.inflate(R.layout.abc_action_bar_title_item, this);
mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
if (mTitleStyleRes != 0) {
mTitleView.setTextAppearance(getContext(), mTitleStyleRes);
}
if (mSubtitleStyleRes != 0) {
mSubtitleView.setTextAppearance(getContext(), mSubtitleStyleRes);
}
}
mTitleView.setText(mTitle);
mSubtitleView.setText(mSubtitle);
final boolean hasTitle = !TextUtils.isEmpty(mTitle);
final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle);
mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE);
mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE);
if (mTitleLayout.getParent() == null) {
addView(mTitleLayout);
}
|
public boolean | isOverflowMenuShowing()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.isOverflowMenuShowing();
}
return false;
|
public boolean | isTitleOptional()
return mTitleOptional;
|
public void | killMode()
finishAnimation();
removeAllViews();
if (mSplitView != null) {
mSplitView.removeView(mMenuView);
}
mCustomView = null;
mMenuView = null;
mAnimateInOnLayout = false;
|
private android.support.v7.internal.view.ViewPropertyAnimatorCompatSet | makeInAnimation()
ViewCompat.setTranslationX(mClose, -mClose.getWidth() -
((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose).translationX(0);
buttonAnimator.setDuration(200);
buttonAnimator.setListener(this);
buttonAnimator.setInterpolator(new DecelerateInterpolator());
ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
set.play(buttonAnimator);
if (mMenuView != null) {
final int count = mMenuView.getChildCount();
if (count > 0) {
for (int i = count - 1, j = 0; i >= 0; i--, j++) {
View child = mMenuView.getChildAt(i);
ViewCompat.setScaleY(child, 0);
ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(1);
a.setDuration(300);
set.play(a);
}
}
}
return set;
|
private android.support.v7.internal.view.ViewPropertyAnimatorCompatSet | makeOutAnimation()
ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose)
.translationX(-mClose.getWidth() -
((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
buttonAnimator.setDuration(200);
buttonAnimator.setListener(this);
buttonAnimator.setInterpolator(new DecelerateInterpolator());
ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
set.play(buttonAnimator);
if (mMenuView != null) {
final int count = mMenuView.getChildCount();
if (count > 0) {
for (int i = 0; i < 0; i++) {
View child = mMenuView.getChildAt(i);
ViewCompat.setScaleY(child, 1);
ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(0);
a.setDuration(300);
set.play(a);
}
}
}
return set;
|
public void | onAnimationCancel(android.view.View view)
|
public void | onAnimationEnd(android.view.View view)
if (mAnimationMode == ANIMATE_OUT) {
killMode();
}
mAnimationMode = ANIMATE_IDLE;
|
public void | onAnimationStart(android.view.View view)
|
public void | onDetachedFromWindow()
super.onDetachedFromWindow();
if (mActionMenuPresenter != null) {
mActionMenuPresenter.hideOverflowMenu();
mActionMenuPresenter.hideSubMenus();
}
|
public void | onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)
if (Build.VERSION.SDK_INT >= 14) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
// Action mode started
event.setSource(this);
event.setClassName(getClass().getName());
event.setPackageName(getContext().getPackageName());
event.setContentDescription(mTitle);
} else {
super.onInitializeAccessibilityEvent(event);
}
}
|
protected void | onLayout(boolean changed, int l, int t, int r, int b)
final boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
int x = isLayoutRtl ? r - l - getPaddingRight() : getPaddingLeft();
final int y = getPaddingTop();
final int contentHeight = b - t - getPaddingTop() - getPaddingBottom();
if (mClose != null && mClose.getVisibility() != GONE) {
MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams();
final int startMargin = (isLayoutRtl ? lp.rightMargin : lp.leftMargin);
final int endMargin = (isLayoutRtl ? lp.leftMargin : lp.rightMargin);
x = next(x, startMargin, isLayoutRtl);
x += positionChild(mClose, x, y, contentHeight, isLayoutRtl);
x = next(x, endMargin, isLayoutRtl);
if (mAnimateInOnLayout) {
mAnimationMode = ANIMATE_IN;
mCurrentAnimation = makeInAnimation();
mCurrentAnimation.start();
mAnimateInOnLayout = false;
}
}
if (mTitleLayout != null && mCustomView == null && mTitleLayout.getVisibility() != GONE) {
x += positionChild(mTitleLayout, x, y, contentHeight, isLayoutRtl);
}
if (mCustomView != null) {
x += positionChild(mCustomView, x, y, contentHeight, isLayoutRtl);
}
x = isLayoutRtl ? getPaddingLeft() : r - l - getPaddingRight();
if (mMenuView != null) {
x += positionChild(mMenuView, x, y, contentHeight, !isLayoutRtl);
}
|
protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec)
final 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)");
}
final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
if (heightMode == MeasureSpec.UNSPECIFIED) {
throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
"with android:layout_height=\"wrap_content\"");
}
final int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
int maxHeight = mContentHeight > 0 ?
mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
final int verticalPadding = getPaddingTop() + getPaddingBottom();
int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight();
final int height = maxHeight - verticalPadding;
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
if (mClose != null) {
availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0);
MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams();
availableWidth -= lp.leftMargin + lp.rightMargin;
}
if (mMenuView != null && mMenuView.getParent() == this) {
availableWidth = measureChildView(mMenuView, availableWidth,
childSpecHeight, 0);
}
if (mTitleLayout != null && mCustomView == null) {
if (mTitleOptional) {
final int titleWidthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
mTitleLayout.measure(titleWidthSpec, childSpecHeight);
final int titleWidth = mTitleLayout.getMeasuredWidth();
final boolean titleFits = titleWidth <= availableWidth;
if (titleFits) {
availableWidth -= titleWidth;
}
mTitleLayout.setVisibility(titleFits ? VISIBLE : GONE);
} else {
availableWidth = measureChildView(mTitleLayout, availableWidth, childSpecHeight, 0);
}
}
if (mCustomView != null) {
ViewGroup.LayoutParams lp = mCustomView.getLayoutParams();
final int customWidthMode = lp.width != LayoutParams.WRAP_CONTENT ?
MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
final int customWidth = lp.width >= 0 ?
Math.min(lp.width, availableWidth) : availableWidth;
final int customHeightMode = lp.height != LayoutParams.WRAP_CONTENT ?
MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
final int customHeight = lp.height >= 0 ?
Math.min(lp.height, height) : height;
mCustomView.measure(MeasureSpec.makeMeasureSpec(customWidth, customWidthMode),
MeasureSpec.makeMeasureSpec(customHeight, customHeightMode));
}
if (mContentHeight <= 0) {
int measuredHeight = 0;
final int count = getChildCount();
for (int i = 0; i < count; i++) {
View v = getChildAt(i);
int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
if (paddedViewHeight > measuredHeight) {
measuredHeight = paddedViewHeight;
}
}
setMeasuredDimension(contentWidth, measuredHeight);
} else {
setMeasuredDimension(contentWidth, maxHeight);
}
|
public void | setContentHeight(int height)
mContentHeight = height;
|
public void | setCustomView(android.view.View view)
if (mCustomView != null) {
removeView(mCustomView);
}
mCustomView = view;
if (mTitleLayout != null) {
removeView(mTitleLayout);
mTitleLayout = null;
}
if (view != null) {
addView(view);
}
requestLayout();
|
public void | setSplitToolbar(boolean split)
if (mSplitActionBar != split) {
if (mActionMenuPresenter != null) {
// Mode is already active; move everything over and adjust the menu itself.
final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT);
if (!split) {
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(null);
final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
if (oldParent != null) oldParent.removeView(mMenuView);
addView(mMenuView, layoutParams);
} else {
// 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 = mContentHeight;
mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
mMenuView.setBackgroundDrawable(mSplitBackground);
final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
if (oldParent != null) oldParent.removeView(mMenuView);
mSplitView.addView(mMenuView, layoutParams);
}
}
super.setSplitToolbar(split);
}
|
public void | setSubtitle(java.lang.CharSequence subtitle)
mSubtitle = subtitle;
initTitle();
|
public void | setTitle(java.lang.CharSequence title)
mTitle = title;
initTitle();
|
public void | setTitleOptional(boolean titleOptional)
if (titleOptional != mTitleOptional) {
requestLayout();
}
mTitleOptional = titleOptional;
|
public boolean | shouldDelayChildPressedState()
return false;
|
public boolean | showOverflowMenu()
if (mActionMenuPresenter != null) {
return mActionMenuPresenter.showOverflowMenu();
}
return false;
|