package androidx.appcompat.widget; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.AttributeSet; import android.view.ContextThemeWrapper; import android.view.KeyEvent; 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.appcompat.R$attr; import androidx.appcompat.R$styleable; 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.SubMenuBuilder; import androidx.appcompat.widget.ActionMenuView; 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; /* loaded from: classes.dex */ public class Toolbar extends ViewGroup { private int A; private int B; private boolean C; private boolean D; private final ArrayList E; private final ArrayList F; private final int[] G; OnMenuItemClickListener H; private final ActionMenuView.OnMenuItemClickListener I; private ToolbarWidgetWrapper J; private ActionMenuPresenter K; private ExpandedActionViewMenuPresenter L; private MenuPresenter.Callback M; private MenuBuilder.Callback N; private boolean O; private final Runnable P; private ActionMenuView a; private TextView b; private TextView c; private ImageButton d; private ImageView e; private Drawable f; private CharSequence g; ImageButton h; View i; private Context j; private int k; private int l; private int m; int n; private int o; private int p; private int q; private int r; private int s; private RtlSpacingHelper t; private int u; private int v; private int x; private CharSequence y; private CharSequence z; public interface OnMenuItemClickListener { boolean onMenuItemClick(MenuItem menuItem); } public static class SavedState extends AbsSavedState { public static final Parcelable.Creator CREATOR = new Parcelable.ClassLoaderCreator() { // from class: androidx.appcompat.widget.Toolbar.SavedState.1 @Override // android.os.Parcelable.Creator public SavedState[] newArray(int i) { return new SavedState[i]; } /* JADX WARN: Can't rename method to resolve collision */ @Override // android.os.Parcelable.ClassLoaderCreator public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) { return new SavedState(parcel, classLoader); } @Override // android.os.Parcelable.Creator public SavedState createFromParcel(Parcel parcel) { return new SavedState(parcel, null); } }; int expandedMenuItemId; boolean isOverflowOpen; public SavedState(Parcel parcel) { this(parcel, null); } @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 SavedState(Parcel parcel, ClassLoader classLoader) { super(parcel, classLoader); this.expandedMenuItemId = parcel.readInt(); this.isOverflowOpen = parcel.readInt() != 0; } public SavedState(Parcelable parcelable) { super(parcelable); } } public Toolbar(Context context) { this(context, null); } private MenuInflater getMenuInflater() { return new SupportMenuInflater(getContext()); } private void l() { if (this.t == null) { this.t = new RtlSpacingHelper(); } } private void m() { if (this.e == null) { this.e = new AppCompatImageView(getContext()); } } private void n() { o(); if (this.a.j() == null) { MenuBuilder menuBuilder = (MenuBuilder) this.a.getMenu(); if (this.L == null) { this.L = new ExpandedActionViewMenuPresenter(); } this.a.setExpandedActionViewsExclusive(true); menuBuilder.a(this.L, this.j); } } private void o() { if (this.a == null) { this.a = new ActionMenuView(getContext()); this.a.setPopupTheme(this.k); this.a.setOnMenuItemClickListener(this.I); this.a.a(this.M, this.N); LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams(); generateDefaultLayoutParams.a = 8388613 | (this.n & 112); this.a.setLayoutParams(generateDefaultLayoutParams); a((View) this.a, false); } } private void p() { if (this.d == null) { this.d = new AppCompatImageButton(getContext(), null, R$attr.toolbarNavigationButtonStyle); LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams(); generateDefaultLayoutParams.a = 8388611 | (this.n & 112); this.d.setLayoutParams(generateDefaultLayoutParams); } } private void q() { removeCallbacks(this.P); post(this.P); } private boolean r() { if (!this.O) { return false; } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); if (d(childAt) && childAt.getMeasuredWidth() > 0 && childAt.getMeasuredHeight() > 0) { return false; } } return true; } public void a(MenuBuilder menuBuilder, ActionMenuPresenter actionMenuPresenter) { if (menuBuilder == null && this.a == null) { return; } o(); MenuBuilder j = this.a.j(); if (j == menuBuilder) { return; } if (j != null) { j.b(this.K); j.b(this.L); } if (this.L == null) { this.L = new ExpandedActionViewMenuPresenter(); } actionMenuPresenter.b(true); if (menuBuilder != null) { menuBuilder.a(actionMenuPresenter, this.j); menuBuilder.a(this.L, this.j); } else { actionMenuPresenter.a(this.j, (MenuBuilder) null); this.L.a(this.j, (MenuBuilder) null); actionMenuPresenter.a(true); this.L.a(true); } this.a.setPopupTheme(this.k); this.a.setPresenter(actionMenuPresenter); this.K = actionMenuPresenter; } public boolean b() { ActionMenuView actionMenuView; return getVisibility() == 0 && (actionMenuView = this.a) != null && actionMenuView.i(); } public void c() { ExpandedActionViewMenuPresenter expandedActionViewMenuPresenter = this.L; MenuItemImpl menuItemImpl = expandedActionViewMenuPresenter == null ? null : expandedActionViewMenuPresenter.b; if (menuItemImpl != null) { menuItemImpl.collapseActionView(); } } @Override // android.view.ViewGroup protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) { return super.checkLayoutParams(layoutParams) && (layoutParams instanceof LayoutParams); } public void d() { ActionMenuView actionMenuView = this.a; if (actionMenuView != null) { actionMenuView.d(); } } void e() { if (this.h == null) { this.h = new AppCompatImageButton(getContext(), null, R$attr.toolbarNavigationButtonStyle); this.h.setImageDrawable(this.f); this.h.setContentDescription(this.g); LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams(); generateDefaultLayoutParams.a = 8388611 | (this.n & 112); generateDefaultLayoutParams.b = 2; this.h.setLayoutParams(generateDefaultLayoutParams); this.h.setOnClickListener(new View.OnClickListener() { // from class: androidx.appcompat.widget.Toolbar.3 @Override // android.view.View.OnClickListener public void onClick(View view) { Toolbar.this.c(); } }); } } public boolean f() { ExpandedActionViewMenuPresenter expandedActionViewMenuPresenter = this.L; return (expandedActionViewMenuPresenter == null || expandedActionViewMenuPresenter.b == null) ? false : true; } public boolean g() { ActionMenuView actionMenuView = this.a; return actionMenuView != null && actionMenuView.f(); } public int getContentInsetEnd() { RtlSpacingHelper rtlSpacingHelper = this.t; if (rtlSpacingHelper != null) { return rtlSpacingHelper.a(); } return 0; } public int getContentInsetEndWithActions() { int i = this.v; return i != Integer.MIN_VALUE ? i : getContentInsetEnd(); } public int getContentInsetLeft() { RtlSpacingHelper rtlSpacingHelper = this.t; if (rtlSpacingHelper != null) { return rtlSpacingHelper.b(); } return 0; } public int getContentInsetRight() { RtlSpacingHelper rtlSpacingHelper = this.t; if (rtlSpacingHelper != null) { return rtlSpacingHelper.c(); } return 0; } public int getContentInsetStart() { RtlSpacingHelper rtlSpacingHelper = this.t; if (rtlSpacingHelper != null) { return rtlSpacingHelper.d(); } return 0; } public int getContentInsetStartWithNavigation() { int i = this.u; return i != Integer.MIN_VALUE ? i : getContentInsetStart(); } public int getCurrentContentInsetEnd() { MenuBuilder j; ActionMenuView actionMenuView = this.a; return actionMenuView != null && (j = actionMenuView.j()) != null && j.hasVisibleItems() ? Math.max(getContentInsetEnd(), Math.max(this.v, 0)) : getContentInsetEnd(); } public int getCurrentContentInsetLeft() { return ViewCompat.k(this) == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart(); } public int getCurrentContentInsetRight() { return ViewCompat.k(this) == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd(); } public int getCurrentContentInsetStart() { return getNavigationIcon() != null ? Math.max(getContentInsetStart(), Math.max(this.u, 0)) : getContentInsetStart(); } public Drawable getLogo() { ImageView imageView = this.e; if (imageView != null) { return imageView.getDrawable(); } return null; } public CharSequence getLogoDescription() { ImageView imageView = this.e; if (imageView != null) { return imageView.getContentDescription(); } return null; } public Menu getMenu() { n(); return this.a.getMenu(); } public CharSequence getNavigationContentDescription() { ImageButton imageButton = this.d; if (imageButton != null) { return imageButton.getContentDescription(); } return null; } public Drawable getNavigationIcon() { ImageButton imageButton = this.d; if (imageButton != null) { return imageButton.getDrawable(); } return null; } ActionMenuPresenter getOuterActionMenuPresenter() { return this.K; } public Drawable getOverflowIcon() { n(); return this.a.getOverflowIcon(); } Context getPopupContext() { return this.j; } public int getPopupTheme() { return this.k; } public CharSequence getSubtitle() { return this.z; } public CharSequence getTitle() { return this.y; } public int getTitleMarginBottom() { return this.s; } public int getTitleMarginEnd() { return this.q; } public int getTitleMarginStart() { return this.p; } public int getTitleMarginTop() { return this.r; } public DecorToolbar getWrapper() { if (this.J == null) { this.J = new ToolbarWidgetWrapper(this, true); } return this.J; } public boolean h() { ActionMenuView actionMenuView = this.a; return actionMenuView != null && actionMenuView.g(); } public boolean i() { ActionMenuView actionMenuView = this.a; return actionMenuView != null && actionMenuView.h(); } void j() { for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) { View childAt = getChildAt(childCount); if (((LayoutParams) childAt.getLayoutParams()).b != 2 && childAt != this.a) { removeViewAt(childCount); this.F.add(childAt); } } } public boolean k() { ActionMenuView actionMenuView = this.a; return actionMenuView != null && actionMenuView.k(); } @Override // android.view.ViewGroup, android.view.View protected void onDetachedFromWindow() { super.onDetachedFromWindow(); removeCallbacks(this.P); } @Override // android.view.View public boolean onHoverEvent(MotionEvent motionEvent) { int actionMasked = motionEvent.getActionMasked(); if (actionMasked == 9) { this.D = false; } if (!this.D) { boolean onHoverEvent = super.onHoverEvent(motionEvent); if (actionMasked == 9 && !onHoverEvent) { this.D = true; } } if (actionMasked == 10 || actionMasked == 3) { this.D = false; } return true; } /* JADX WARN: Removed duplicated region for block: B:107:0x01a8 */ /* JADX WARN: Removed duplicated region for block: B:112:0x0137 */ /* JADX WARN: Removed duplicated region for block: B:113:0x0130 */ /* JADX WARN: Removed duplicated region for block: B:114:0x011d */ /* JADX WARN: Removed duplicated region for block: B:115:0x0100 */ /* JADX WARN: Removed duplicated region for block: B:13:0x005f */ /* JADX WARN: Removed duplicated region for block: B:18:0x0076 */ /* JADX WARN: Removed duplicated region for block: B:23:0x00b3 */ /* JADX WARN: Removed duplicated region for block: B:28:0x00ca */ /* JADX WARN: Removed duplicated region for block: B:33:0x00e7 */ /* JADX WARN: Removed duplicated region for block: B:35:0x0105 */ /* JADX WARN: Removed duplicated region for block: B:42:0x02a6 A[LOOP:0: B:41:0x02a4->B:42:0x02a6, LOOP_END] */ /* JADX WARN: Removed duplicated region for block: B:46:0x02c8 A[LOOP:1: B:45:0x02c6->B:46:0x02c8, LOOP_END] */ /* JADX WARN: Removed duplicated region for block: B:50:0x02f3 */ /* JADX WARN: Removed duplicated region for block: B:55:0x0302 A[LOOP:2: B:54:0x0300->B:55:0x0302, LOOP_END] */ /* JADX WARN: Removed duplicated region for block: B:61:0x012d */ /* JADX WARN: Removed duplicated region for block: B:63:0x0134 */ /* JADX WARN: Removed duplicated region for block: B:71:0x016a */ /* JADX WARN: Removed duplicated region for block: B:78:0x01b9 */ /* JADX WARN: Removed duplicated region for block: B:91:0x022c */ @Override // android.view.ViewGroup, android.view.View /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ protected void onLayout(boolean r20, int r21, int r22, int r23, int r24) { /* Method dump skipped, instructions count: 791 To view this dump change 'Code comments level' option to 'DEBUG' */ throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.Toolbar.onLayout(boolean, int, int, int, int):void"); } @Override // android.view.View protected void onMeasure(int i, int i2) { char c; char c2; int i3; int i4; int i5; int i6; int i7; int i8; int i9; int[] iArr = this.G; if (ViewUtils.a(this)) { c = 1; c2 = 0; } else { c = 0; c2 = 1; } if (d(this.d)) { a(this.d, i, 0, i2, 0, this.o); i3 = this.d.getMeasuredWidth() + a(this.d); i4 = Math.max(0, this.d.getMeasuredHeight() + b(this.d)); i5 = View.combineMeasuredStates(0, this.d.getMeasuredState()); } else { i3 = 0; i4 = 0; i5 = 0; } if (d(this.h)) { a(this.h, i, 0, i2, 0, this.o); i3 = this.h.getMeasuredWidth() + a(this.h); i4 = Math.max(i4, this.h.getMeasuredHeight() + b(this.h)); i5 = View.combineMeasuredStates(i5, this.h.getMeasuredState()); } int currentContentInsetStart = getCurrentContentInsetStart(); int max = 0 + Math.max(currentContentInsetStart, i3); iArr[c] = Math.max(0, currentContentInsetStart - i3); if (d(this.a)) { a(this.a, i, max, i2, 0, this.o); i6 = this.a.getMeasuredWidth() + a(this.a); i4 = Math.max(i4, this.a.getMeasuredHeight() + b(this.a)); i5 = View.combineMeasuredStates(i5, this.a.getMeasuredState()); } else { i6 = 0; } int currentContentInsetEnd = getCurrentContentInsetEnd(); int max2 = max + Math.max(currentContentInsetEnd, i6); iArr[c2] = Math.max(0, currentContentInsetEnd - i6); if (d(this.i)) { max2 += a(this.i, i, max2, i2, 0, iArr); i4 = Math.max(i4, this.i.getMeasuredHeight() + b(this.i)); i5 = View.combineMeasuredStates(i5, this.i.getMeasuredState()); } if (d(this.e)) { max2 += a(this.e, i, max2, i2, 0, iArr); i4 = Math.max(i4, this.e.getMeasuredHeight() + b(this.e)); i5 = View.combineMeasuredStates(i5, this.e.getMeasuredState()); } int childCount = getChildCount(); int i10 = i4; int i11 = max2; for (int i12 = 0; i12 < childCount; i12++) { View childAt = getChildAt(i12); if (((LayoutParams) childAt.getLayoutParams()).b == 0 && d(childAt)) { i11 += a(childAt, i, i11, i2, 0, iArr); i10 = Math.max(i10, childAt.getMeasuredHeight() + b(childAt)); i5 = View.combineMeasuredStates(i5, childAt.getMeasuredState()); } } int i13 = this.r + this.s; int i14 = this.p + this.q; if (d(this.b)) { a(this.b, i, i11 + i14, i2, i13, iArr); int measuredWidth = this.b.getMeasuredWidth() + a(this.b); i9 = this.b.getMeasuredHeight() + b(this.b); i7 = View.combineMeasuredStates(i5, this.b.getMeasuredState()); i8 = measuredWidth; } else { i7 = i5; i8 = 0; i9 = 0; } if (d(this.c)) { i8 = Math.max(i8, a(this.c, i, i11 + i14, i2, i9 + i13, iArr)); i9 += this.c.getMeasuredHeight() + b(this.c); i7 = View.combineMeasuredStates(i7, this.c.getMeasuredState()); } int max3 = Math.max(i10, i9); int paddingLeft = i11 + i8 + getPaddingLeft() + getPaddingRight(); int paddingTop = max3 + getPaddingTop() + getPaddingBottom(); int resolveSizeAndState = View.resolveSizeAndState(Math.max(paddingLeft, getSuggestedMinimumWidth()), i, (-16777216) & i7); int resolveSizeAndState2 = View.resolveSizeAndState(Math.max(paddingTop, getSuggestedMinimumHeight()), i2, i7 << 16); if (r()) { resolveSizeAndState2 = 0; } setMeasuredDimension(resolveSizeAndState, resolveSizeAndState2); } @Override // android.view.View protected 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.a; MenuBuilder j = actionMenuView != null ? actionMenuView.j() : null; int i = savedState.expandedMenuItemId; if (i != 0 && this.L != null && j != null && (findItem = j.findItem(i)) != null) { findItem.expandActionView(); } if (savedState.isOverflowOpen) { q(); } } @Override // android.view.View public void onRtlPropertiesChanged(int i) { if (Build.VERSION.SDK_INT >= 17) { super.onRtlPropertiesChanged(i); } l(); this.t.a(i == 1); } @Override // android.view.View protected Parcelable onSaveInstanceState() { MenuItemImpl menuItemImpl; SavedState savedState = new SavedState(super.onSaveInstanceState()); ExpandedActionViewMenuPresenter expandedActionViewMenuPresenter = this.L; if (expandedActionViewMenuPresenter != null && (menuItemImpl = expandedActionViewMenuPresenter.b) != null) { savedState.expandedMenuItemId = menuItemImpl.getItemId(); } savedState.isOverflowOpen = i(); return savedState; } @Override // android.view.View public boolean onTouchEvent(MotionEvent motionEvent) { int actionMasked = motionEvent.getActionMasked(); if (actionMasked == 0) { this.C = false; } if (!this.C) { boolean onTouchEvent = super.onTouchEvent(motionEvent); if (actionMasked == 0 && !onTouchEvent) { this.C = true; } } if (actionMasked == 1 || actionMasked == 3) { this.C = false; } return true; } public void setCollapsible(boolean z) { this.O = z; requestLayout(); } public void setContentInsetEndWithActions(int i) { if (i < 0) { i = Integer.MIN_VALUE; } if (i != this.v) { this.v = i; if (getNavigationIcon() != null) { requestLayout(); } } } public void setContentInsetStartWithNavigation(int i) { if (i < 0) { i = Integer.MIN_VALUE; } if (i != this.u) { this.u = i; if (getNavigationIcon() != null) { requestLayout(); } } } public void setLogo(int i) { setLogo(AppCompatResources.c(getContext(), i)); } public void setLogoDescription(int i) { setLogoDescription(getContext().getText(i)); } public void setNavigationContentDescription(int i) { setNavigationContentDescription(i != 0 ? getContext().getText(i) : null); } public void setNavigationIcon(int i) { setNavigationIcon(AppCompatResources.c(getContext(), i)); } public void setNavigationOnClickListener(View.OnClickListener onClickListener) { p(); this.d.setOnClickListener(onClickListener); } public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) { this.H = onMenuItemClickListener; } public void setOverflowIcon(Drawable drawable) { n(); this.a.setOverflowIcon(drawable); } public void setPopupTheme(int i) { if (this.k != i) { this.k = i; if (i == 0) { this.j = getContext(); } else { this.j = new ContextThemeWrapper(getContext(), i); } } } public void setSubtitle(int i) { setSubtitle(getContext().getText(i)); } public void setSubtitleTextColor(int i) { this.B = i; TextView textView = this.c; if (textView != null) { textView.setTextColor(i); } } public void setTitle(int i) { setTitle(getContext().getText(i)); } public void setTitleMarginBottom(int i) { this.s = i; requestLayout(); } public void setTitleMarginEnd(int i) { this.q = i; requestLayout(); } public void setTitleMarginStart(int i) { this.p = i; requestLayout(); } public void setTitleMarginTop(int i) { this.r = i; requestLayout(); } public void setTitleTextColor(int i) { this.A = i; TextView textView = this.b; if (textView != null) { textView.setTextColor(i); } } public static class LayoutParams extends ActionBar.LayoutParams { int b; public LayoutParams(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.b = 0; } void a(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 LayoutParams(int i, int i2) { super(i, i2); this.b = 0; this.a = 8388627; } public LayoutParams(LayoutParams layoutParams) { super((ActionBar.LayoutParams) layoutParams); this.b = 0; this.b = layoutParams.b; } public LayoutParams(ActionBar.LayoutParams layoutParams) { super(layoutParams); this.b = 0; } public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) { super(marginLayoutParams); this.b = 0; a(marginLayoutParams); } public LayoutParams(ViewGroup.LayoutParams layoutParams) { super(layoutParams); this.b = 0; } } public Toolbar(Context context, AttributeSet attributeSet) { this(context, attributeSet, R$attr.toolbarStyle); } public void b(Context context, int i) { this.l = i; TextView textView = this.b; if (textView != null) { textView.setTextAppearance(context, i); } } /* JADX INFO: Access modifiers changed from: protected */ @Override // android.view.ViewGroup public LayoutParams generateDefaultLayoutParams() { return new LayoutParams(-2, -2); } public void setLogo(Drawable drawable) { if (drawable != null) { m(); if (!c(this.e)) { a((View) this.e, true); } } else { ImageView imageView = this.e; if (imageView != null && c(imageView)) { removeView(this.e); this.F.remove(this.e); } } ImageView imageView2 = this.e; if (imageView2 != null) { imageView2.setImageDrawable(drawable); } } public void setLogoDescription(CharSequence charSequence) { if (!TextUtils.isEmpty(charSequence)) { m(); } ImageView imageView = this.e; if (imageView != null) { imageView.setContentDescription(charSequence); } } public void setNavigationContentDescription(CharSequence charSequence) { if (!TextUtils.isEmpty(charSequence)) { p(); } ImageButton imageButton = this.d; if (imageButton != null) { imageButton.setContentDescription(charSequence); } } public void setNavigationIcon(Drawable drawable) { if (drawable != null) { p(); if (!c(this.d)) { a((View) this.d, true); } } else { ImageButton imageButton = this.d; if (imageButton != null && c(imageButton)) { removeView(this.d); this.F.remove(this.d); } } ImageButton imageButton2 = this.d; if (imageButton2 != null) { imageButton2.setImageDrawable(drawable); } } public void setSubtitle(CharSequence charSequence) { if (TextUtils.isEmpty(charSequence)) { TextView textView = this.c; if (textView != null && c(textView)) { removeView(this.c); this.F.remove(this.c); } } else { if (this.c == null) { Context context = getContext(); this.c = new AppCompatTextView(context); this.c.setSingleLine(); this.c.setEllipsize(TextUtils.TruncateAt.END); int i = this.m; if (i != 0) { this.c.setTextAppearance(context, i); } int i2 = this.B; if (i2 != 0) { this.c.setTextColor(i2); } } if (!c(this.c)) { a((View) this.c, true); } } TextView textView2 = this.c; if (textView2 != null) { textView2.setText(charSequence); } this.z = charSequence; } public void setTitle(CharSequence charSequence) { if (TextUtils.isEmpty(charSequence)) { TextView textView = this.b; if (textView != null && c(textView)) { removeView(this.b); this.F.remove(this.b); } } else { if (this.b == null) { Context context = getContext(); this.b = new AppCompatTextView(context); this.b.setSingleLine(); this.b.setEllipsize(TextUtils.TruncateAt.END); int i = this.l; if (i != 0) { this.b.setTextAppearance(context, i); } int i2 = this.A; if (i2 != 0) { this.b.setTextColor(i2); } } if (!c(this.b)) { a((View) this.b, true); } } TextView textView2 = this.b; if (textView2 != null) { textView2.setText(charSequence); } this.y = charSequence; } private class ExpandedActionViewMenuPresenter implements MenuPresenter { MenuBuilder a; MenuItemImpl b; ExpandedActionViewMenuPresenter() { } @Override // androidx.appcompat.view.menu.MenuPresenter public void a(Context context, MenuBuilder menuBuilder) { MenuItemImpl menuItemImpl; MenuBuilder menuBuilder2 = this.a; if (menuBuilder2 != null && (menuItemImpl = this.b) != null) { menuBuilder2.a(menuItemImpl); } this.a = menuBuilder; } @Override // androidx.appcompat.view.menu.MenuPresenter public void a(MenuBuilder menuBuilder, boolean z) { } @Override // androidx.appcompat.view.menu.MenuPresenter public boolean a(SubMenuBuilder subMenuBuilder) { return false; } @Override // androidx.appcompat.view.menu.MenuPresenter public boolean b() { return false; } @Override // androidx.appcompat.view.menu.MenuPresenter public boolean b(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { Toolbar.this.e(); ViewParent parent = Toolbar.this.h.getParent(); Toolbar toolbar = Toolbar.this; if (parent != toolbar) { if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(toolbar.h); } Toolbar toolbar2 = Toolbar.this; toolbar2.addView(toolbar2.h); } Toolbar.this.i = menuItemImpl.getActionView(); this.b = menuItemImpl; ViewParent parent2 = Toolbar.this.i.getParent(); Toolbar toolbar3 = Toolbar.this; if (parent2 != toolbar3) { if (parent2 instanceof ViewGroup) { ((ViewGroup) parent2).removeView(toolbar3.i); } LayoutParams generateDefaultLayoutParams = Toolbar.this.generateDefaultLayoutParams(); Toolbar toolbar4 = Toolbar.this; generateDefaultLayoutParams.a = 8388611 | (toolbar4.n & 112); generateDefaultLayoutParams.b = 2; toolbar4.i.setLayoutParams(generateDefaultLayoutParams); Toolbar toolbar5 = Toolbar.this; toolbar5.addView(toolbar5.i); } Toolbar.this.j(); Toolbar.this.requestLayout(); menuItemImpl.a(true); KeyEvent.Callback callback = Toolbar.this.i; if (callback instanceof CollapsibleActionView) { ((CollapsibleActionView) callback).b(); } return true; } @Override // androidx.appcompat.view.menu.MenuPresenter public void a(boolean z) { if (this.b != null) { MenuBuilder menuBuilder = this.a; boolean z2 = false; if (menuBuilder != null) { int size = menuBuilder.size(); int i = 0; while (true) { if (i >= size) { break; } if (this.a.getItem(i) == this.b) { z2 = true; break; } i++; } } if (z2) { return; } a(this.a, this.b); } } @Override // androidx.appcompat.view.menu.MenuPresenter public boolean a(MenuBuilder menuBuilder, MenuItemImpl menuItemImpl) { KeyEvent.Callback callback = Toolbar.this.i; if (callback instanceof CollapsibleActionView) { ((CollapsibleActionView) callback).c(); } Toolbar toolbar = Toolbar.this; toolbar.removeView(toolbar.i); Toolbar toolbar2 = Toolbar.this; toolbar2.removeView(toolbar2.h); Toolbar toolbar3 = Toolbar.this; toolbar3.i = null; toolbar3.a(); this.b = null; Toolbar.this.requestLayout(); menuItemImpl.a(false); return true; } } public Toolbar(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.x = 8388627; this.E = new ArrayList<>(); this.F = new ArrayList<>(); this.G = new int[2]; this.I = new ActionMenuView.OnMenuItemClickListener() { // from class: androidx.appcompat.widget.Toolbar.1 @Override // androidx.appcompat.widget.ActionMenuView.OnMenuItemClickListener public boolean onMenuItemClick(MenuItem menuItem) { OnMenuItemClickListener onMenuItemClickListener = Toolbar.this.H; if (onMenuItemClickListener != null) { return onMenuItemClickListener.onMenuItemClick(menuItem); } return false; } }; this.P = new Runnable() { // from class: androidx.appcompat.widget.Toolbar.2 @Override // java.lang.Runnable public void run() { Toolbar.this.k(); } }; TintTypedArray a = TintTypedArray.a(getContext(), attributeSet, R$styleable.Toolbar, i, 0); this.l = a.g(R$styleable.Toolbar_titleTextAppearance, 0); this.m = a.g(R$styleable.Toolbar_subtitleTextAppearance, 0); this.x = a.e(R$styleable.Toolbar_android_gravity, this.x); this.n = a.e(R$styleable.Toolbar_buttonGravity, 48); int b = a.b(R$styleable.Toolbar_titleMargin, 0); b = a.g(R$styleable.Toolbar_titleMargins) ? a.b(R$styleable.Toolbar_titleMargins, b) : b; this.s = b; this.r = b; this.q = b; this.p = b; int b2 = a.b(R$styleable.Toolbar_titleMarginStart, -1); if (b2 >= 0) { this.p = b2; } int b3 = a.b(R$styleable.Toolbar_titleMarginEnd, -1); if (b3 >= 0) { this.q = b3; } int b4 = a.b(R$styleable.Toolbar_titleMarginTop, -1); if (b4 >= 0) { this.r = b4; } int b5 = a.b(R$styleable.Toolbar_titleMarginBottom, -1); if (b5 >= 0) { this.s = b5; } this.o = a.c(R$styleable.Toolbar_maxButtonHeight, -1); int b6 = a.b(R$styleable.Toolbar_contentInsetStart, Integer.MIN_VALUE); int b7 = a.b(R$styleable.Toolbar_contentInsetEnd, Integer.MIN_VALUE); int c = a.c(R$styleable.Toolbar_contentInsetLeft, 0); int c2 = a.c(R$styleable.Toolbar_contentInsetRight, 0); l(); this.t.a(c, c2); if (b6 != Integer.MIN_VALUE || b7 != Integer.MIN_VALUE) { this.t.b(b6, b7); } this.u = a.b(R$styleable.Toolbar_contentInsetStartWithNavigation, Integer.MIN_VALUE); this.v = a.b(R$styleable.Toolbar_contentInsetEndWithActions, Integer.MIN_VALUE); this.f = a.b(R$styleable.Toolbar_collapseIcon); this.g = a.e(R$styleable.Toolbar_collapseContentDescription); CharSequence e = a.e(R$styleable.Toolbar_title); if (!TextUtils.isEmpty(e)) { setTitle(e); } CharSequence e2 = a.e(R$styleable.Toolbar_subtitle); if (!TextUtils.isEmpty(e2)) { setSubtitle(e2); } this.j = getContext(); setPopupTheme(a.g(R$styleable.Toolbar_popupTheme, 0)); Drawable b8 = a.b(R$styleable.Toolbar_navigationIcon); if (b8 != null) { setNavigationIcon(b8); } CharSequence e3 = a.e(R$styleable.Toolbar_navigationContentDescription); if (!TextUtils.isEmpty(e3)) { setNavigationContentDescription(e3); } Drawable b9 = a.b(R$styleable.Toolbar_logo); if (b9 != null) { setLogo(b9); } CharSequence e4 = a.e(R$styleable.Toolbar_logoDescription); if (!TextUtils.isEmpty(e4)) { setLogoDescription(e4); } if (a.g(R$styleable.Toolbar_titleTextColor)) { setTitleTextColor(a.a(R$styleable.Toolbar_titleTextColor, -1)); } if (a.g(R$styleable.Toolbar_subtitleTextColor)) { setSubtitleTextColor(a.a(R$styleable.Toolbar_subtitleTextColor, -1)); } a.a(); } private boolean c(View view) { return view.getParent() == this || this.F.contains(view); } private boolean d(View view) { return (view == null || view.getParent() != this || view.getVisibility() == 8) ? false : true; } @Override // android.view.ViewGroup public LayoutParams generateLayoutParams(AttributeSet attributeSet) { return new LayoutParams(getContext(), attributeSet); } /* JADX INFO: Access modifiers changed from: protected */ @Override // android.view.ViewGroup public LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) { if (layoutParams instanceof LayoutParams) { return new LayoutParams((LayoutParams) layoutParams); } if (layoutParams instanceof ActionBar.LayoutParams) { return new LayoutParams((ActionBar.LayoutParams) layoutParams); } if (layoutParams instanceof ViewGroup.MarginLayoutParams) { return new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams); } return new LayoutParams(layoutParams); } private int b(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 a = a(view, i2); int measuredWidth = view.getMeasuredWidth(); view.layout(max - measuredWidth, a, max, view.getMeasuredHeight() + a); return max - (measuredWidth + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin); } private int b(int i) { int i2 = i & 112; return (i2 == 16 || i2 == 48 || i2 == 80) ? i2 : this.x & 112; } private int b(View view) { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin; } public void a(Context context, int i) { this.m = i; TextView textView = this.c; if (textView != null) { textView.setTextAppearance(context, i); } } public void a(int i, int i2) { l(); this.t.b(i, i2); } private void a(View view, boolean z) { LayoutParams layoutParams; ViewGroup.LayoutParams layoutParams2 = view.getLayoutParams(); if (layoutParams2 == null) { layoutParams = generateDefaultLayoutParams(); } else if (!checkLayoutParams(layoutParams2)) { layoutParams = generateLayoutParams(layoutParams2); } else { layoutParams = (LayoutParams) layoutParams2; } layoutParams.b = 1; if (z && this.i != null) { view.setLayoutParams(layoutParams); this.F.add(view); } else { addView(view, layoutParams); } } private void a(View view, int i, int i2, int i3, int i4, int i5) { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); int childMeasureSpec = ViewGroup.getChildMeasureSpec(i, getPaddingLeft() + getPaddingRight() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i2, marginLayoutParams.width); int childMeasureSpec2 = ViewGroup.getChildMeasureSpec(i3, getPaddingTop() + getPaddingBottom() + 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, 1073741824); } view.measure(childMeasureSpec, childMeasureSpec2); } private int a(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, i5) + Math.max(0, i6); iArr[0] = Math.max(0, -i5); iArr[1] = Math.max(0, -i6); view.measure(ViewGroup.getChildMeasureSpec(i, getPaddingLeft() + getPaddingRight() + max + i2, marginLayoutParams.width), ViewGroup.getChildMeasureSpec(i3, getPaddingTop() + getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i4, marginLayoutParams.height)); return view.getMeasuredWidth() + max; } private int a(List list, int[] iArr) { int i = iArr[0]; int i2 = iArr[1]; int size = list.size(); int i3 = i2; int i4 = i; int i5 = 0; int i6 = 0; while (i5 < size) { View view = list.get(i5); LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); int i7 = ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin - i4; int i8 = ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin - i3; int max = Math.max(0, i7); int max2 = Math.max(0, i8); int max3 = Math.max(0, -i7); int max4 = Math.max(0, -i8); i6 += max + view.getMeasuredWidth() + max2; i5++; i3 = max4; i4 = max3; } return i6; } private int a(View view, int i, int[] iArr, int i2) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); int i3 = ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin - iArr[0]; int max = i + Math.max(0, i3); iArr[0] = Math.max(0, -i3); int a = a(view, i2); int measuredWidth = view.getMeasuredWidth(); view.layout(max, a, max + measuredWidth, view.getMeasuredHeight() + a); return max + measuredWidth + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin; } private int a(View view, int i) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); int measuredHeight = view.getMeasuredHeight(); int i2 = i > 0 ? (measuredHeight - i) / 2 : 0; int b = b(layoutParams.a); if (b == 48) { return getPaddingTop() - i2; } if (b != 80) { 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; } return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin) - i2; } private void a(List list, int i) { boolean z = ViewCompat.k(this) == 1; int childCount = getChildCount(); int a = GravityCompat.a(i, ViewCompat.k(this)); list.clear(); if (!z) { for (int i2 = 0; i2 < childCount; i2++) { View childAt = getChildAt(i2); LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.b == 0 && d(childAt) && a(layoutParams.a) == a) { list.add(childAt); } } return; } for (int i3 = childCount - 1; i3 >= 0; i3--) { View childAt2 = getChildAt(i3); LayoutParams layoutParams2 = (LayoutParams) childAt2.getLayoutParams(); if (layoutParams2.b == 0 && d(childAt2) && a(layoutParams2.a) == a) { list.add(childAt2); } } } private int a(int i) { int k = ViewCompat.k(this); int a = GravityCompat.a(i, k) & 7; return (a == 1 || a == 3 || a == 5) ? a : k == 1 ? 5 : 3; } private int a(View view) { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); return MarginLayoutParamsCompat.b(marginLayoutParams) + MarginLayoutParamsCompat.a(marginLayoutParams); } void a() { for (int size = this.F.size() - 1; size >= 0; size--) { addView(this.F.get(size)); } this.F.clear(); } public void a(MenuPresenter.Callback callback, MenuBuilder.Callback callback2) { this.M = callback; this.N = callback2; ActionMenuView actionMenuView = this.a; if (actionMenuView != null) { actionMenuView.a(callback, callback2); } } }