package androidx.appcompat.view.menu; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.view.ContextMenu; import android.view.KeyEvent; import android.view.MenuItem; import android.view.SubMenu; import android.view.View; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.internal.view.SupportMenuItem; import androidx.core.view.ActionProvider; /* loaded from: classes.dex */ public class ActionMenuItem implements SupportMenuItem { private static final int CHECKABLE = 1; private static final int CHECKED = 2; private static final int ENABLED = 16; private static final int EXCLUSIVE = 4; private static final int HIDDEN = 8; private MenuItem.OnMenuItemClickListener mClickListener; private CharSequence mContentDescription; private Context mContext; private final int mGroup; private Drawable mIconDrawable; private final int mId; private Intent mIntent; private final int mOrdering; private char mShortcutAlphabeticChar; private char mShortcutNumericChar; private CharSequence mTitle; private CharSequence mTitleCondensed; private CharSequence mTooltipText; private int mShortcutNumericModifiers = 4096; private int mShortcutAlphabeticModifiers = 4096; private ColorStateList mIconTintList = null; private PorterDuff.Mode mIconTintMode = null; private boolean mHasIconTint = false; private boolean mHasIconTintMode = false; private int mFlags = 16; @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public boolean collapseActionView() { return false; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public boolean expandActionView() { return false; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public View getActionView() { return null; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public int getAlphabeticModifiers() { return this.mShortcutAlphabeticModifiers; } @Override // android.view.MenuItem public char getAlphabeticShortcut() { return this.mShortcutAlphabeticChar; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public CharSequence getContentDescription() { return this.mContentDescription; } @Override // android.view.MenuItem public int getGroupId() { return this.mGroup; } @Override // android.view.MenuItem public Drawable getIcon() { return this.mIconDrawable; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public ColorStateList getIconTintList() { return this.mIconTintList; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public PorterDuff.Mode getIconTintMode() { return this.mIconTintMode; } @Override // android.view.MenuItem public Intent getIntent() { return this.mIntent; } @Override // android.view.MenuItem public int getItemId() { return this.mId; } @Override // android.view.MenuItem public ContextMenu.ContextMenuInfo getMenuInfo() { return null; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public int getNumericModifiers() { return this.mShortcutNumericModifiers; } @Override // android.view.MenuItem public char getNumericShortcut() { return this.mShortcutNumericChar; } @Override // android.view.MenuItem public int getOrder() { return this.mOrdering; } @Override // android.view.MenuItem public SubMenu getSubMenu() { return null; } @Override // androidx.core.internal.view.SupportMenuItem public ActionProvider getSupportActionProvider() { return null; } @Override // android.view.MenuItem public CharSequence getTitle() { return this.mTitle; } @Override // android.view.MenuItem public CharSequence getTitleCondensed() { CharSequence charSequence = this.mTitleCondensed; return charSequence != null ? charSequence : this.mTitle; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public CharSequence getTooltipText() { return this.mTooltipText; } @Override // android.view.MenuItem public boolean hasSubMenu() { return false; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public boolean isActionViewExpanded() { return false; } @Override // android.view.MenuItem public boolean isCheckable() { return (this.mFlags & 1) != 0; } @Override // android.view.MenuItem public boolean isChecked() { return (this.mFlags & 2) != 0; } @Override // android.view.MenuItem public boolean isEnabled() { return (this.mFlags & 16) != 0; } @Override // android.view.MenuItem public boolean isVisible() { return (this.mFlags & 8) == 0; } @Override // androidx.core.internal.view.SupportMenuItem public boolean requiresActionButton() { return true; } @Override // androidx.core.internal.view.SupportMenuItem public boolean requiresOverflow() { return false; } @Override // android.view.MenuItem public MenuItem setCheckable(boolean z) { this.mFlags = (z ? 1 : 0) | (this.mFlags & (-2)); return this; } @Override // android.view.MenuItem public MenuItem setChecked(boolean z) { this.mFlags = (z ? 2 : 0) | (this.mFlags & (-3)); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setContentDescription(CharSequence charSequence) { this.mContentDescription = charSequence; return this; } @Override // android.view.MenuItem public MenuItem setEnabled(boolean z) { this.mFlags = (z ? 16 : 0) | (this.mFlags & (-17)); return this; } public ActionMenuItem setExclusiveCheckable(boolean z) { this.mFlags = (z ? 4 : 0) | (this.mFlags & (-5)); return this; } @Override // android.view.MenuItem public MenuItem setIntent(Intent intent) { this.mIntent = intent; return this; } @Override // android.view.MenuItem public MenuItem setNumericShortcut(char c) { this.mShortcutNumericChar = c; return this; } @Override // android.view.MenuItem public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) { this.mClickListener = onMenuItemClickListener; return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public void setShowAsAction(int i) { } @Override // android.view.MenuItem public MenuItem setTitle(CharSequence charSequence) { this.mTitle = charSequence; return this; } @Override // android.view.MenuItem public MenuItem setTitleCondensed(CharSequence charSequence) { this.mTitleCondensed = charSequence; return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setTooltipText(CharSequence charSequence) { this.mTooltipText = charSequence; return this; } @Override // android.view.MenuItem public MenuItem setVisible(boolean z) { this.mFlags = (this.mFlags & 8) | (z ? 0 : 8); return this; } public ActionMenuItem(Context context, int i, int i2, int i3, int i4, CharSequence charSequence) { this.mContext = context; this.mId = i2; this.mGroup = i; this.mOrdering = i4; this.mTitle = charSequence; } @Override // android.view.MenuItem public MenuItem setAlphabeticShortcut(char c) { this.mShortcutAlphabeticChar = Character.toLowerCase(c); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setAlphabeticShortcut(char c, int i) { this.mShortcutAlphabeticChar = Character.toLowerCase(c); this.mShortcutAlphabeticModifiers = KeyEvent.normalizeMetaState(i); return this; } @Override // android.view.MenuItem public MenuItem setIcon(Drawable drawable) { this.mIconDrawable = drawable; applyIconTint(); return this; } @Override // android.view.MenuItem public MenuItem setIcon(int i) { this.mIconDrawable = ContextCompat.getDrawable(this.mContext, i); applyIconTint(); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setNumericShortcut(char c, int i) { this.mShortcutNumericChar = c; this.mShortcutNumericModifiers = KeyEvent.normalizeMetaState(i); return this; } @Override // android.view.MenuItem public MenuItem setShortcut(char c, char c2) { this.mShortcutNumericChar = c; this.mShortcutAlphabeticChar = Character.toLowerCase(c2); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setShortcut(char c, char c2, int i, int i2) { this.mShortcutNumericChar = c; this.mShortcutNumericModifiers = KeyEvent.normalizeMetaState(i); this.mShortcutAlphabeticChar = Character.toLowerCase(c2); this.mShortcutAlphabeticModifiers = KeyEvent.normalizeMetaState(i2); return this; } @Override // android.view.MenuItem public MenuItem setTitle(int i) { this.mTitle = this.mContext.getResources().getString(i); return this; } public boolean invoke() { MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.mClickListener; if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) { return true; } Intent intent = this.mIntent; if (intent == null) { return false; } this.mContext.startActivity(intent); return true; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setActionView(View view) { throw new UnsupportedOperationException(); } @Override // android.view.MenuItem public MenuItem setActionProvider(android.view.ActionProvider actionProvider) { throw new UnsupportedOperationException(); } @Override // android.view.MenuItem public android.view.ActionProvider getActionProvider() { throw new UnsupportedOperationException(); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setActionView(int i) { throw new UnsupportedOperationException(); } @Override // androidx.core.internal.view.SupportMenuItem public SupportMenuItem setSupportActionProvider(ActionProvider actionProvider) { throw new UnsupportedOperationException(); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public SupportMenuItem setShowAsActionFlags(int i) { setShowAsAction(i); return this; } @Override // android.view.MenuItem public MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) { throw new UnsupportedOperationException(); } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setIconTintList(ColorStateList colorStateList) { this.mIconTintList = colorStateList; this.mHasIconTint = true; applyIconTint(); return this; } @Override // androidx.core.internal.view.SupportMenuItem, android.view.MenuItem public MenuItem setIconTintMode(PorterDuff.Mode mode) { this.mIconTintMode = mode; this.mHasIconTintMode = true; applyIconTint(); return this; } private void applyIconTint() { Drawable drawable = this.mIconDrawable; if (drawable != null) { if (this.mHasIconTint || this.mHasIconTintMode) { Drawable wrap = DrawableCompat.wrap(drawable); this.mIconDrawable = wrap; Drawable mutate = wrap.mutate(); this.mIconDrawable = mutate; if (this.mHasIconTint) { DrawableCompat.setTintList(mutate, this.mIconTintList); } if (this.mHasIconTintMode) { DrawableCompat.setTintMode(this.mIconDrawable, this.mIconTintMode); } } } } }