package androidx.appcompat.view.menu; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.text.TextUtils; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.Button; import androidx.appcompat.widget.ActionMenuView; import androidx.appcompat.widget.AppCompatTextView; import o.AZJ; import o.C6286cOZ; import o.NoP; import o.SYO; import o.Sya; import o.nHL; /* loaded from: classes.dex */ public class ActionMenuItemView extends AppCompatTextView implements Sya.HBt, View.OnClickListener, ActionMenuView.HBt { private nHL a; private boolean b; private boolean c; NoP.LWm d; LWm e; private int f; private int g; private CharSequence h; private Drawable i; private int j; MenuItemImpl mItemData; /* loaded from: classes.dex */ public static abstract class LWm { public abstract AZJ e(); } @Override // o.Sya.HBt public final boolean b() { return true; } public void setCheckable(boolean z) { } public void setChecked(boolean z) { } public void setShortcut(boolean z, char c) { } public ActionMenuItemView(Context context) { this(context, null); } public ActionMenuItemView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public ActionMenuItemView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); Resources resources = context.getResources(); this.c = g(); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, SYO.ZqN.ActionMenuItemView, i, 0); this.j = obtainStyledAttributes.getDimensionPixelSize(SYO.ZqN.ActionMenuItemView_android_minWidth, 0); obtainStyledAttributes.recycle(); this.f = (int) ((resources.getDisplayMetrics().density * 32.0f) + 0.5f); setOnClickListener(this); this.g = -1; setSaveEnabled(false); } @Override // android.widget.TextView, android.view.View public void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); this.c = g(); i(); } @Override // android.widget.TextView, android.view.View public CharSequence getAccessibilityClassName() { return Button.class.getName(); } private boolean g() { Configuration configuration = getContext().getResources().getConfiguration(); int i = configuration.screenWidthDp; return i >= 480 || (i >= 640 && configuration.screenHeightDp >= 480) || configuration.orientation == 2; } @Override // android.widget.TextView, android.view.View public void setPadding(int i, int i2, int i3, int i4) { this.g = i; super.setPadding(i, i2, i3, i4); } @Override // o.Sya.HBt public final void c(MenuItemImpl menuItemImpl) { CharSequence title; this.mItemData = menuItemImpl; setIcon(menuItemImpl.getIcon()); if (b()) { title = menuItemImpl.getTitleCondensed(); } else { title = menuItemImpl.getTitle(); } setTitle(title); setId(menuItemImpl.getItemId()); setVisibility(menuItemImpl.isVisible() ? 0 : 8); setEnabled(menuItemImpl.isEnabled()); if (menuItemImpl.hasSubMenu() && this.a == null) { this.a = new IeS(this); } } @Override // android.widget.TextView, android.view.View public boolean onTouchEvent(MotionEvent motionEvent) { nHL nhl; if (this.mItemData.hasSubMenu() && (nhl = this.a) != null && nhl.onTouch(this, motionEvent)) { return true; } return super.onTouchEvent(motionEvent); } @Override // android.view.View.OnClickListener public void onClick(View view) { NoP.LWm lWm = this.d; if (lWm != null) { lWm.d(this.mItemData); } } public void setExpandedFormat(boolean z) { if (this.b != z) { this.b = z; MenuItemImpl menuItemImpl = this.mItemData; if (menuItemImpl != null) { NoP noP = menuItemImpl.e; noP.f = true; noP.c(true); } } } private void i() { boolean z = (!TextUtils.isEmpty(this.h)) & (this.i == null || ((this.mItemData.i & 4) == 4 && (this.c || this.b))); setText(z ? this.h : null); CharSequence contentDescription = this.mItemData.getContentDescription(); if (TextUtils.isEmpty(contentDescription)) { setContentDescription(z ? null : this.mItemData.getTitle()); } else { setContentDescription(contentDescription); } CharSequence tooltipText = this.mItemData.getTooltipText(); if (TextUtils.isEmpty(tooltipText)) { C6286cOZ.e(this, z ? null : this.mItemData.getTitle()); } else { C6286cOZ.e(this, tooltipText); } } public void setIcon(Drawable drawable) { this.i = drawable; if (drawable != null) { int intrinsicWidth = drawable.getIntrinsicWidth(); int intrinsicHeight = drawable.getIntrinsicHeight(); int i = this.f; if (intrinsicWidth > i) { intrinsicHeight = (int) (intrinsicHeight * (i / intrinsicWidth)); intrinsicWidth = i; } if (intrinsicHeight > i) { intrinsicWidth = (int) (intrinsicWidth * (i / intrinsicHeight)); } else { i = intrinsicHeight; } drawable.setBounds(0, 0, intrinsicWidth, i); } setCompoundDrawables(drawable, null, null, null); i(); } public void setTitle(CharSequence charSequence) { this.h = charSequence; i(); } /* loaded from: classes.dex */ class IeS extends nHL { final ActionMenuItemView c; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public IeS(ActionMenuItemView actionMenuItemView) { super(actionMenuItemView); this.c = actionMenuItemView; } @Override // o.nHL public final AZJ e() { if (this.c.e != null) { return this.c.e.e(); } return null; } @Override // o.nHL public final boolean c() { AZJ e; return this.c.d != null && this.c.d.d(this.c.mItemData) && (e = e()) != null && e.j(); } } @Override // android.widget.TextView, android.view.View public void onRestoreInstanceState(Parcelable parcelable) { super.onRestoreInstanceState(null); } @Override // androidx.appcompat.widget.ActionMenuView.HBt public final boolean d() { return !TextUtils.isEmpty(getText()); } @Override // androidx.appcompat.widget.ActionMenuView.HBt public final boolean c() { return (TextUtils.isEmpty(getText()) ^ true) && this.mItemData.getIcon() == null; } @Override // androidx.appcompat.widget.AppCompatTextView, android.widget.TextView, android.view.View public void onMeasure(int i, int i2) { int i3; boolean z = !TextUtils.isEmpty(getText()); if (z && (i3 = this.g) >= 0) { super.setPadding(i3, getPaddingTop(), getPaddingRight(), getPaddingBottom()); } super.onMeasure(i, i2); int mode = View.MeasureSpec.getMode(i); int size = View.MeasureSpec.getSize(i); int measuredWidth = getMeasuredWidth(); int min = mode == Integer.MIN_VALUE ? Math.min(size, this.j) : this.j; if (mode != 1073741824 && this.j > 0 && measuredWidth < min) { super.onMeasure(View.MeasureSpec.makeMeasureSpec(min, 1073741824), i2); } if (z || this.i == null) { return; } super.setPadding((getMeasuredWidth() - this.i.getBounds().width()) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom()); } public void setPopupCallback(LWm lWm) { this.e = lWm; } public void setItemInvoker(NoP.LWm lWm) { this.d = lWm; } @Override // o.Sya.HBt public final MenuItemImpl a() { return this.mItemData; } }