1836 lines
76 KiB
Java
1836 lines
76 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.text.Layout;
|
|
import android.text.TextUtils;
|
|
import android.util.AttributeSet;
|
|
import android.view.ContextThemeWrapper;
|
|
import android.view.Menu;
|
|
import android.view.MenuInflater;
|
|
import android.view.MenuItem;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewParent;
|
|
import android.widget.ImageButton;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.ColorInt;
|
|
import androidx.annotation.DrawableRes;
|
|
import androidx.annotation.MenuRes;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.annotation.StyleRes;
|
|
import androidx.appcompat.R;
|
|
import androidx.appcompat.app.ActionBar;
|
|
import androidx.appcompat.content.res.AppCompatResources;
|
|
import androidx.appcompat.view.CollapsibleActionView;
|
|
import androidx.appcompat.view.SupportMenuInflater;
|
|
import androidx.appcompat.view.menu.MenuBuilder;
|
|
import androidx.appcompat.view.menu.MenuItemImpl;
|
|
import androidx.appcompat.view.menu.MenuPresenter;
|
|
import androidx.appcompat.view.menu.MenuView;
|
|
import androidx.appcompat.view.menu.SubMenuBuilder;
|
|
import androidx.appcompat.widget.ActionMenuView;
|
|
import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure;
|
|
import androidx.core.view.GravityCompat;
|
|
import androidx.core.view.MarginLayoutParamsCompat;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.customview.view.AbsSavedState;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
public class Toolbar extends ViewGroup {
|
|
private static final String TAG = "Toolbar";
|
|
private MenuPresenter.Callback mActionMenuPresenterCallback;
|
|
public int mButtonGravity;
|
|
public ImageButton mCollapseButtonView;
|
|
private CharSequence mCollapseDescription;
|
|
private Drawable mCollapseIcon;
|
|
private boolean mCollapsible;
|
|
private int mContentInsetEndWithActions;
|
|
private int mContentInsetStartWithNavigation;
|
|
private RtlSpacingHelper mContentInsets;
|
|
private boolean mEatingHover;
|
|
private boolean mEatingTouch;
|
|
public View mExpandedActionView;
|
|
private ExpandedActionViewMenuPresenter mExpandedMenuPresenter;
|
|
private int mGravity;
|
|
private final ArrayList<View> mHiddenViews;
|
|
private ImageView mLogoView;
|
|
private int mMaxButtonHeight;
|
|
private MenuBuilder.Callback mMenuBuilderCallback;
|
|
private ActionMenuView mMenuView;
|
|
private final ActionMenuView.OnMenuItemClickListener mMenuViewItemClickListener;
|
|
private ImageButton mNavButtonView;
|
|
public OnMenuItemClickListener mOnMenuItemClickListener;
|
|
private ActionMenuPresenter mOuterActionMenuPresenter;
|
|
private Context mPopupContext;
|
|
private int mPopupTheme;
|
|
private final Runnable mShowOverflowMenuRunnable;
|
|
private CharSequence mSubtitleText;
|
|
private int mSubtitleTextAppearance;
|
|
private ColorStateList mSubtitleTextColor;
|
|
private TextView mSubtitleTextView;
|
|
private final int[] mTempMargins;
|
|
private final ArrayList<View> mTempViews;
|
|
private int mTitleMarginBottom;
|
|
private int mTitleMarginEnd;
|
|
private int mTitleMarginStart;
|
|
private int mTitleMarginTop;
|
|
private CharSequence mTitleText;
|
|
private int mTitleTextAppearance;
|
|
private ColorStateList mTitleTextColor;
|
|
private TextView mTitleTextView;
|
|
private ToolbarWidgetWrapper mWrapper;
|
|
|
|
/* renamed from: androidx.appcompat.widget.Toolbar$1 reason: invalid class name */
|
|
public class AnonymousClass1 implements ActionMenuView.OnMenuItemClickListener {
|
|
public AnonymousClass1() {
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.ActionMenuView.OnMenuItemClickListener
|
|
public boolean onMenuItemClick(MenuItem menuItem) {
|
|
OnMenuItemClickListener onMenuItemClickListener = Toolbar.this.mOnMenuItemClickListener;
|
|
if (onMenuItemClickListener != null) {
|
|
return onMenuItemClickListener.onMenuItemClick(menuItem);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.appcompat.widget.Toolbar$2 reason: invalid class name */
|
|
public class AnonymousClass2 implements Runnable {
|
|
public AnonymousClass2() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
Toolbar.this.showOverflowMenu();
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.appcompat.widget.Toolbar$3 reason: invalid class name */
|
|
public class AnonymousClass3 implements View.OnClickListener {
|
|
public AnonymousClass3() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
Toolbar.this.collapseActionView();
|
|
}
|
|
}
|
|
|
|
public class ExpandedActionViewMenuPresenter implements MenuPresenter {
|
|
public MenuItemImpl mCurrentExpandedItem;
|
|
public MenuBuilder mMenu;
|
|
|
|
public ExpandedActionViewMenuPresenter() {
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean collapseItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
|
View view = Toolbar.this.mExpandedActionView;
|
|
if (view instanceof CollapsibleActionView) {
|
|
((CollapsibleActionView) view).onActionViewCollapsed();
|
|
}
|
|
Toolbar toolbar = Toolbar.this;
|
|
toolbar.removeView(toolbar.mExpandedActionView);
|
|
Toolbar toolbar2 = Toolbar.this;
|
|
toolbar2.removeView(toolbar2.mCollapseButtonView);
|
|
Toolbar toolbar3 = Toolbar.this;
|
|
toolbar3.mExpandedActionView = null;
|
|
toolbar3.addChildrenForExpandedActionView();
|
|
this.mCurrentExpandedItem = null;
|
|
Toolbar.this.requestLayout();
|
|
menuItemImpl.setActionViewExpanded(false);
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean expandItemActionView(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) {
|
|
Toolbar.this.ensureCollapseButtonView();
|
|
ViewParent parent = Toolbar.this.mCollapseButtonView.getParent();
|
|
Toolbar toolbar = Toolbar.this;
|
|
if (parent != toolbar) {
|
|
if (parent instanceof ViewGroup) {
|
|
((ViewGroup) parent).removeView(toolbar.mCollapseButtonView);
|
|
}
|
|
Toolbar toolbar2 = Toolbar.this;
|
|
toolbar2.addView(toolbar2.mCollapseButtonView);
|
|
}
|
|
Toolbar.this.mExpandedActionView = menuItemImpl.getActionView();
|
|
this.mCurrentExpandedItem = menuItemImpl;
|
|
ViewParent parent2 = Toolbar.this.mExpandedActionView.getParent();
|
|
Toolbar toolbar3 = Toolbar.this;
|
|
if (parent2 != toolbar3) {
|
|
if (parent2 instanceof ViewGroup) {
|
|
((ViewGroup) parent2).removeView(toolbar3.mExpandedActionView);
|
|
}
|
|
LayoutParams generateDefaultLayoutParams = Toolbar.this.generateDefaultLayoutParams();
|
|
Toolbar toolbar4 = Toolbar.this;
|
|
generateDefaultLayoutParams.gravity = 8388611 | (toolbar4.mButtonGravity & 112);
|
|
generateDefaultLayoutParams.mViewType = 2;
|
|
toolbar4.mExpandedActionView.setLayoutParams(generateDefaultLayoutParams);
|
|
Toolbar toolbar5 = Toolbar.this;
|
|
toolbar5.addView(toolbar5.mExpandedActionView);
|
|
}
|
|
Toolbar.this.removeChildrenForExpandedActionView();
|
|
Toolbar.this.requestLayout();
|
|
menuItemImpl.setActionViewExpanded(true);
|
|
View view = Toolbar.this.mExpandedActionView;
|
|
if (view instanceof CollapsibleActionView) {
|
|
((CollapsibleActionView) view).onActionViewExpanded();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean flagActionItems() {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public int getId() {
|
|
return 0;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public MenuView getMenuView(ViewGroup viewGroup) {
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void initForMenu(Context context, MenuBuilder menuBuilder) {
|
|
MenuItemImpl menuItemImpl;
|
|
MenuBuilder menuBuilder2 = this.mMenu;
|
|
if (!(menuBuilder2 == null || (menuItemImpl = this.mCurrentExpandedItem) == null)) {
|
|
menuBuilder2.collapseItemActionView(menuItemImpl);
|
|
}
|
|
this.mMenu = menuBuilder;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void onCloseMenu(MenuBuilder menuBuilder, boolean z2) {
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void onRestoreInstanceState(Parcelable parcelable) {
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public Parcelable onSaveInstanceState() {
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public boolean onSubMenuSelected(SubMenuBuilder subMenuBuilder) {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void setCallback(MenuPresenter.Callback callback) {
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.menu.MenuPresenter
|
|
public void updateMenuView(boolean z2) {
|
|
if (this.mCurrentExpandedItem != null) {
|
|
MenuBuilder menuBuilder = this.mMenu;
|
|
boolean z3 = false;
|
|
if (menuBuilder != null) {
|
|
int size = menuBuilder.size();
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= size) {
|
|
break;
|
|
} else if (this.mMenu.getItem(i) == this.mCurrentExpandedItem) {
|
|
z3 = true;
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
if (!z3) {
|
|
collapseItemActionView(this.mMenu, this.mCurrentExpandedItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static class LayoutParams extends ActionBar.LayoutParams {
|
|
public static final int CUSTOM = 0;
|
|
public static final int EXPANDED = 2;
|
|
public static final int SYSTEM = 1;
|
|
public int mViewType;
|
|
|
|
public LayoutParams(int i) {
|
|
this(-2, -1, i);
|
|
}
|
|
|
|
public LayoutParams(int i, int i2) {
|
|
super(i, i2);
|
|
this.mViewType = 0;
|
|
this.gravity = 8388627;
|
|
}
|
|
|
|
public LayoutParams(int i, int i2, int i3) {
|
|
super(i, i2);
|
|
this.mViewType = 0;
|
|
this.gravity = i3;
|
|
}
|
|
|
|
public LayoutParams(@NonNull Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.mViewType = 0;
|
|
}
|
|
|
|
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
super(layoutParams);
|
|
this.mViewType = 0;
|
|
}
|
|
|
|
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
|
super(marginLayoutParams);
|
|
this.mViewType = 0;
|
|
copyMarginsFromCompat(marginLayoutParams);
|
|
}
|
|
|
|
public LayoutParams(ActionBar.LayoutParams layoutParams) {
|
|
super(layoutParams);
|
|
this.mViewType = 0;
|
|
}
|
|
|
|
public LayoutParams(LayoutParams layoutParams) {
|
|
super((ActionBar.LayoutParams) layoutParams);
|
|
this.mViewType = 0;
|
|
this.mViewType = layoutParams.mViewType;
|
|
}
|
|
|
|
public void copyMarginsFromCompat(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
|
((ViewGroup.MarginLayoutParams) this).leftMargin = marginLayoutParams.leftMargin;
|
|
((ViewGroup.MarginLayoutParams) this).topMargin = marginLayoutParams.topMargin;
|
|
((ViewGroup.MarginLayoutParams) this).rightMargin = marginLayoutParams.rightMargin;
|
|
((ViewGroup.MarginLayoutParams) this).bottomMargin = marginLayoutParams.bottomMargin;
|
|
}
|
|
}
|
|
|
|
public interface OnMenuItemClickListener {
|
|
boolean onMenuItemClick(MenuItem menuItem);
|
|
}
|
|
|
|
public static class SavedState extends AbsSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new AnonymousClass1();
|
|
public int expandedMenuItemId;
|
|
public boolean isOverflowOpen;
|
|
|
|
/* renamed from: androidx.appcompat.widget.Toolbar$SavedState$1 reason: invalid class name */
|
|
public class AnonymousClass1 implements Parcelable.ClassLoaderCreator<SavedState> {
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel, null);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.ClassLoaderCreator
|
|
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
|
|
return new SavedState(parcel, classLoader);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
}
|
|
|
|
public SavedState(Parcel parcel) {
|
|
this(parcel, null);
|
|
}
|
|
|
|
public SavedState(Parcel parcel, ClassLoader classLoader) {
|
|
super(parcel, classLoader);
|
|
this.expandedMenuItemId = parcel.readInt();
|
|
this.isOverflowOpen = parcel.readInt() != 0;
|
|
}
|
|
|
|
public SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
|
|
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
super.writeToParcel(parcel, i);
|
|
parcel.writeInt(this.expandedMenuItemId);
|
|
parcel.writeInt(this.isOverflowOpen ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
public Toolbar(@NonNull Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public Toolbar(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
|
this(context, attributeSet, R.attr.toolbarStyle);
|
|
}
|
|
|
|
public Toolbar(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.mGravity = 8388627;
|
|
this.mTempViews = new ArrayList<>();
|
|
this.mHiddenViews = new ArrayList<>();
|
|
this.mTempMargins = new int[2];
|
|
this.mMenuViewItemClickListener = new AnonymousClass1();
|
|
this.mShowOverflowMenuRunnable = new AnonymousClass2();
|
|
Context context2 = getContext();
|
|
int[] iArr = R.styleable.Toolbar;
|
|
TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context2, attributeSet, iArr, i, 0);
|
|
ViewCompat.saveAttributeDataForStyleable(this, context, iArr, attributeSet, obtainStyledAttributes.getWrappedTypeArray(), i, 0);
|
|
this.mTitleTextAppearance = obtainStyledAttributes.getResourceId(R.styleable.Toolbar_titleTextAppearance, 0);
|
|
this.mSubtitleTextAppearance = obtainStyledAttributes.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, 0);
|
|
this.mGravity = obtainStyledAttributes.getInteger(R.styleable.Toolbar_android_gravity, this.mGravity);
|
|
this.mButtonGravity = obtainStyledAttributes.getInteger(R.styleable.Toolbar_buttonGravity, 48);
|
|
int dimensionPixelOffset = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_titleMargin, 0);
|
|
int i2 = R.styleable.Toolbar_titleMargins;
|
|
dimensionPixelOffset = obtainStyledAttributes.hasValue(i2) ? obtainStyledAttributes.getDimensionPixelOffset(i2, dimensionPixelOffset) : dimensionPixelOffset;
|
|
this.mTitleMarginBottom = dimensionPixelOffset;
|
|
this.mTitleMarginTop = dimensionPixelOffset;
|
|
this.mTitleMarginEnd = dimensionPixelOffset;
|
|
this.mTitleMarginStart = dimensionPixelOffset;
|
|
int dimensionPixelOffset2 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginStart, -1);
|
|
if (dimensionPixelOffset2 >= 0) {
|
|
this.mTitleMarginStart = dimensionPixelOffset2;
|
|
}
|
|
int dimensionPixelOffset3 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginEnd, -1);
|
|
if (dimensionPixelOffset3 >= 0) {
|
|
this.mTitleMarginEnd = dimensionPixelOffset3;
|
|
}
|
|
int dimensionPixelOffset4 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginTop, -1);
|
|
if (dimensionPixelOffset4 >= 0) {
|
|
this.mTitleMarginTop = dimensionPixelOffset4;
|
|
}
|
|
int dimensionPixelOffset5 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_titleMarginBottom, -1);
|
|
if (dimensionPixelOffset5 >= 0) {
|
|
this.mTitleMarginBottom = dimensionPixelOffset5;
|
|
}
|
|
this.mMaxButtonHeight = obtainStyledAttributes.getDimensionPixelSize(R.styleable.Toolbar_maxButtonHeight, -1);
|
|
int dimensionPixelOffset6 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetStart, Integer.MIN_VALUE);
|
|
int dimensionPixelOffset7 = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetEnd, Integer.MIN_VALUE);
|
|
int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.Toolbar_contentInsetLeft, 0);
|
|
int dimensionPixelSize2 = obtainStyledAttributes.getDimensionPixelSize(R.styleable.Toolbar_contentInsetRight, 0);
|
|
ensureContentInsets();
|
|
this.mContentInsets.setAbsolute(dimensionPixelSize, dimensionPixelSize2);
|
|
if (!(dimensionPixelOffset6 == Integer.MIN_VALUE && dimensionPixelOffset7 == Integer.MIN_VALUE)) {
|
|
this.mContentInsets.setRelative(dimensionPixelOffset6, dimensionPixelOffset7);
|
|
}
|
|
this.mContentInsetStartWithNavigation = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetStartWithNavigation, Integer.MIN_VALUE);
|
|
this.mContentInsetEndWithActions = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.Toolbar_contentInsetEndWithActions, Integer.MIN_VALUE);
|
|
this.mCollapseIcon = obtainStyledAttributes.getDrawable(R.styleable.Toolbar_collapseIcon);
|
|
this.mCollapseDescription = obtainStyledAttributes.getText(R.styleable.Toolbar_collapseContentDescription);
|
|
CharSequence text = obtainStyledAttributes.getText(R.styleable.Toolbar_title);
|
|
if (!TextUtils.isEmpty(text)) {
|
|
setTitle(text);
|
|
}
|
|
CharSequence text2 = obtainStyledAttributes.getText(R.styleable.Toolbar_subtitle);
|
|
if (!TextUtils.isEmpty(text2)) {
|
|
setSubtitle(text2);
|
|
}
|
|
this.mPopupContext = getContext();
|
|
setPopupTheme(obtainStyledAttributes.getResourceId(R.styleable.Toolbar_popupTheme, 0));
|
|
Drawable drawable = obtainStyledAttributes.getDrawable(R.styleable.Toolbar_navigationIcon);
|
|
if (drawable != null) {
|
|
setNavigationIcon(drawable);
|
|
}
|
|
CharSequence text3 = obtainStyledAttributes.getText(R.styleable.Toolbar_navigationContentDescription);
|
|
if (!TextUtils.isEmpty(text3)) {
|
|
setNavigationContentDescription(text3);
|
|
}
|
|
Drawable drawable2 = obtainStyledAttributes.getDrawable(R.styleable.Toolbar_logo);
|
|
if (drawable2 != null) {
|
|
setLogo(drawable2);
|
|
}
|
|
CharSequence text4 = obtainStyledAttributes.getText(R.styleable.Toolbar_logoDescription);
|
|
if (!TextUtils.isEmpty(text4)) {
|
|
setLogoDescription(text4);
|
|
}
|
|
int i3 = R.styleable.Toolbar_titleTextColor;
|
|
if (obtainStyledAttributes.hasValue(i3)) {
|
|
setTitleTextColor(obtainStyledAttributes.getColorStateList(i3));
|
|
}
|
|
int i4 = R.styleable.Toolbar_subtitleTextColor;
|
|
if (obtainStyledAttributes.hasValue(i4)) {
|
|
setSubtitleTextColor(obtainStyledAttributes.getColorStateList(i4));
|
|
}
|
|
int i5 = R.styleable.Toolbar_menu;
|
|
if (obtainStyledAttributes.hasValue(i5)) {
|
|
inflateMenu(obtainStyledAttributes.getResourceId(i5, 0));
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
|
|
private void addCustomViewsWithGravity(List<View> list, int i) {
|
|
boolean z2 = ViewCompat.getLayoutDirection(this) == 1;
|
|
int childCount = getChildCount();
|
|
int absoluteGravity = GravityCompat.getAbsoluteGravity(i, ViewCompat.getLayoutDirection(this));
|
|
list.clear();
|
|
if (z2) {
|
|
for (int i2 = childCount - 1; i2 >= 0; i2--) {
|
|
View childAt = getChildAt(i2);
|
|
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
|
|
if (layoutParams.mViewType == 0 && shouldLayout(childAt) && getChildHorizontalGravity(layoutParams.gravity) == absoluteGravity) {
|
|
list.add(childAt);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
for (int i3 = 0; i3 < childCount; i3++) {
|
|
View childAt2 = getChildAt(i3);
|
|
LayoutParams layoutParams2 = (LayoutParams) childAt2.getLayoutParams();
|
|
if (layoutParams2.mViewType == 0 && shouldLayout(childAt2) && getChildHorizontalGravity(layoutParams2.gravity) == absoluteGravity) {
|
|
list.add(childAt2);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void addSystemView(View view, boolean z2) {
|
|
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
|
LayoutParams generateDefaultLayoutParams = layoutParams == null ? generateDefaultLayoutParams() : !checkLayoutParams(layoutParams) ? generateLayoutParams(layoutParams) : (LayoutParams) layoutParams;
|
|
generateDefaultLayoutParams.mViewType = 1;
|
|
if (!z2 || this.mExpandedActionView == null) {
|
|
addView(view, generateDefaultLayoutParams);
|
|
return;
|
|
}
|
|
view.setLayoutParams(generateDefaultLayoutParams);
|
|
this.mHiddenViews.add(view);
|
|
}
|
|
|
|
private void ensureContentInsets() {
|
|
if (this.mContentInsets == null) {
|
|
this.mContentInsets = new RtlSpacingHelper();
|
|
}
|
|
}
|
|
|
|
private void ensureLogoView() {
|
|
if (this.mLogoView == null) {
|
|
this.mLogoView = new AppCompatImageView(getContext());
|
|
}
|
|
}
|
|
|
|
private void ensureMenu() {
|
|
ensureMenuView();
|
|
if (this.mMenuView.peekMenu() == null) {
|
|
MenuBuilder menuBuilder = (MenuBuilder) this.mMenuView.getMenu();
|
|
if (this.mExpandedMenuPresenter == null) {
|
|
this.mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
|
|
}
|
|
this.mMenuView.setExpandedActionViewsExclusive(true);
|
|
menuBuilder.addMenuPresenter(this.mExpandedMenuPresenter, this.mPopupContext);
|
|
}
|
|
}
|
|
|
|
private void ensureMenuView() {
|
|
if (this.mMenuView == null) {
|
|
ActionMenuView actionMenuView = new ActionMenuView(getContext());
|
|
this.mMenuView = actionMenuView;
|
|
actionMenuView.setPopupTheme(this.mPopupTheme);
|
|
this.mMenuView.setOnMenuItemClickListener(this.mMenuViewItemClickListener);
|
|
this.mMenuView.setMenuCallbacks(this.mActionMenuPresenterCallback, this.mMenuBuilderCallback);
|
|
LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams();
|
|
generateDefaultLayoutParams.gravity = 8388613 | (this.mButtonGravity & 112);
|
|
this.mMenuView.setLayoutParams(generateDefaultLayoutParams);
|
|
addSystemView(this.mMenuView, false);
|
|
}
|
|
}
|
|
|
|
private void ensureNavButtonView() {
|
|
if (this.mNavButtonView == null) {
|
|
this.mNavButtonView = new AppCompatImageButton(getContext(), null, R.attr.toolbarNavigationButtonStyle);
|
|
LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams();
|
|
generateDefaultLayoutParams.gravity = 8388611 | (this.mButtonGravity & 112);
|
|
this.mNavButtonView.setLayoutParams(generateDefaultLayoutParams);
|
|
}
|
|
}
|
|
|
|
private int getChildHorizontalGravity(int i) {
|
|
int layoutDirection = ViewCompat.getLayoutDirection(this);
|
|
int absoluteGravity = GravityCompat.getAbsoluteGravity(i, layoutDirection) & 7;
|
|
return (absoluteGravity == 1 || absoluteGravity == 3 || absoluteGravity == 5) ? absoluteGravity : layoutDirection == 1 ? 5 : 3;
|
|
}
|
|
|
|
private int getChildTop(View view, int i) {
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
int measuredHeight = view.getMeasuredHeight();
|
|
int i2 = i > 0 ? (measuredHeight - i) / 2 : 0;
|
|
int childVerticalGravity = getChildVerticalGravity(layoutParams.gravity);
|
|
if (childVerticalGravity == 48) {
|
|
return getPaddingTop() - i2;
|
|
}
|
|
if (childVerticalGravity == 80) {
|
|
return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin) - i2;
|
|
}
|
|
int paddingTop = getPaddingTop();
|
|
int paddingBottom = getPaddingBottom();
|
|
int height = getHeight();
|
|
int i3 = (((height - paddingTop) - paddingBottom) - measuredHeight) / 2;
|
|
int i4 = ((ViewGroup.MarginLayoutParams) layoutParams).topMargin;
|
|
if (i3 < i4) {
|
|
i3 = i4;
|
|
} else {
|
|
int i5 = (((height - paddingBottom) - measuredHeight) - i3) - paddingTop;
|
|
int i6 = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
|
|
if (i5 < i6) {
|
|
i3 = Math.max(0, i3 - (i6 - i5));
|
|
}
|
|
}
|
|
return paddingTop + i3;
|
|
}
|
|
|
|
private int getChildVerticalGravity(int i) {
|
|
int i2 = i & 112;
|
|
return (i2 == 16 || i2 == 48 || i2 == 80) ? i2 : this.mGravity & 112;
|
|
}
|
|
|
|
private int getHorizontalMargins(View view) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
|
return MarginLayoutParamsCompat.getMarginEnd(marginLayoutParams) + MarginLayoutParamsCompat.getMarginStart(marginLayoutParams);
|
|
}
|
|
|
|
private MenuInflater getMenuInflater() {
|
|
return new SupportMenuInflater(getContext());
|
|
}
|
|
|
|
private int getVerticalMargins(View view) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
|
return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
|
|
}
|
|
|
|
private int getViewListMeasuredWidth(List<View> list, int[] iArr) {
|
|
int i = iArr[0];
|
|
int i2 = iArr[1];
|
|
int size = list.size();
|
|
int i3 = 0;
|
|
int i4 = 0;
|
|
while (i3 < size) {
|
|
View view = list.get(i3);
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
int i5 = ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin - i;
|
|
int i6 = ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin - i2;
|
|
int max = Math.max(0, i5);
|
|
int max2 = Math.max(0, i6);
|
|
int max3 = Math.max(0, -i5);
|
|
int max4 = Math.max(0, -i6);
|
|
i4 += view.getMeasuredWidth() + max + max2;
|
|
i3++;
|
|
i2 = max4;
|
|
i = max3;
|
|
}
|
|
return i4;
|
|
}
|
|
|
|
private boolean isChildOrHidden(View view) {
|
|
return view.getParent() == this || this.mHiddenViews.contains(view);
|
|
}
|
|
|
|
private int layoutChildLeft(View view, int i, int[] iArr, int i2) {
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
int i3 = ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin - iArr[0];
|
|
int max = Math.max(0, i3) + i;
|
|
iArr[0] = Math.max(0, -i3);
|
|
int childTop = getChildTop(view, i2);
|
|
int measuredWidth = view.getMeasuredWidth();
|
|
view.layout(max, childTop, max + measuredWidth, view.getMeasuredHeight() + childTop);
|
|
return measuredWidth + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin + max;
|
|
}
|
|
|
|
private int layoutChildRight(View view, int i, int[] iArr, int i2) {
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
int i3 = ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin - iArr[1];
|
|
int max = i - Math.max(0, i3);
|
|
iArr[1] = Math.max(0, -i3);
|
|
int childTop = getChildTop(view, i2);
|
|
int measuredWidth = view.getMeasuredWidth();
|
|
view.layout(max - measuredWidth, childTop, max, view.getMeasuredHeight() + childTop);
|
|
return max - (measuredWidth + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin);
|
|
}
|
|
|
|
private int measureChildCollapseMargins(View view, int i, int i2, int i3, int i4, int[] iArr) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
|
int i5 = marginLayoutParams.leftMargin - iArr[0];
|
|
int i6 = marginLayoutParams.rightMargin - iArr[1];
|
|
int max = Math.max(0, i6) + Math.max(0, i5);
|
|
iArr[0] = Math.max(0, -i5);
|
|
iArr[1] = Math.max(0, -i6);
|
|
view.measure(ViewGroup.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft() + max + i2, marginLayoutParams.width), ViewGroup.getChildMeasureSpec(i3, getPaddingBottom() + getPaddingTop() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i4, marginLayoutParams.height));
|
|
return view.getMeasuredWidth() + max;
|
|
}
|
|
|
|
private void measureChildConstrained(View view, int i, int i2, int i3, int i4, int i5) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
|
int childMeasureSpec = ViewGroup.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i2, marginLayoutParams.width);
|
|
int childMeasureSpec2 = ViewGroup.getChildMeasureSpec(i3, getPaddingBottom() + getPaddingTop() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i4, marginLayoutParams.height);
|
|
int mode = View.MeasureSpec.getMode(childMeasureSpec2);
|
|
if (mode != 1073741824 && i5 >= 0) {
|
|
if (mode != 0) {
|
|
i5 = Math.min(View.MeasureSpec.getSize(childMeasureSpec2), i5);
|
|
}
|
|
childMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i5, BasicMeasure.EXACTLY);
|
|
}
|
|
view.measure(childMeasureSpec, childMeasureSpec2);
|
|
}
|
|
|
|
private void postShowOverflowMenu() {
|
|
removeCallbacks(this.mShowOverflowMenuRunnable);
|
|
post(this.mShowOverflowMenuRunnable);
|
|
}
|
|
|
|
private boolean shouldCollapse() {
|
|
if (!this.mCollapsible) {
|
|
return false;
|
|
}
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
if (shouldLayout(childAt) && childAt.getMeasuredWidth() > 0 && childAt.getMeasuredHeight() > 0) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private boolean shouldLayout(View view) {
|
|
return (view == null || view.getParent() != this || view.getVisibility() == 8) ? false : true;
|
|
}
|
|
|
|
public void addChildrenForExpandedActionView() {
|
|
for (int size = this.mHiddenViews.size() - 1; size >= 0; size--) {
|
|
addView(this.mHiddenViews.get(size));
|
|
}
|
|
this.mHiddenViews.clear();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public boolean canShowOverflowMenu() {
|
|
ActionMenuView actionMenuView;
|
|
return getVisibility() == 0 && (actionMenuView = this.mMenuView) != null && actionMenuView.isOverflowReserved();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return super.checkLayoutParams(layoutParams) && (layoutParams instanceof LayoutParams);
|
|
}
|
|
|
|
public void collapseActionView() {
|
|
ExpandedActionViewMenuPresenter expandedActionViewMenuPresenter = this.mExpandedMenuPresenter;
|
|
MenuItemImpl menuItemImpl = expandedActionViewMenuPresenter == null ? null : expandedActionViewMenuPresenter.mCurrentExpandedItem;
|
|
if (menuItemImpl != null) {
|
|
menuItemImpl.collapseActionView();
|
|
}
|
|
}
|
|
|
|
public void dismissPopupMenus() {
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
if (actionMenuView != null) {
|
|
actionMenuView.dismissPopupMenus();
|
|
}
|
|
}
|
|
|
|
public void ensureCollapseButtonView() {
|
|
if (this.mCollapseButtonView == null) {
|
|
AppCompatImageButton appCompatImageButton = new AppCompatImageButton(getContext(), null, R.attr.toolbarNavigationButtonStyle);
|
|
this.mCollapseButtonView = appCompatImageButton;
|
|
appCompatImageButton.setImageDrawable(this.mCollapseIcon);
|
|
this.mCollapseButtonView.setContentDescription(this.mCollapseDescription);
|
|
LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams();
|
|
generateDefaultLayoutParams.gravity = 8388611 | (this.mButtonGravity & 112);
|
|
generateDefaultLayoutParams.mViewType = 2;
|
|
this.mCollapseButtonView.setLayoutParams(generateDefaultLayoutParams);
|
|
this.mCollapseButtonView.setOnClickListener(new AnonymousClass3());
|
|
}
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public LayoutParams generateDefaultLayoutParams() {
|
|
return new LayoutParams(-2, -2);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
|
return new LayoutParams(getContext(), attributeSet);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return layoutParams instanceof LayoutParams ? new LayoutParams((LayoutParams) layoutParams) : layoutParams instanceof ActionBar.LayoutParams ? new LayoutParams((ActionBar.LayoutParams) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams) : new LayoutParams(layoutParams);
|
|
}
|
|
|
|
@Nullable
|
|
public CharSequence getCollapseContentDescription() {
|
|
ImageButton imageButton = this.mCollapseButtonView;
|
|
if (imageButton != null) {
|
|
return imageButton.getContentDescription();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Nullable
|
|
public Drawable getCollapseIcon() {
|
|
ImageButton imageButton = this.mCollapseButtonView;
|
|
if (imageButton != null) {
|
|
return imageButton.getDrawable();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public int getContentInsetEnd() {
|
|
RtlSpacingHelper rtlSpacingHelper = this.mContentInsets;
|
|
if (rtlSpacingHelper != null) {
|
|
return rtlSpacingHelper.getEnd();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getContentInsetEndWithActions() {
|
|
int i = this.mContentInsetEndWithActions;
|
|
return i != Integer.MIN_VALUE ? i : getContentInsetEnd();
|
|
}
|
|
|
|
public int getContentInsetLeft() {
|
|
RtlSpacingHelper rtlSpacingHelper = this.mContentInsets;
|
|
if (rtlSpacingHelper != null) {
|
|
return rtlSpacingHelper.getLeft();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getContentInsetRight() {
|
|
RtlSpacingHelper rtlSpacingHelper = this.mContentInsets;
|
|
if (rtlSpacingHelper != null) {
|
|
return rtlSpacingHelper.getRight();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getContentInsetStart() {
|
|
RtlSpacingHelper rtlSpacingHelper = this.mContentInsets;
|
|
if (rtlSpacingHelper != null) {
|
|
return rtlSpacingHelper.getStart();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int getContentInsetStartWithNavigation() {
|
|
int i = this.mContentInsetStartWithNavigation;
|
|
return i != Integer.MIN_VALUE ? i : getContentInsetStart();
|
|
}
|
|
|
|
public int getCurrentContentInsetEnd() {
|
|
MenuBuilder peekMenu;
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
return actionMenuView != null && (peekMenu = actionMenuView.peekMenu()) != null && peekMenu.hasVisibleItems() ? Math.max(getContentInsetEnd(), Math.max(this.mContentInsetEndWithActions, 0)) : getContentInsetEnd();
|
|
}
|
|
|
|
public int getCurrentContentInsetLeft() {
|
|
return ViewCompat.getLayoutDirection(this) == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart();
|
|
}
|
|
|
|
public int getCurrentContentInsetRight() {
|
|
return ViewCompat.getLayoutDirection(this) == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd();
|
|
}
|
|
|
|
public int getCurrentContentInsetStart() {
|
|
return getNavigationIcon() != null ? Math.max(getContentInsetStart(), Math.max(this.mContentInsetStartWithNavigation, 0)) : getContentInsetStart();
|
|
}
|
|
|
|
public Drawable getLogo() {
|
|
ImageView imageView = this.mLogoView;
|
|
if (imageView != null) {
|
|
return imageView.getDrawable();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public CharSequence getLogoDescription() {
|
|
ImageView imageView = this.mLogoView;
|
|
if (imageView != null) {
|
|
return imageView.getContentDescription();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public Menu getMenu() {
|
|
ensureMenu();
|
|
return this.mMenuView.getMenu();
|
|
}
|
|
|
|
@Nullable
|
|
public CharSequence getNavigationContentDescription() {
|
|
ImageButton imageButton = this.mNavButtonView;
|
|
if (imageButton != null) {
|
|
return imageButton.getContentDescription();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Nullable
|
|
public Drawable getNavigationIcon() {
|
|
ImageButton imageButton = this.mNavButtonView;
|
|
if (imageButton != null) {
|
|
return imageButton.getDrawable();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public ActionMenuPresenter getOuterActionMenuPresenter() {
|
|
return this.mOuterActionMenuPresenter;
|
|
}
|
|
|
|
@Nullable
|
|
public Drawable getOverflowIcon() {
|
|
ensureMenu();
|
|
return this.mMenuView.getOverflowIcon();
|
|
}
|
|
|
|
public Context getPopupContext() {
|
|
return this.mPopupContext;
|
|
}
|
|
|
|
public int getPopupTheme() {
|
|
return this.mPopupTheme;
|
|
}
|
|
|
|
public CharSequence getSubtitle() {
|
|
return this.mSubtitleText;
|
|
}
|
|
|
|
@Nullable
|
|
@RestrictTo({RestrictTo.Scope.TESTS})
|
|
public final TextView getSubtitleTextView() {
|
|
return this.mSubtitleTextView;
|
|
}
|
|
|
|
public CharSequence getTitle() {
|
|
return this.mTitleText;
|
|
}
|
|
|
|
public int getTitleMarginBottom() {
|
|
return this.mTitleMarginBottom;
|
|
}
|
|
|
|
public int getTitleMarginEnd() {
|
|
return this.mTitleMarginEnd;
|
|
}
|
|
|
|
public int getTitleMarginStart() {
|
|
return this.mTitleMarginStart;
|
|
}
|
|
|
|
public int getTitleMarginTop() {
|
|
return this.mTitleMarginTop;
|
|
}
|
|
|
|
@Nullable
|
|
@RestrictTo({RestrictTo.Scope.TESTS})
|
|
public final TextView getTitleTextView() {
|
|
return this.mTitleTextView;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public DecorToolbar getWrapper() {
|
|
if (this.mWrapper == null) {
|
|
this.mWrapper = new ToolbarWidgetWrapper(this, true);
|
|
}
|
|
return this.mWrapper;
|
|
}
|
|
|
|
public boolean hasExpandedActionView() {
|
|
ExpandedActionViewMenuPresenter expandedActionViewMenuPresenter = this.mExpandedMenuPresenter;
|
|
return (expandedActionViewMenuPresenter == null || expandedActionViewMenuPresenter.mCurrentExpandedItem == null) ? false : true;
|
|
}
|
|
|
|
public boolean hideOverflowMenu() {
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
return actionMenuView != null && actionMenuView.hideOverflowMenu();
|
|
}
|
|
|
|
public void inflateMenu(@MenuRes int i) {
|
|
getMenuInflater().inflate(i, getMenu());
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public boolean isOverflowMenuShowPending() {
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
return actionMenuView != null && actionMenuView.isOverflowMenuShowPending();
|
|
}
|
|
|
|
public boolean isOverflowMenuShowing() {
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
return actionMenuView != null && actionMenuView.isOverflowMenuShowing();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public boolean isTitleTruncated() {
|
|
Layout layout;
|
|
TextView textView = this.mTitleTextView;
|
|
if (textView == null || (layout = textView.getLayout()) == null) {
|
|
return false;
|
|
}
|
|
int lineCount = layout.getLineCount();
|
|
for (int i = 0; i < lineCount; i++) {
|
|
if (layout.getEllipsisCount(i) > 0) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
removeCallbacks(this.mShowOverflowMenuRunnable);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onHoverEvent(MotionEvent motionEvent) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 9) {
|
|
this.mEatingHover = false;
|
|
}
|
|
if (!this.mEatingHover) {
|
|
boolean onHoverEvent = super.onHoverEvent(motionEvent);
|
|
if (actionMasked == 9 && !onHoverEvent) {
|
|
this.mEatingHover = true;
|
|
}
|
|
}
|
|
if (actionMasked == 10 || actionMasked == 3) {
|
|
this.mEatingHover = false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:102:0x029f A[LOOP:0: B:101:0x029d->B:102:0x029f, LOOP_END] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:105:0x02c1 A[LOOP:1: B:104:0x02bf->B:105:0x02c1, LOOP_END] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:108:0x02eb */
|
|
/* JADX WARNING: Removed duplicated region for block: B:113:0x02fa A[LOOP:2: B:112:0x02f8->B:113:0x02fa, LOOP_END] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:17:0x005f */
|
|
/* JADX WARNING: Removed duplicated region for block: B:22:0x0076 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:27:0x00b3 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:32:0x00ca */
|
|
/* JADX WARNING: Removed duplicated region for block: B:37:0x00e7 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:38:0x0100 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:40:0x0105 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:41:0x011d */
|
|
/* JADX WARNING: Removed duplicated region for block: B:47:0x012d */
|
|
/* JADX WARNING: Removed duplicated region for block: B:48:0x0130 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:50:0x0134 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:51:0x0137 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:63:0x0168 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:73:0x01a6 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:75:0x01b7 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:88:0x0227 */
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void onLayout(boolean z2, int i, int i2, int i3, int i4) {
|
|
int i5;
|
|
int i6;
|
|
boolean shouldLayout;
|
|
boolean shouldLayout2;
|
|
int i7;
|
|
int i8;
|
|
int i9;
|
|
int i10;
|
|
int i11;
|
|
int i12;
|
|
int size;
|
|
int i13;
|
|
int size2;
|
|
int i14;
|
|
int i15;
|
|
int size3;
|
|
int i16;
|
|
int i17;
|
|
int i18;
|
|
int i19;
|
|
int i20;
|
|
int i21;
|
|
int i22;
|
|
int i23;
|
|
boolean z3 = ViewCompat.getLayoutDirection(this) == 1;
|
|
int width = getWidth();
|
|
int height = getHeight();
|
|
int paddingLeft = getPaddingLeft();
|
|
int paddingRight = getPaddingRight();
|
|
int paddingTop = getPaddingTop();
|
|
int paddingBottom = getPaddingBottom();
|
|
int i24 = width - paddingRight;
|
|
int[] iArr = this.mTempMargins;
|
|
iArr[1] = 0;
|
|
iArr[0] = 0;
|
|
int minimumHeight = ViewCompat.getMinimumHeight(this);
|
|
int min = minimumHeight >= 0 ? Math.min(minimumHeight, i4 - i2) : 0;
|
|
if (!shouldLayout(this.mNavButtonView)) {
|
|
i6 = paddingLeft;
|
|
} else if (z3) {
|
|
i5 = layoutChildRight(this.mNavButtonView, i24, iArr, min);
|
|
i6 = paddingLeft;
|
|
if (shouldLayout(this.mCollapseButtonView)) {
|
|
if (z3) {
|
|
i5 = layoutChildRight(this.mCollapseButtonView, i5, iArr, min);
|
|
} else {
|
|
i6 = layoutChildLeft(this.mCollapseButtonView, i6, iArr, min);
|
|
}
|
|
}
|
|
if (shouldLayout(this.mMenuView)) {
|
|
if (z3) {
|
|
i6 = layoutChildLeft(this.mMenuView, i6, iArr, min);
|
|
} else {
|
|
i5 = layoutChildRight(this.mMenuView, i5, iArr, min);
|
|
}
|
|
}
|
|
int currentContentInsetLeft = getCurrentContentInsetLeft();
|
|
int currentContentInsetRight = getCurrentContentInsetRight();
|
|
iArr[0] = Math.max(0, currentContentInsetLeft - i6);
|
|
iArr[1] = Math.max(0, currentContentInsetRight - (i24 - i5));
|
|
int max = Math.max(i6, currentContentInsetLeft);
|
|
int min2 = Math.min(i5, i24 - currentContentInsetRight);
|
|
if (shouldLayout(this.mExpandedActionView)) {
|
|
if (z3) {
|
|
min2 = layoutChildRight(this.mExpandedActionView, min2, iArr, min);
|
|
} else {
|
|
max = layoutChildLeft(this.mExpandedActionView, max, iArr, min);
|
|
}
|
|
}
|
|
if (shouldLayout(this.mLogoView)) {
|
|
if (z3) {
|
|
min2 = layoutChildRight(this.mLogoView, min2, iArr, min);
|
|
} else {
|
|
max = layoutChildLeft(this.mLogoView, max, iArr, min);
|
|
}
|
|
}
|
|
shouldLayout = shouldLayout(this.mTitleTextView);
|
|
shouldLayout2 = shouldLayout(this.mSubtitleTextView);
|
|
if (!shouldLayout) {
|
|
LayoutParams layoutParams = (LayoutParams) this.mTitleTextView.getLayoutParams();
|
|
i7 = paddingRight;
|
|
i8 = this.mTitleTextView.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin + 0;
|
|
} else {
|
|
i7 = paddingRight;
|
|
i8 = 0;
|
|
}
|
|
if (!shouldLayout2) {
|
|
LayoutParams layoutParams2 = (LayoutParams) this.mSubtitleTextView.getLayoutParams();
|
|
i9 = width;
|
|
i8 += this.mSubtitleTextView.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams2).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams2).bottomMargin;
|
|
} else {
|
|
i9 = width;
|
|
}
|
|
if (!shouldLayout || shouldLayout2) {
|
|
TextView textView = !shouldLayout ? this.mTitleTextView : this.mSubtitleTextView;
|
|
TextView textView2 = !shouldLayout2 ? this.mSubtitleTextView : this.mTitleTextView;
|
|
LayoutParams layoutParams3 = (LayoutParams) textView.getLayoutParams();
|
|
LayoutParams layoutParams4 = (LayoutParams) textView2.getLayoutParams();
|
|
boolean z4 = (!shouldLayout && this.mTitleTextView.getMeasuredWidth() > 0) || (shouldLayout2 && this.mSubtitleTextView.getMeasuredWidth() > 0);
|
|
i16 = this.mGravity & 112;
|
|
i11 = paddingLeft;
|
|
if (i16 != 48) {
|
|
i17 = max;
|
|
i10 = min;
|
|
i18 = getPaddingTop() + ((ViewGroup.MarginLayoutParams) layoutParams3).topMargin + this.mTitleMarginTop;
|
|
} else if (i16 != 80) {
|
|
int i25 = (((height - paddingTop) - paddingBottom) - i8) / 2;
|
|
int i26 = ((ViewGroup.MarginLayoutParams) layoutParams3).topMargin;
|
|
i10 = min;
|
|
int i27 = this.mTitleMarginTop;
|
|
i17 = max;
|
|
if (i25 < i26 + i27) {
|
|
i25 = i26 + i27;
|
|
} else {
|
|
int i28 = (((height - paddingBottom) - i8) - i25) - paddingTop;
|
|
int i29 = ((ViewGroup.MarginLayoutParams) layoutParams3).bottomMargin;
|
|
int i30 = this.mTitleMarginBottom;
|
|
if (i28 < i29 + i30) {
|
|
i25 = Math.max(0, i25 - ((((ViewGroup.MarginLayoutParams) layoutParams4).bottomMargin + i30) - i28));
|
|
}
|
|
}
|
|
i18 = paddingTop + i25;
|
|
} else {
|
|
i17 = max;
|
|
i10 = min;
|
|
i18 = (((height - paddingBottom) - ((ViewGroup.MarginLayoutParams) layoutParams4).bottomMargin) - this.mTitleMarginBottom) - i8;
|
|
}
|
|
if (!z3) {
|
|
int i31 = (z4 ? this.mTitleMarginStart : 0) - iArr[1];
|
|
min2 -= Math.max(0, i31);
|
|
iArr[1] = Math.max(0, -i31);
|
|
if (shouldLayout) {
|
|
int measuredWidth = min2 - this.mTitleTextView.getMeasuredWidth();
|
|
int measuredHeight = this.mTitleTextView.getMeasuredHeight() + i18;
|
|
this.mTitleTextView.layout(measuredWidth, i18, min2, measuredHeight);
|
|
i22 = measuredWidth - this.mTitleMarginEnd;
|
|
i18 = measuredHeight + ((ViewGroup.MarginLayoutParams) ((LayoutParams) this.mTitleTextView.getLayoutParams())).bottomMargin;
|
|
} else {
|
|
i22 = min2;
|
|
}
|
|
if (shouldLayout2) {
|
|
int i32 = i18 + ((ViewGroup.MarginLayoutParams) ((LayoutParams) this.mSubtitleTextView.getLayoutParams())).topMargin;
|
|
this.mSubtitleTextView.layout(min2 - this.mSubtitleTextView.getMeasuredWidth(), i32, min2, this.mSubtitleTextView.getMeasuredHeight() + i32);
|
|
i23 = min2 - this.mTitleMarginEnd;
|
|
} else {
|
|
i23 = min2;
|
|
}
|
|
if (z4) {
|
|
min2 = Math.min(i22, i23);
|
|
}
|
|
max = i17;
|
|
} else {
|
|
if (z4) {
|
|
i19 = this.mTitleMarginStart;
|
|
i12 = 0;
|
|
} else {
|
|
i12 = 0;
|
|
i19 = 0;
|
|
}
|
|
int i33 = i19 - iArr[i12];
|
|
max = Math.max(i12, i33) + i17;
|
|
iArr[i12] = Math.max(i12, -i33);
|
|
if (shouldLayout) {
|
|
int measuredWidth2 = this.mTitleTextView.getMeasuredWidth() + max;
|
|
int measuredHeight2 = this.mTitleTextView.getMeasuredHeight() + i18;
|
|
this.mTitleTextView.layout(max, i18, measuredWidth2, measuredHeight2);
|
|
i20 = measuredWidth2 + this.mTitleMarginEnd;
|
|
i18 = measuredHeight2 + ((ViewGroup.MarginLayoutParams) ((LayoutParams) this.mTitleTextView.getLayoutParams())).bottomMargin;
|
|
} else {
|
|
i20 = max;
|
|
}
|
|
if (shouldLayout2) {
|
|
int i34 = i18 + ((ViewGroup.MarginLayoutParams) ((LayoutParams) this.mSubtitleTextView.getLayoutParams())).topMargin;
|
|
int measuredWidth3 = this.mSubtitleTextView.getMeasuredWidth() + max;
|
|
this.mSubtitleTextView.layout(max, i34, measuredWidth3, this.mSubtitleTextView.getMeasuredHeight() + i34);
|
|
i21 = measuredWidth3 + this.mTitleMarginEnd;
|
|
} else {
|
|
i21 = max;
|
|
}
|
|
if (z4) {
|
|
max = Math.max(i20, i21);
|
|
}
|
|
addCustomViewsWithGravity(this.mTempViews, 3);
|
|
size = this.mTempViews.size();
|
|
for (i13 = 0; i13 < size; i13++) {
|
|
max = layoutChildLeft(this.mTempViews.get(i13), max, iArr, i10);
|
|
}
|
|
addCustomViewsWithGravity(this.mTempViews, 5);
|
|
size2 = this.mTempViews.size();
|
|
for (i14 = 0; i14 < size2; i14++) {
|
|
min2 = layoutChildRight(this.mTempViews.get(i14), min2, iArr, i10);
|
|
}
|
|
addCustomViewsWithGravity(this.mTempViews, 1);
|
|
int viewListMeasuredWidth = getViewListMeasuredWidth(this.mTempViews, iArr);
|
|
i15 = ((((i9 - i11) - i7) / 2) + i11) - (viewListMeasuredWidth / 2);
|
|
int i35 = viewListMeasuredWidth + i15;
|
|
if (i15 >= max) {
|
|
max = i35 > min2 ? i15 - (i35 - min2) : i15;
|
|
}
|
|
size3 = this.mTempViews.size();
|
|
while (i12 < size3) {
|
|
max = layoutChildLeft(this.mTempViews.get(i12), max, iArr, i10);
|
|
i12++;
|
|
}
|
|
this.mTempViews.clear();
|
|
return;
|
|
}
|
|
} else {
|
|
i11 = paddingLeft;
|
|
i10 = min;
|
|
}
|
|
i12 = 0;
|
|
addCustomViewsWithGravity(this.mTempViews, 3);
|
|
size = this.mTempViews.size();
|
|
while (i13 < size) {
|
|
}
|
|
addCustomViewsWithGravity(this.mTempViews, 5);
|
|
size2 = this.mTempViews.size();
|
|
while (i14 < size2) {
|
|
}
|
|
addCustomViewsWithGravity(this.mTempViews, 1);
|
|
int viewListMeasuredWidth = getViewListMeasuredWidth(this.mTempViews, iArr);
|
|
i15 = ((((i9 - i11) - i7) / 2) + i11) - (viewListMeasuredWidth / 2);
|
|
int i35 = viewListMeasuredWidth + i15;
|
|
if (i15 >= max) {
|
|
}
|
|
size3 = this.mTempViews.size();
|
|
while (i12 < size3) {
|
|
}
|
|
this.mTempViews.clear();
|
|
return;
|
|
} else {
|
|
i6 = layoutChildLeft(this.mNavButtonView, paddingLeft, iArr, min);
|
|
}
|
|
i5 = i24;
|
|
if (shouldLayout(this.mCollapseButtonView)) {
|
|
}
|
|
if (shouldLayout(this.mMenuView)) {
|
|
}
|
|
int currentContentInsetLeft = getCurrentContentInsetLeft();
|
|
int currentContentInsetRight = getCurrentContentInsetRight();
|
|
iArr[0] = Math.max(0, currentContentInsetLeft - i6);
|
|
iArr[1] = Math.max(0, currentContentInsetRight - (i24 - i5));
|
|
int max = Math.max(i6, currentContentInsetLeft);
|
|
int min2 = Math.min(i5, i24 - currentContentInsetRight);
|
|
if (shouldLayout(this.mExpandedActionView)) {
|
|
}
|
|
if (shouldLayout(this.mLogoView)) {
|
|
}
|
|
shouldLayout = shouldLayout(this.mTitleTextView);
|
|
shouldLayout2 = shouldLayout(this.mSubtitleTextView);
|
|
if (!shouldLayout) {
|
|
}
|
|
if (!shouldLayout2) {
|
|
}
|
|
if (!shouldLayout) {
|
|
}
|
|
if (!shouldLayout) {
|
|
}
|
|
if (!shouldLayout2) {
|
|
}
|
|
LayoutParams layoutParams3 = (LayoutParams) textView.getLayoutParams();
|
|
LayoutParams layoutParams4 = (LayoutParams) textView2.getLayoutParams();
|
|
if (!shouldLayout) {
|
|
}
|
|
i16 = this.mGravity & 112;
|
|
i11 = paddingLeft;
|
|
if (i16 != 48) {
|
|
}
|
|
if (!z3) {
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onMeasure(int i, int i2) {
|
|
char c2;
|
|
char c3;
|
|
int i3;
|
|
int i4;
|
|
int i5;
|
|
int i6;
|
|
int i7;
|
|
int i8;
|
|
int i9;
|
|
int[] iArr = this.mTempMargins;
|
|
int i10 = 0;
|
|
if (ViewUtils.isLayoutRtl(this)) {
|
|
c3 = 1;
|
|
c2 = 0;
|
|
} else {
|
|
c3 = 0;
|
|
c2 = 1;
|
|
}
|
|
if (shouldLayout(this.mNavButtonView)) {
|
|
measureChildConstrained(this.mNavButtonView, i, 0, i2, 0, this.mMaxButtonHeight);
|
|
i5 = this.mNavButtonView.getMeasuredWidth() + getHorizontalMargins(this.mNavButtonView);
|
|
i4 = Math.max(0, this.mNavButtonView.getMeasuredHeight() + getVerticalMargins(this.mNavButtonView));
|
|
i3 = View.combineMeasuredStates(0, this.mNavButtonView.getMeasuredState());
|
|
} else {
|
|
i5 = 0;
|
|
i4 = 0;
|
|
i3 = 0;
|
|
}
|
|
if (shouldLayout(this.mCollapseButtonView)) {
|
|
measureChildConstrained(this.mCollapseButtonView, i, 0, i2, 0, this.mMaxButtonHeight);
|
|
i5 = this.mCollapseButtonView.getMeasuredWidth() + getHorizontalMargins(this.mCollapseButtonView);
|
|
i4 = Math.max(i4, this.mCollapseButtonView.getMeasuredHeight() + getVerticalMargins(this.mCollapseButtonView));
|
|
i3 = View.combineMeasuredStates(i3, this.mCollapseButtonView.getMeasuredState());
|
|
}
|
|
int currentContentInsetStart = getCurrentContentInsetStart();
|
|
int max = Math.max(currentContentInsetStart, i5) + 0;
|
|
iArr[c3] = Math.max(0, currentContentInsetStart - i5);
|
|
if (shouldLayout(this.mMenuView)) {
|
|
measureChildConstrained(this.mMenuView, i, max, i2, 0, this.mMaxButtonHeight);
|
|
i6 = this.mMenuView.getMeasuredWidth() + getHorizontalMargins(this.mMenuView);
|
|
i4 = Math.max(i4, this.mMenuView.getMeasuredHeight() + getVerticalMargins(this.mMenuView));
|
|
i3 = View.combineMeasuredStates(i3, this.mMenuView.getMeasuredState());
|
|
} else {
|
|
i6 = 0;
|
|
}
|
|
int currentContentInsetEnd = getCurrentContentInsetEnd();
|
|
int max2 = Math.max(currentContentInsetEnd, i6) + max;
|
|
iArr[c2] = Math.max(0, currentContentInsetEnd - i6);
|
|
if (shouldLayout(this.mExpandedActionView)) {
|
|
max2 += measureChildCollapseMargins(this.mExpandedActionView, i, max2, i2, 0, iArr);
|
|
i4 = Math.max(i4, this.mExpandedActionView.getMeasuredHeight() + getVerticalMargins(this.mExpandedActionView));
|
|
i3 = View.combineMeasuredStates(i3, this.mExpandedActionView.getMeasuredState());
|
|
}
|
|
if (shouldLayout(this.mLogoView)) {
|
|
max2 += measureChildCollapseMargins(this.mLogoView, i, max2, i2, 0, iArr);
|
|
i4 = Math.max(i4, this.mLogoView.getMeasuredHeight() + getVerticalMargins(this.mLogoView));
|
|
i3 = View.combineMeasuredStates(i3, this.mLogoView.getMeasuredState());
|
|
}
|
|
int childCount = getChildCount();
|
|
for (int i11 = 0; i11 < childCount; i11++) {
|
|
View childAt = getChildAt(i11);
|
|
if (((LayoutParams) childAt.getLayoutParams()).mViewType == 0 && shouldLayout(childAt)) {
|
|
max2 += measureChildCollapseMargins(childAt, i, max2, i2, 0, iArr);
|
|
i4 = Math.max(i4, childAt.getMeasuredHeight() + getVerticalMargins(childAt));
|
|
i3 = View.combineMeasuredStates(i3, childAt.getMeasuredState());
|
|
}
|
|
}
|
|
int i12 = this.mTitleMarginTop + this.mTitleMarginBottom;
|
|
int i13 = this.mTitleMarginStart + this.mTitleMarginEnd;
|
|
if (shouldLayout(this.mTitleTextView)) {
|
|
measureChildCollapseMargins(this.mTitleTextView, i, max2 + i13, i2, i12, iArr);
|
|
int measuredWidth = this.mTitleTextView.getMeasuredWidth() + getHorizontalMargins(this.mTitleTextView);
|
|
i7 = this.mTitleTextView.getMeasuredHeight() + getVerticalMargins(this.mTitleTextView);
|
|
i9 = View.combineMeasuredStates(i3, this.mTitleTextView.getMeasuredState());
|
|
i8 = measuredWidth;
|
|
} else {
|
|
i9 = i3;
|
|
i8 = 0;
|
|
i7 = 0;
|
|
}
|
|
if (shouldLayout(this.mSubtitleTextView)) {
|
|
i8 = Math.max(i8, measureChildCollapseMargins(this.mSubtitleTextView, i, max2 + i13, i2, i7 + i12, iArr));
|
|
i7 += this.mSubtitleTextView.getMeasuredHeight() + getVerticalMargins(this.mSubtitleTextView);
|
|
i9 = View.combineMeasuredStates(i9, this.mSubtitleTextView.getMeasuredState());
|
|
}
|
|
int max3 = Math.max(i4, i7);
|
|
int paddingRight = getPaddingRight() + getPaddingLeft();
|
|
int paddingBottom = getPaddingBottom() + getPaddingTop() + max3;
|
|
int resolveSizeAndState = View.resolveSizeAndState(Math.max(paddingRight + max2 + i8, getSuggestedMinimumWidth()), i, -16777216 & i9);
|
|
int resolveSizeAndState2 = View.resolveSizeAndState(Math.max(paddingBottom, getSuggestedMinimumHeight()), i2, i9 << 16);
|
|
if (!shouldCollapse()) {
|
|
i10 = resolveSizeAndState2;
|
|
}
|
|
setMeasuredDimension(resolveSizeAndState, i10);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onRestoreInstanceState(Parcelable parcelable) {
|
|
MenuItem findItem;
|
|
if (!(parcelable instanceof SavedState)) {
|
|
super.onRestoreInstanceState(parcelable);
|
|
return;
|
|
}
|
|
SavedState savedState = (SavedState) parcelable;
|
|
super.onRestoreInstanceState(savedState.getSuperState());
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
MenuBuilder peekMenu = actionMenuView != null ? actionMenuView.peekMenu() : null;
|
|
int i = savedState.expandedMenuItemId;
|
|
if (!(i == 0 || this.mExpandedMenuPresenter == null || peekMenu == null || (findItem = peekMenu.findItem(i)) == null)) {
|
|
findItem.expandActionView();
|
|
}
|
|
if (savedState.isOverflowOpen) {
|
|
postShowOverflowMenu();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onRtlPropertiesChanged(int i) {
|
|
super.onRtlPropertiesChanged(i);
|
|
ensureContentInsets();
|
|
RtlSpacingHelper rtlSpacingHelper = this.mContentInsets;
|
|
boolean z2 = true;
|
|
if (i != 1) {
|
|
z2 = false;
|
|
}
|
|
rtlSpacingHelper.setDirection(z2);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public Parcelable onSaveInstanceState() {
|
|
MenuItemImpl menuItemImpl;
|
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
|
ExpandedActionViewMenuPresenter expandedActionViewMenuPresenter = this.mExpandedMenuPresenter;
|
|
if (!(expandedActionViewMenuPresenter == null || (menuItemImpl = expandedActionViewMenuPresenter.mCurrentExpandedItem) == null)) {
|
|
savedState.expandedMenuItemId = menuItemImpl.getItemId();
|
|
}
|
|
savedState.isOverflowOpen = isOverflowMenuShowing();
|
|
return savedState;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
int actionMasked = motionEvent.getActionMasked();
|
|
if (actionMasked == 0) {
|
|
this.mEatingTouch = false;
|
|
}
|
|
if (!this.mEatingTouch) {
|
|
boolean onTouchEvent = super.onTouchEvent(motionEvent);
|
|
if (actionMasked == 0 && !onTouchEvent) {
|
|
this.mEatingTouch = true;
|
|
}
|
|
}
|
|
if (actionMasked == 1 || actionMasked == 3) {
|
|
this.mEatingTouch = false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void removeChildrenForExpandedActionView() {
|
|
for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
|
|
View childAt = getChildAt(childCount);
|
|
if (!(((LayoutParams) childAt.getLayoutParams()).mViewType == 2 || childAt == this.mMenuView)) {
|
|
removeViewAt(childCount);
|
|
this.mHiddenViews.add(childAt);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setCollapseContentDescription(@StringRes int i) {
|
|
setCollapseContentDescription(i != 0 ? getContext().getText(i) : null);
|
|
}
|
|
|
|
public void setCollapseContentDescription(@Nullable CharSequence charSequence) {
|
|
if (!TextUtils.isEmpty(charSequence)) {
|
|
ensureCollapseButtonView();
|
|
}
|
|
ImageButton imageButton = this.mCollapseButtonView;
|
|
if (imageButton != null) {
|
|
imageButton.setContentDescription(charSequence);
|
|
}
|
|
}
|
|
|
|
public void setCollapseIcon(@DrawableRes int i) {
|
|
setCollapseIcon(AppCompatResources.getDrawable(getContext(), i));
|
|
}
|
|
|
|
public void setCollapseIcon(@Nullable Drawable drawable) {
|
|
if (drawable != null) {
|
|
ensureCollapseButtonView();
|
|
this.mCollapseButtonView.setImageDrawable(drawable);
|
|
return;
|
|
}
|
|
ImageButton imageButton = this.mCollapseButtonView;
|
|
if (imageButton != null) {
|
|
imageButton.setImageDrawable(this.mCollapseIcon);
|
|
}
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void setCollapsible(boolean z2) {
|
|
this.mCollapsible = z2;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setContentInsetEndWithActions(int i) {
|
|
if (i < 0) {
|
|
i = Integer.MIN_VALUE;
|
|
}
|
|
if (i != this.mContentInsetEndWithActions) {
|
|
this.mContentInsetEndWithActions = i;
|
|
if (getNavigationIcon() != null) {
|
|
requestLayout();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setContentInsetStartWithNavigation(int i) {
|
|
if (i < 0) {
|
|
i = Integer.MIN_VALUE;
|
|
}
|
|
if (i != this.mContentInsetStartWithNavigation) {
|
|
this.mContentInsetStartWithNavigation = i;
|
|
if (getNavigationIcon() != null) {
|
|
requestLayout();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setContentInsetsAbsolute(int i, int i2) {
|
|
ensureContentInsets();
|
|
this.mContentInsets.setAbsolute(i, i2);
|
|
}
|
|
|
|
public void setContentInsetsRelative(int i, int i2) {
|
|
ensureContentInsets();
|
|
this.mContentInsets.setRelative(i, i2);
|
|
}
|
|
|
|
public void setLogo(@DrawableRes int i) {
|
|
setLogo(AppCompatResources.getDrawable(getContext(), i));
|
|
}
|
|
|
|
public void setLogo(Drawable drawable) {
|
|
if (drawable != null) {
|
|
ensureLogoView();
|
|
if (!isChildOrHidden(this.mLogoView)) {
|
|
addSystemView(this.mLogoView, true);
|
|
}
|
|
} else {
|
|
ImageView imageView = this.mLogoView;
|
|
if (imageView != null && isChildOrHidden(imageView)) {
|
|
removeView(this.mLogoView);
|
|
this.mHiddenViews.remove(this.mLogoView);
|
|
}
|
|
}
|
|
ImageView imageView2 = this.mLogoView;
|
|
if (imageView2 != null) {
|
|
imageView2.setImageDrawable(drawable);
|
|
}
|
|
}
|
|
|
|
public void setLogoDescription(@StringRes int i) {
|
|
setLogoDescription(getContext().getText(i));
|
|
}
|
|
|
|
public void setLogoDescription(CharSequence charSequence) {
|
|
if (!TextUtils.isEmpty(charSequence)) {
|
|
ensureLogoView();
|
|
}
|
|
ImageView imageView = this.mLogoView;
|
|
if (imageView != null) {
|
|
imageView.setContentDescription(charSequence);
|
|
}
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void setMenu(MenuBuilder menuBuilder, ActionMenuPresenter actionMenuPresenter) {
|
|
if (menuBuilder != null || this.mMenuView != null) {
|
|
ensureMenuView();
|
|
MenuBuilder peekMenu = this.mMenuView.peekMenu();
|
|
if (peekMenu != menuBuilder) {
|
|
if (peekMenu != null) {
|
|
peekMenu.removeMenuPresenter(this.mOuterActionMenuPresenter);
|
|
peekMenu.removeMenuPresenter(this.mExpandedMenuPresenter);
|
|
}
|
|
if (this.mExpandedMenuPresenter == null) {
|
|
this.mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
|
|
}
|
|
actionMenuPresenter.setExpandedActionViewsExclusive(true);
|
|
if (menuBuilder != null) {
|
|
menuBuilder.addMenuPresenter(actionMenuPresenter, this.mPopupContext);
|
|
menuBuilder.addMenuPresenter(this.mExpandedMenuPresenter, this.mPopupContext);
|
|
} else {
|
|
actionMenuPresenter.initForMenu(this.mPopupContext, null);
|
|
this.mExpandedMenuPresenter.initForMenu(this.mPopupContext, null);
|
|
actionMenuPresenter.updateMenuView(true);
|
|
this.mExpandedMenuPresenter.updateMenuView(true);
|
|
}
|
|
this.mMenuView.setPopupTheme(this.mPopupTheme);
|
|
this.mMenuView.setPresenter(actionMenuPresenter);
|
|
this.mOuterActionMenuPresenter = actionMenuPresenter;
|
|
}
|
|
}
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void setMenuCallbacks(MenuPresenter.Callback callback, MenuBuilder.Callback callback2) {
|
|
this.mActionMenuPresenterCallback = callback;
|
|
this.mMenuBuilderCallback = callback2;
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
if (actionMenuView != null) {
|
|
actionMenuView.setMenuCallbacks(callback, callback2);
|
|
}
|
|
}
|
|
|
|
public void setNavigationContentDescription(@StringRes int i) {
|
|
setNavigationContentDescription(i != 0 ? getContext().getText(i) : null);
|
|
}
|
|
|
|
public void setNavigationContentDescription(@Nullable CharSequence charSequence) {
|
|
if (!TextUtils.isEmpty(charSequence)) {
|
|
ensureNavButtonView();
|
|
}
|
|
ImageButton imageButton = this.mNavButtonView;
|
|
if (imageButton != null) {
|
|
imageButton.setContentDescription(charSequence);
|
|
}
|
|
}
|
|
|
|
public void setNavigationIcon(@DrawableRes int i) {
|
|
setNavigationIcon(AppCompatResources.getDrawable(getContext(), i));
|
|
}
|
|
|
|
public void setNavigationIcon(@Nullable Drawable drawable) {
|
|
if (drawable != null) {
|
|
ensureNavButtonView();
|
|
if (!isChildOrHidden(this.mNavButtonView)) {
|
|
addSystemView(this.mNavButtonView, true);
|
|
}
|
|
} else {
|
|
ImageButton imageButton = this.mNavButtonView;
|
|
if (imageButton != null && isChildOrHidden(imageButton)) {
|
|
removeView(this.mNavButtonView);
|
|
this.mHiddenViews.remove(this.mNavButtonView);
|
|
}
|
|
}
|
|
ImageButton imageButton2 = this.mNavButtonView;
|
|
if (imageButton2 != null) {
|
|
imageButton2.setImageDrawable(drawable);
|
|
}
|
|
}
|
|
|
|
public void setNavigationOnClickListener(View.OnClickListener onClickListener) {
|
|
ensureNavButtonView();
|
|
this.mNavButtonView.setOnClickListener(onClickListener);
|
|
}
|
|
|
|
public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) {
|
|
this.mOnMenuItemClickListener = onMenuItemClickListener;
|
|
}
|
|
|
|
public void setOverflowIcon(@Nullable Drawable drawable) {
|
|
ensureMenu();
|
|
this.mMenuView.setOverflowIcon(drawable);
|
|
}
|
|
|
|
public void setPopupTheme(@StyleRes int i) {
|
|
if (this.mPopupTheme != i) {
|
|
this.mPopupTheme = i;
|
|
if (i == 0) {
|
|
this.mPopupContext = getContext();
|
|
} else {
|
|
this.mPopupContext = new ContextThemeWrapper(getContext(), i);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setSubtitle(@StringRes int i) {
|
|
setSubtitle(getContext().getText(i));
|
|
}
|
|
|
|
public void setSubtitle(CharSequence charSequence) {
|
|
if (!TextUtils.isEmpty(charSequence)) {
|
|
if (this.mSubtitleTextView == null) {
|
|
Context context = getContext();
|
|
AppCompatTextView appCompatTextView = new AppCompatTextView(context);
|
|
this.mSubtitleTextView = appCompatTextView;
|
|
appCompatTextView.setSingleLine();
|
|
this.mSubtitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
|
int i = this.mSubtitleTextAppearance;
|
|
if (i != 0) {
|
|
this.mSubtitleTextView.setTextAppearance(context, i);
|
|
}
|
|
ColorStateList colorStateList = this.mSubtitleTextColor;
|
|
if (colorStateList != null) {
|
|
this.mSubtitleTextView.setTextColor(colorStateList);
|
|
}
|
|
}
|
|
if (!isChildOrHidden(this.mSubtitleTextView)) {
|
|
addSystemView(this.mSubtitleTextView, true);
|
|
}
|
|
} else {
|
|
TextView textView = this.mSubtitleTextView;
|
|
if (textView != null && isChildOrHidden(textView)) {
|
|
removeView(this.mSubtitleTextView);
|
|
this.mHiddenViews.remove(this.mSubtitleTextView);
|
|
}
|
|
}
|
|
TextView textView2 = this.mSubtitleTextView;
|
|
if (textView2 != null) {
|
|
textView2.setText(charSequence);
|
|
}
|
|
this.mSubtitleText = charSequence;
|
|
}
|
|
|
|
public void setSubtitleTextAppearance(Context context, @StyleRes int i) {
|
|
this.mSubtitleTextAppearance = i;
|
|
TextView textView = this.mSubtitleTextView;
|
|
if (textView != null) {
|
|
textView.setTextAppearance(context, i);
|
|
}
|
|
}
|
|
|
|
public void setSubtitleTextColor(@ColorInt int i) {
|
|
setSubtitleTextColor(ColorStateList.valueOf(i));
|
|
}
|
|
|
|
public void setSubtitleTextColor(@NonNull ColorStateList colorStateList) {
|
|
this.mSubtitleTextColor = colorStateList;
|
|
TextView textView = this.mSubtitleTextView;
|
|
if (textView != null) {
|
|
textView.setTextColor(colorStateList);
|
|
}
|
|
}
|
|
|
|
public void setTitle(@StringRes int i) {
|
|
setTitle(getContext().getText(i));
|
|
}
|
|
|
|
public void setTitle(CharSequence charSequence) {
|
|
if (!TextUtils.isEmpty(charSequence)) {
|
|
if (this.mTitleTextView == null) {
|
|
Context context = getContext();
|
|
AppCompatTextView appCompatTextView = new AppCompatTextView(context);
|
|
this.mTitleTextView = appCompatTextView;
|
|
appCompatTextView.setSingleLine();
|
|
this.mTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
|
int i = this.mTitleTextAppearance;
|
|
if (i != 0) {
|
|
this.mTitleTextView.setTextAppearance(context, i);
|
|
}
|
|
ColorStateList colorStateList = this.mTitleTextColor;
|
|
if (colorStateList != null) {
|
|
this.mTitleTextView.setTextColor(colorStateList);
|
|
}
|
|
}
|
|
if (!isChildOrHidden(this.mTitleTextView)) {
|
|
addSystemView(this.mTitleTextView, true);
|
|
}
|
|
} else {
|
|
TextView textView = this.mTitleTextView;
|
|
if (textView != null && isChildOrHidden(textView)) {
|
|
removeView(this.mTitleTextView);
|
|
this.mHiddenViews.remove(this.mTitleTextView);
|
|
}
|
|
}
|
|
TextView textView2 = this.mTitleTextView;
|
|
if (textView2 != null) {
|
|
textView2.setText(charSequence);
|
|
}
|
|
this.mTitleText = charSequence;
|
|
}
|
|
|
|
public void setTitleMargin(int i, int i2, int i3, int i4) {
|
|
this.mTitleMarginStart = i;
|
|
this.mTitleMarginTop = i2;
|
|
this.mTitleMarginEnd = i3;
|
|
this.mTitleMarginBottom = i4;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setTitleMarginBottom(int i) {
|
|
this.mTitleMarginBottom = i;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setTitleMarginEnd(int i) {
|
|
this.mTitleMarginEnd = i;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setTitleMarginStart(int i) {
|
|
this.mTitleMarginStart = i;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setTitleMarginTop(int i) {
|
|
this.mTitleMarginTop = i;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setTitleTextAppearance(Context context, @StyleRes int i) {
|
|
this.mTitleTextAppearance = i;
|
|
TextView textView = this.mTitleTextView;
|
|
if (textView != null) {
|
|
textView.setTextAppearance(context, i);
|
|
}
|
|
}
|
|
|
|
public void setTitleTextColor(@ColorInt int i) {
|
|
setTitleTextColor(ColorStateList.valueOf(i));
|
|
}
|
|
|
|
public void setTitleTextColor(@NonNull ColorStateList colorStateList) {
|
|
this.mTitleTextColor = colorStateList;
|
|
TextView textView = this.mTitleTextView;
|
|
if (textView != null) {
|
|
textView.setTextColor(colorStateList);
|
|
}
|
|
}
|
|
|
|
public boolean showOverflowMenu() {
|
|
ActionMenuView actionMenuView = this.mMenuView;
|
|
return actionMenuView != null && actionMenuView.showOverflowMenu();
|
|
}
|
|
}
|