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.os.Build; import android.util.Log; 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.ViewDebug; import android.view.ViewGroup; import android.widget.LinearLayout; import androidx.appcompat.R$string; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.menu.MenuView; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.internal.view.SupportMenuItem; import androidx.core.view.ActionProvider; import com.ubt.jimu.base.util.FileUtil; /* loaded from: classes.dex */ public final class MenuItemImpl implements SupportMenuItem { private View A; private ActionProvider B; private MenuItem.OnActionExpandListener C; private ContextMenu.ContextMenuInfo E; private final int a; private final int b; private final int c; private final int d; private CharSequence e; private CharSequence f; private Intent g; private char h; private char j; private Drawable l; MenuBuilder n; private SubMenuBuilder o; private Runnable p; private MenuItem.OnMenuItemClickListener q; private CharSequence r; private CharSequence s; private int z; private int i = FileUtil.ZIP_BUFFER_SIZE; private int k = FileUtil.ZIP_BUFFER_SIZE; private int m = 0; private ColorStateList t = null; private PorterDuff.Mode u = null; private boolean v = false; private boolean w = false; private boolean x = false; private int y = 16; private boolean D = false; MenuItemImpl(MenuBuilder menuBuilder, int i, int i2, int i3, int i4, CharSequence charSequence, int i5) { this.z = 0; this.n = menuBuilder; this.a = i2; this.b = i; this.c = i3; this.d = i4; this.e = charSequence; this.z = i5; } private static void a(StringBuilder sb, int i, int i2, String str) { if ((i & i2) == i2) { sb.append(str); } } void b(boolean z) { int i = this.y; this.y = (z ? 2 : 0) | (i & (-3)); if (i != this.y) { this.n.b(false); } } public int c() { return this.d; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public boolean collapseActionView() { if ((this.z & 8) == 0) { return false; } if (this.A == null) { return true; } MenuItem.OnActionExpandListener onActionExpandListener = this.C; if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionCollapse(this)) { return this.n.a(this); } return false; } char d() { return this.n.p() ? this.j : this.h; } String e() { char d = d(); if (d == 0) { return ""; } Resources resources = this.n.e().getResources(); StringBuilder sb = new StringBuilder(); if (ViewConfiguration.get(this.n.e()).hasPermanentMenuKey()) { sb.append(resources.getString(R$string.abc_prepend_shortcut_label)); } int i = this.n.p() ? this.k : this.i; a(sb, i, 65536, resources.getString(R$string.abc_menu_meta_shortcut_label)); a(sb, i, FileUtil.ZIP_BUFFER_SIZE, resources.getString(R$string.abc_menu_ctrl_shortcut_label)); a(sb, i, 2, resources.getString(R$string.abc_menu_alt_shortcut_label)); a(sb, i, 1, resources.getString(R$string.abc_menu_shift_shortcut_label)); a(sb, i, 4, resources.getString(R$string.abc_menu_sym_shortcut_label)); a(sb, i, 8, resources.getString(R$string.abc_menu_function_shortcut_label)); if (d == '\b') { sb.append(resources.getString(R$string.abc_menu_delete_shortcut_label)); } else if (d == '\n') { sb.append(resources.getString(R$string.abc_menu_enter_shortcut_label)); } else if (d != ' ') { sb.append(d); } else { sb.append(resources.getString(R$string.abc_menu_space_shortcut_label)); } return sb.toString(); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public boolean expandActionView() { if (!f()) { return false; } MenuItem.OnActionExpandListener onActionExpandListener = this.C; if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionExpand(this)) { return this.n.b(this); } return false; } public boolean f() { ActionProvider actionProvider; if ((this.z & 8) == 0) { return false; } if (this.A == null && (actionProvider = this.B) != null) { this.A = actionProvider.a(this); } return this.A != null; } public boolean g() { MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.q; if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) { return true; } MenuBuilder menuBuilder = this.n; if (menuBuilder.a(menuBuilder, this)) { return true; } Runnable runnable = this.p; if (runnable != null) { runnable.run(); return true; } if (this.g != null) { try { this.n.e().startActivity(this.g); return true; } catch (ActivityNotFoundException e) { Log.e("MenuItemImpl", "Can't find activity to handle intent; ignoring", e); } } ActionProvider actionProvider = this.B; return actionProvider != null && actionProvider.d(); } @Override // android.view.MenuItem public android.view.ActionProvider getActionProvider() { throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.getActionProvider()"); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public View getActionView() { View view = this.A; if (view != null) { return view; } ActionProvider actionProvider = this.B; if (actionProvider == null) { return null; } this.A = actionProvider.a(this); return this.A; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public int getAlphabeticModifiers() { return this.k; } @Override // android.view.MenuItem public char getAlphabeticShortcut() { return this.j; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public CharSequence getContentDescription() { return this.r; } @Override // android.view.MenuItem public int getGroupId() { return this.b; } @Override // android.view.MenuItem public Drawable getIcon() { Drawable drawable = this.l; if (drawable != null) { return a(drawable); } if (this.m == 0) { return null; } Drawable c = AppCompatResources.c(this.n.e(), this.m); this.m = 0; this.l = c; return a(c); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public ColorStateList getIconTintList() { return this.t; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public PorterDuff.Mode getIconTintMode() { return this.u; } @Override // android.view.MenuItem public Intent getIntent() { return this.g; } @Override // android.view.MenuItem @ViewDebug.CapturedViewProperty public int getItemId() { return this.a; } @Override // android.view.MenuItem public ContextMenu.ContextMenuInfo getMenuInfo() { return this.E; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public int getNumericModifiers() { return this.i; } @Override // android.view.MenuItem public char getNumericShortcut() { return this.h; } @Override // android.view.MenuItem public int getOrder() { return this.c; } @Override // android.view.MenuItem public SubMenu getSubMenu() { return this.o; } @Override // android.view.MenuItem @ViewDebug.CapturedViewProperty public CharSequence getTitle() { return this.e; } @Override // android.view.MenuItem public CharSequence getTitleCondensed() { CharSequence charSequence = this.f; if (charSequence == null) { charSequence = this.e; } return (Build.VERSION.SDK_INT >= 18 || charSequence == null || (charSequence instanceof String)) ? charSequence : charSequence.toString(); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public CharSequence getTooltipText() { return this.s; } public boolean h() { return (this.y & 32) == 32; } @Override // android.view.MenuItem public boolean hasSubMenu() { return this.o != null; } public boolean i() { return (this.y & 4) != 0; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public boolean isActionViewExpanded() { return this.D; } @Override // android.view.MenuItem public boolean isCheckable() { return (this.y & 1) == 1; } @Override // android.view.MenuItem public boolean isChecked() { return (this.y & 2) == 2; } @Override // android.view.MenuItem public boolean isEnabled() { return (this.y & 16) != 0; } @Override // android.view.MenuItem public boolean isVisible() { ActionProvider actionProvider = this.B; return (actionProvider == null || !actionProvider.e()) ? (this.y & 8) == 0 : (this.y & 8) == 0 && this.B.b(); } public boolean j() { return (this.z & 1) == 1; } public boolean k() { return (this.z & 2) == 2; } public boolean l() { return this.n.k(); } boolean m() { return this.n.q() && d() != 0; } public boolean n() { return (this.z & 4) == 4; } @Override // android.view.MenuItem public MenuItem setActionProvider(android.view.ActionProvider actionProvider) { throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()"); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public /* bridge */ /* synthetic */ MenuItem setActionView(int i) { setActionView(i); return this; } @Override // android.view.MenuItem public MenuItem setAlphabeticShortcut(char c) { if (this.j == c) { return this; } this.j = Character.toLowerCase(c); this.n.b(false); return this; } @Override // android.view.MenuItem public MenuItem setCheckable(boolean z) { int i = this.y; this.y = (z ? 1 : 0) | (i & (-2)); if (i != this.y) { this.n.b(false); } return this; } @Override // android.view.MenuItem public MenuItem setChecked(boolean z) { if ((this.y & 4) != 0) { this.n.a((MenuItem) this); } else { b(z); } return this; } @Override // android.view.MenuItem public /* bridge */ /* synthetic */ MenuItem setContentDescription(CharSequence charSequence) { setContentDescription(charSequence); return this; } @Override // android.view.MenuItem public MenuItem setEnabled(boolean z) { if (z) { this.y |= 16; } else { this.y &= -17; } this.n.b(false); return this; } @Override // android.view.MenuItem public MenuItem setIcon(Drawable drawable) { this.m = 0; this.l = drawable; this.x = true; this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setIconTintList(ColorStateList colorStateList) { this.t = colorStateList; this.v = true; this.x = true; this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setIconTintMode(PorterDuff.Mode mode) { this.u = mode; this.w = true; this.x = true; this.n.b(false); return this; } @Override // android.view.MenuItem public MenuItem setIntent(Intent intent) { this.g = intent; return this; } @Override // android.view.MenuItem public MenuItem setNumericShortcut(char c) { if (this.h == c) { return this; } this.h = c; this.n.b(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.q = onMenuItemClickListener; return this; } @Override // android.view.MenuItem public MenuItem setShortcut(char c, char c2) { this.h = c; this.j = Character.toLowerCase(c2); this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public void setShowAsAction(int i) { int i2 = i & 3; if (i2 != 0 && i2 != 1 && i2 != 2) { throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, and SHOW_AS_ACTION_NEVER are mutually exclusive."); } this.z = i; this.n.c(this); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public /* bridge */ /* synthetic */ MenuItem setShowAsActionFlags(int i) { setShowAsActionFlags(i); return this; } @Override // android.view.MenuItem public MenuItem setTitle(CharSequence charSequence) { this.e = charSequence; this.n.b(false); SubMenuBuilder subMenuBuilder = this.o; if (subMenuBuilder != null) { subMenuBuilder.setHeaderTitle(charSequence); } return this; } @Override // android.view.MenuItem public MenuItem setTitleCondensed(CharSequence charSequence) { this.f = charSequence; this.n.b(false); return this; } @Override // android.view.MenuItem public /* bridge */ /* synthetic */ MenuItem setTooltipText(CharSequence charSequence) { setTooltipText(charSequence); return this; } @Override // android.view.MenuItem public MenuItem setVisible(boolean z) { if (e(z)) { this.n.d(this); } return this; } public String toString() { CharSequence charSequence = this.e; if (charSequence != null) { return charSequence.toString(); } return null; } public void a(SubMenuBuilder subMenuBuilder) { this.o = subMenuBuilder; subMenuBuilder.setHeaderTitle(getTitle()); } public void c(boolean z) { this.y = (z ? 4 : 0) | (this.y & (-5)); } public void d(boolean z) { if (z) { this.y |= 32; } else { this.y &= -33; } } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public /* bridge */ /* synthetic */ MenuItem setActionView(View view) { setActionView(view); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setContentDescription(CharSequence charSequence) { this.r = charSequence; this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setShowAsActionFlags(int i) { setShowAsAction(i); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setTooltipText(CharSequence charSequence) { this.s = charSequence; this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setActionView(View view) { int i; this.A = view; this.B = null; if (view != null && view.getId() == -1 && (i = this.a) > 0) { view.setId(i); } this.n.c(this); return this; } CharSequence a(MenuView.ItemView itemView) { if (itemView != null && itemView.a()) { return getTitleCondensed(); } return getTitle(); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setAlphabeticShortcut(char c, int i) { if (this.j == c && this.k == i) { return this; } this.j = Character.toLowerCase(c); this.k = KeyEvent.normalizeMetaState(i); this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setNumericShortcut(char c, int i) { if (this.h == c && this.i == i) { return this; } this.h = c; this.i = KeyEvent.normalizeMetaState(i); this.n.b(false); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setShortcut(char c, char c2, int i, int i2) { this.h = c; this.i = KeyEvent.normalizeMetaState(i); this.j = Character.toLowerCase(c2); this.k = KeyEvent.normalizeMetaState(i2); this.n.b(false); return this; } public void b() { this.n.c(this); } @Override // android.view.MenuItem public MenuItem setIcon(int i) { this.l = null; this.m = i; this.x = true; this.n.b(false); return this; } @Override // android.view.MenuItem public MenuItem setTitle(int i) { setTitle(this.n.e().getString(i)); return this; } private Drawable a(Drawable drawable) { if (drawable != null && this.x && (this.v || this.w)) { drawable = DrawableCompat.h(drawable).mutate(); if (this.v) { DrawableCompat.a(drawable, this.t); } if (this.w) { DrawableCompat.a(drawable, this.u); } this.x = false; } return drawable; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setActionView(int i) { Context e = this.n.e(); setActionView(LayoutInflater.from(e).inflate(i, (ViewGroup) new LinearLayout(e), false)); return this; } void a(ContextMenu.ContextMenuInfo contextMenuInfo) { this.E = contextMenuInfo; } @Override // androidx.core.internal.view.SupportMenuItem public ActionProvider a() { return this.B; } @Override // androidx.core.internal.view.SupportMenuItem public SupportMenuItem a(ActionProvider actionProvider) { ActionProvider actionProvider2 = this.B; if (actionProvider2 != null) { actionProvider2.f(); } this.A = null; this.B = actionProvider; this.n.b(true); ActionProvider actionProvider3 = this.B; if (actionProvider3 != null) { actionProvider3.a(new ActionProvider.VisibilityListener() { // from class: androidx.appcompat.view.menu.MenuItemImpl.1 @Override // androidx.core.view.ActionProvider.VisibilityListener public void onActionProviderVisibilityChanged(boolean z) { MenuItemImpl menuItemImpl = MenuItemImpl.this; menuItemImpl.n.d(menuItemImpl); } }); } return this; } public void a(boolean z) { this.D = z; this.n.b(false); } boolean e(boolean z) { int i = this.y; this.y = (z ? 0 : 8) | (i & (-9)); return i != this.y; } }