package androidx.appcompat.view.menu; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.content.res.Resources; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.ActionProvider; import android.view.ContextMenu; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.SubMenu; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.widget.LinearLayout; import androidx.appcompat.view.menu.k; import androidx.core.view.b; import com.google.android.gms.ads.RequestConfiguration; /* loaded from: classes.dex */ public final class g implements s.b { private View A; private androidx.core.view.b B; private MenuItem.OnActionExpandListener C; private ContextMenu.ContextMenuInfo E; /* renamed from: a, reason: collision with root package name */ private final int f636a; /* renamed from: b, reason: collision with root package name */ private final int f637b; /* renamed from: c, reason: collision with root package name */ private final int f638c; /* renamed from: d, reason: collision with root package name */ private final int f639d; /* renamed from: e, reason: collision with root package name */ private CharSequence f640e; /* renamed from: f, reason: collision with root package name */ private CharSequence f641f; /* renamed from: g, reason: collision with root package name */ private Intent f642g; /* renamed from: h, reason: collision with root package name */ private char f643h; /* renamed from: j, reason: collision with root package name */ private char f645j; /* renamed from: l, reason: collision with root package name */ private Drawable f647l; /* renamed from: n, reason: collision with root package name */ e f649n; /* renamed from: o, reason: collision with root package name */ private m f650o; /* renamed from: p, reason: collision with root package name */ private Runnable f651p; /* renamed from: q, reason: collision with root package name */ private MenuItem.OnMenuItemClickListener f652q; /* renamed from: r, reason: collision with root package name */ private CharSequence f653r; /* renamed from: s, reason: collision with root package name */ private CharSequence f654s; /* renamed from: z, reason: collision with root package name */ private int f661z; /* renamed from: i, reason: collision with root package name */ private int f644i = 4096; /* renamed from: k, reason: collision with root package name */ private int f646k = 4096; /* renamed from: m, reason: collision with root package name */ private int f648m = 0; /* renamed from: t, reason: collision with root package name */ private ColorStateList f655t = null; /* renamed from: u, reason: collision with root package name */ private PorterDuff.Mode f656u = null; /* renamed from: v, reason: collision with root package name */ private boolean f657v = false; /* renamed from: w, reason: collision with root package name */ private boolean f658w = false; /* renamed from: x, reason: collision with root package name */ private boolean f659x = false; /* renamed from: y, reason: collision with root package name */ private int f660y = 16; private boolean D = false; class a implements b.InterfaceC0020b { a() { } @Override // androidx.core.view.b.InterfaceC0020b public void onActionProviderVisibilityChanged(boolean z10) { g gVar = g.this; gVar.f649n.J(gVar); } } g(e eVar, int i10, int i11, int i12, int i13, CharSequence charSequence, int i14) { this.f649n = eVar; this.f636a = i11; this.f637b = i10; this.f638c = i12; this.f639d = i13; this.f640e = charSequence; this.f661z = i14; } private static void d(StringBuilder sb, int i10, int i11, String str) { if ((i10 & i11) == i11) { sb.append(str); } } private Drawable e(Drawable drawable) { if (drawable != null && this.f659x && (this.f657v || this.f658w)) { drawable = r.c.r(drawable).mutate(); if (this.f657v) { r.c.o(drawable, this.f655t); } if (this.f658w) { r.c.p(drawable, this.f656u); } this.f659x = false; } return drawable; } boolean A() { return this.f649n.H() && g() != 0; } public boolean B() { return (this.f661z & 4) == 4; } @Override // s.b public s.b a(androidx.core.view.b bVar) { androidx.core.view.b bVar2 = this.B; if (bVar2 != null) { bVar2.g(); } this.A = null; this.B = bVar; this.f649n.K(true); androidx.core.view.b bVar3 = this.B; if (bVar3 != null) { bVar3.i(new a()); } return this; } @Override // s.b public androidx.core.view.b b() { return this.B; } public void c() { this.f649n.I(this); } @Override // s.b, android.view.MenuItem public boolean collapseActionView() { if ((this.f661z & 8) == 0) { return false; } if (this.A == null) { return true; } MenuItem.OnActionExpandListener onActionExpandListener = this.C; if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionCollapse(this)) { return this.f649n.f(this); } return false; } @Override // s.b, android.view.MenuItem public boolean expandActionView() { if (!j()) { return false; } MenuItem.OnActionExpandListener onActionExpandListener = this.C; if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionExpand(this)) { return this.f649n.k(this); } return false; } public int f() { return this.f639d; } char g() { return this.f649n.G() ? this.f645j : this.f643h; } @Override // android.view.MenuItem public ActionProvider getActionProvider() { throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.getActionProvider()"); } @Override // s.b, android.view.MenuItem public View getActionView() { View view = this.A; if (view != null) { return view; } androidx.core.view.b bVar = this.B; if (bVar == null) { return null; } View c10 = bVar.c(this); this.A = c10; return c10; } @Override // s.b, android.view.MenuItem public int getAlphabeticModifiers() { return this.f646k; } @Override // android.view.MenuItem public char getAlphabeticShortcut() { return this.f645j; } @Override // s.b, android.view.MenuItem public CharSequence getContentDescription() { return this.f653r; } @Override // android.view.MenuItem public int getGroupId() { return this.f637b; } @Override // android.view.MenuItem public Drawable getIcon() { Drawable drawable = this.f647l; if (drawable != null) { return e(drawable); } if (this.f648m == 0) { return null; } Drawable d10 = e.b.d(this.f649n.u(), this.f648m); this.f648m = 0; this.f647l = d10; return e(d10); } @Override // s.b, android.view.MenuItem public ColorStateList getIconTintList() { return this.f655t; } @Override // s.b, android.view.MenuItem public PorterDuff.Mode getIconTintMode() { return this.f656u; } @Override // android.view.MenuItem public Intent getIntent() { return this.f642g; } @Override // android.view.MenuItem public int getItemId() { return this.f636a; } @Override // android.view.MenuItem public ContextMenu.ContextMenuInfo getMenuInfo() { return this.E; } @Override // s.b, android.view.MenuItem public int getNumericModifiers() { return this.f644i; } @Override // android.view.MenuItem public char getNumericShortcut() { return this.f643h; } @Override // android.view.MenuItem public int getOrder() { return this.f638c; } @Override // android.view.MenuItem public SubMenu getSubMenu() { return this.f650o; } @Override // android.view.MenuItem public CharSequence getTitle() { return this.f640e; } @Override // android.view.MenuItem public CharSequence getTitleCondensed() { CharSequence charSequence = this.f641f; return charSequence != null ? charSequence : this.f640e; } @Override // s.b, android.view.MenuItem public CharSequence getTooltipText() { return this.f654s; } String h() { char g10 = g(); if (g10 == 0) { return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } Resources resources = this.f649n.u().getResources(); StringBuilder sb = new StringBuilder(); if (ViewConfiguration.get(this.f649n.u()).hasPermanentMenuKey()) { sb.append(resources.getString(d.h.f8809k)); } int i10 = this.f649n.G() ? this.f646k : this.f644i; d(sb, i10, 65536, resources.getString(d.h.f8805g)); d(sb, i10, 4096, resources.getString(d.h.f8801c)); d(sb, i10, 2, resources.getString(d.h.f8800b)); d(sb, i10, 1, resources.getString(d.h.f8806h)); d(sb, i10, 4, resources.getString(d.h.f8808j)); d(sb, i10, 8, resources.getString(d.h.f8804f)); if (g10 == '\b') { sb.append(resources.getString(d.h.f8802d)); } else if (g10 == '\n') { sb.append(resources.getString(d.h.f8803e)); } else if (g10 != ' ') { sb.append(g10); } else { sb.append(resources.getString(d.h.f8807i)); } return sb.toString(); } @Override // android.view.MenuItem public boolean hasSubMenu() { return this.f650o != null; } CharSequence i(k.a aVar) { return (aVar == null || !aVar.d()) ? getTitle() : getTitleCondensed(); } @Override // s.b, android.view.MenuItem public boolean isActionViewExpanded() { return this.D; } @Override // android.view.MenuItem public boolean isCheckable() { return (this.f660y & 1) == 1; } @Override // android.view.MenuItem public boolean isChecked() { return (this.f660y & 2) == 2; } @Override // android.view.MenuItem public boolean isEnabled() { return (this.f660y & 16) != 0; } @Override // android.view.MenuItem public boolean isVisible() { androidx.core.view.b bVar = this.B; return (bVar == null || !bVar.f()) ? (this.f660y & 8) == 0 : (this.f660y & 8) == 0 && this.B.b(); } public boolean j() { androidx.core.view.b bVar; if ((this.f661z & 8) == 0) { return false; } if (this.A == null && (bVar = this.B) != null) { this.A = bVar.c(this); } return this.A != null; } public boolean k() { MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.f652q; if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) { return true; } e eVar = this.f649n; if (eVar.h(eVar, this)) { return true; } Runnable runnable = this.f651p; if (runnable != null) { runnable.run(); return true; } if (this.f642g != null) { try { this.f649n.u().startActivity(this.f642g); return true; } catch (ActivityNotFoundException e10) { Log.e("MenuItemImpl", "Can't find activity to handle intent; ignoring", e10); } } androidx.core.view.b bVar = this.B; return bVar != null && bVar.d(); } public boolean l() { return (this.f660y & 32) == 32; } public boolean m() { return (this.f660y & 4) != 0; } public boolean n() { return (this.f661z & 1) == 1; } public boolean o() { return (this.f661z & 2) == 2; } @Override // s.b, android.view.MenuItem /* renamed from: p, reason: merged with bridge method [inline-methods] */ public s.b setActionView(int i10) { Context u10 = this.f649n.u(); setActionView(LayoutInflater.from(u10).inflate(i10, (ViewGroup) new LinearLayout(u10), false)); return this; } @Override // s.b, android.view.MenuItem /* renamed from: q, reason: merged with bridge method [inline-methods] */ public s.b setActionView(View view) { int i10; this.A = view; this.B = null; if (view != null && view.getId() == -1 && (i10 = this.f636a) > 0) { view.setId(i10); } this.f649n.I(this); return this; } public void r(boolean z10) { this.D = z10; this.f649n.K(false); } void s(boolean z10) { int i10 = this.f660y; int i11 = (z10 ? 2 : 0) | (i10 & (-3)); this.f660y = i11; if (i10 != i11) { this.f649n.K(false); } } @Override // android.view.MenuItem public MenuItem setActionProvider(ActionProvider actionProvider) { throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()"); } @Override // android.view.MenuItem public MenuItem setAlphabeticShortcut(char c10) { if (this.f645j == c10) { return this; } this.f645j = Character.toLowerCase(c10); this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setCheckable(boolean z10) { int i10 = this.f660y; int i11 = (z10 ? 1 : 0) | (i10 & (-2)); this.f660y = i11; if (i10 != i11) { this.f649n.K(false); } return this; } @Override // android.view.MenuItem public MenuItem setChecked(boolean z10) { if ((this.f660y & 4) != 0) { this.f649n.T(this); } else { s(z10); } return this; } @Override // android.view.MenuItem public MenuItem setEnabled(boolean z10) { if (z10) { this.f660y |= 16; } else { this.f660y &= -17; } this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setIcon(Drawable drawable) { this.f648m = 0; this.f647l = drawable; this.f659x = true; this.f649n.K(false); return this; } @Override // s.b, android.view.MenuItem public MenuItem setIconTintList(ColorStateList colorStateList) { this.f655t = colorStateList; this.f657v = true; this.f659x = true; this.f649n.K(false); return this; } @Override // s.b, android.view.MenuItem public MenuItem setIconTintMode(PorterDuff.Mode mode) { this.f656u = mode; this.f658w = true; this.f659x = true; this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setIntent(Intent intent) { this.f642g = intent; return this; } @Override // android.view.MenuItem public MenuItem setNumericShortcut(char c10) { if (this.f643h == c10) { return this; } this.f643h = c10; this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) { this.C = onActionExpandListener; return this; } @Override // android.view.MenuItem public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) { this.f652q = onMenuItemClickListener; return this; } @Override // android.view.MenuItem public MenuItem setShortcut(char c10, char c11) { this.f643h = c10; this.f645j = Character.toLowerCase(c11); this.f649n.K(false); return this; } @Override // s.b, android.view.MenuItem public void setShowAsAction(int i10) { int i11 = i10 & 3; if (i11 != 0 && i11 != 1 && i11 != 2) { throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, and SHOW_AS_ACTION_NEVER are mutually exclusive."); } this.f661z = i10; this.f649n.I(this); } @Override // android.view.MenuItem public MenuItem setTitle(CharSequence charSequence) { this.f640e = charSequence; this.f649n.K(false); m mVar = this.f650o; if (mVar != null) { mVar.setHeaderTitle(charSequence); } return this; } @Override // android.view.MenuItem public MenuItem setTitleCondensed(CharSequence charSequence) { this.f641f = charSequence; this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setVisible(boolean z10) { if (y(z10)) { this.f649n.J(this); } return this; } public void t(boolean z10) { this.f660y = (z10 ? 4 : 0) | (this.f660y & (-5)); } public String toString() { CharSequence charSequence = this.f640e; if (charSequence != null) { return charSequence.toString(); } return null; } public void u(boolean z10) { if (z10) { this.f660y |= 32; } else { this.f660y &= -33; } } void v(ContextMenu.ContextMenuInfo contextMenuInfo) { this.E = contextMenuInfo; } @Override // s.b, android.view.MenuItem /* renamed from: w, reason: merged with bridge method [inline-methods] */ public s.b setShowAsActionFlags(int i10) { setShowAsAction(i10); return this; } public void x(m mVar) { this.f650o = mVar; mVar.setHeaderTitle(getTitle()); } boolean y(boolean z10) { int i10 = this.f660y; int i11 = (z10 ? 0 : 8) | (i10 & (-9)); this.f660y = i11; return i10 != i11; } public boolean z() { return this.f649n.A(); } @Override // android.view.MenuItem public s.b setContentDescription(CharSequence charSequence) { this.f653r = charSequence; this.f649n.K(false); return this; } @Override // android.view.MenuItem public s.b setTooltipText(CharSequence charSequence) { this.f654s = charSequence; this.f649n.K(false); return this; } @Override // s.b, android.view.MenuItem public MenuItem setAlphabeticShortcut(char c10, int i10) { if (this.f645j == c10 && this.f646k == i10) { return this; } this.f645j = Character.toLowerCase(c10); this.f646k = KeyEvent.normalizeMetaState(i10); this.f649n.K(false); return this; } @Override // s.b, android.view.MenuItem public MenuItem setNumericShortcut(char c10, int i10) { if (this.f643h == c10 && this.f644i == i10) { return this; } this.f643h = c10; this.f644i = KeyEvent.normalizeMetaState(i10); this.f649n.K(false); return this; } @Override // s.b, android.view.MenuItem public MenuItem setShortcut(char c10, char c11, int i10, int i11) { this.f643h = c10; this.f644i = KeyEvent.normalizeMetaState(i10); this.f645j = Character.toLowerCase(c11); this.f646k = KeyEvent.normalizeMetaState(i11); this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setIcon(int i10) { this.f647l = null; this.f648m = i10; this.f659x = true; this.f649n.K(false); return this; } @Override // android.view.MenuItem public MenuItem setTitle(int i10) { return setTitle(this.f649n.u().getString(i10)); } }