package com.google.android.material.internal; import android.R; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.util.AttributeSet; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.CheckedTextView; import android.widget.FrameLayout; import android.widget.LinearLayout; import androidx.appcompat.view.menu.k; import androidx.appcompat.widget.l2; import androidx.appcompat.widget.n1; import androidx.core.view.n0; import androidx.core.widget.t; import z.a0; /* loaded from: classes2.dex */ public class NavigationMenuItemView extends d implements k.a { private static final int[] F = {R.attr.state_checked}; private androidx.appcompat.view.menu.g A; private ColorStateList B; private boolean C; private Drawable D; private final androidx.core.view.a E; /* renamed from: v, reason: collision with root package name */ private int f4583v; /* renamed from: w, reason: collision with root package name */ private boolean f4584w; /* renamed from: x, reason: collision with root package name */ boolean f4585x; /* renamed from: y, reason: collision with root package name */ private final CheckedTextView f4586y; /* renamed from: z, reason: collision with root package name */ private FrameLayout f4587z; class a extends androidx.core.view.a { a() { } @Override // androidx.core.view.a public void g(View view, a0 a0Var) { super.g(view, a0Var); a0Var.U(NavigationMenuItemView.this.f4585x); } } public NavigationMenuItemView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } private void B() { if (D()) { this.f4586y.setVisibility(8); FrameLayout frameLayout = this.f4587z; if (frameLayout != null) { n1.a aVar = (n1.a) frameLayout.getLayoutParams(); ((LinearLayout.LayoutParams) aVar).width = -1; this.f4587z.setLayoutParams(aVar); return; } return; } this.f4586y.setVisibility(0); FrameLayout frameLayout2 = this.f4587z; if (frameLayout2 != null) { n1.a aVar2 = (n1.a) frameLayout2.getLayoutParams(); ((LinearLayout.LayoutParams) aVar2).width = -2; this.f4587z.setLayoutParams(aVar2); } } private StateListDrawable C() { TypedValue typedValue = new TypedValue(); if (!getContext().getTheme().resolveAttribute(d.a.f8697s, typedValue, true)) { return null; } StateListDrawable stateListDrawable = new StateListDrawable(); stateListDrawable.addState(F, new ColorDrawable(typedValue.data)); stateListDrawable.addState(ViewGroup.EMPTY_STATE_SET, new ColorDrawable(0)); return stateListDrawable; } private boolean D() { return this.A.getTitle() == null && this.A.getIcon() == null && this.A.getActionView() != null; } private void setActionView(View view) { if (view != null) { if (this.f4587z == null) { this.f4587z = (FrameLayout) ((ViewStub) findViewById(c3.e.f3503c)).inflate(); } this.f4587z.removeAllViews(); this.f4587z.addView(view); } } @Override // androidx.appcompat.view.menu.k.a public boolean d() { return false; } @Override // androidx.appcompat.view.menu.k.a public void e(androidx.appcompat.view.menu.g gVar, int i10) { this.A = gVar; setVisibility(gVar.isVisible() ? 0 : 8); if (getBackground() == null) { n0.q0(this, C()); } setCheckable(gVar.isCheckable()); setChecked(gVar.isChecked()); setEnabled(gVar.isEnabled()); setTitle(gVar.getTitle()); setIcon(gVar.getIcon()); setActionView(gVar.getActionView()); setContentDescription(gVar.getContentDescription()); l2.a(this, gVar.getTooltipText()); B(); } @Override // androidx.appcompat.view.menu.k.a public androidx.appcompat.view.menu.g getItemData() { return this.A; } @Override // android.view.ViewGroup, android.view.View protected int[] onCreateDrawableState(int i10) { int[] onCreateDrawableState = super.onCreateDrawableState(i10 + 1); androidx.appcompat.view.menu.g gVar = this.A; if (gVar != null && gVar.isCheckable() && this.A.isChecked()) { View.mergeDrawableStates(onCreateDrawableState, F); } return onCreateDrawableState; } public void setCheckable(boolean z10) { refreshDrawableState(); if (this.f4585x != z10) { this.f4585x = z10; this.E.l(this.f4586y, 2048); } } public void setChecked(boolean z10) { refreshDrawableState(); this.f4586y.setChecked(z10); } public void setHorizontalPadding(int i10) { setPadding(i10, 0, i10, 0); } public void setIcon(Drawable drawable) { if (drawable != null) { if (this.C) { Drawable.ConstantState constantState = drawable.getConstantState(); if (constantState != null) { drawable = constantState.newDrawable(); } drawable = r.c.r(drawable).mutate(); r.c.o(drawable, this.B); } int i10 = this.f4583v; drawable.setBounds(0, 0, i10, i10); } else if (this.f4584w) { if (this.D == null) { Drawable d10 = p.h.d(getResources(), c3.d.f3500g, getContext().getTheme()); this.D = d10; if (d10 != null) { int i11 = this.f4583v; d10.setBounds(0, 0, i11, i11); } } drawable = this.D; } t.i(this.f4586y, drawable, null, null, null); } public void setIconPadding(int i10) { this.f4586y.setCompoundDrawablePadding(i10); } public void setIconSize(int i10) { this.f4583v = i10; } void setIconTintList(ColorStateList colorStateList) { this.B = colorStateList; this.C = colorStateList != null; androidx.appcompat.view.menu.g gVar = this.A; if (gVar != null) { setIcon(gVar.getIcon()); } } public void setMaxLines(int i10) { this.f4586y.setMaxLines(i10); } public void setNeedsEmptyIcon(boolean z10) { this.f4584w = z10; } public void setTextAppearance(int i10) { t.n(this.f4586y, i10); } public void setTextColor(ColorStateList colorStateList) { this.f4586y.setTextColor(colorStateList); } public void setTitle(CharSequence charSequence) { this.f4586y.setText(charSequence); } public NavigationMenuItemView(Context context, AttributeSet attributeSet, int i10) { super(context, attributeSet, i10); a aVar = new a(); this.E = aVar; setOrientation(0); LayoutInflater.from(context).inflate(c3.g.f3525a, (ViewGroup) this, true); setIconSize(context.getResources().getDimensionPixelSize(c3.c.f3473b)); CheckedTextView checkedTextView = (CheckedTextView) findViewById(c3.e.f3504d); this.f4586y = checkedTextView; checkedTextView.setDuplicateParentStateEnabled(true); n0.n0(checkedTextView, aVar); } }