package k;

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.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.ViewGroup;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class r implements l0.b {
    public androidx.core.view.e A;
    public MenuItem.OnActionExpandListener B;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final int f28908a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f28909b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f28910c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int f28911d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public CharSequence f28912e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public CharSequence f28913f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public Intent f28914g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public char f28915h;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public char f28917j;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public Drawable f28919l;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final p f28921n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public h0 f28922o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public MenuItem.OnMenuItemClickListener f28923p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public CharSequence f28924q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public CharSequence f28925r;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public int f28932y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public View f28933z;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f28916i = 4096;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f28918k = 4096;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f28920m = 0;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public ColorStateList f28926s = null;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public PorterDuff.Mode f28927t = null;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public boolean f28928u = false;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public boolean f28929v = false;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public boolean f28930w = false;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public int f28931x = 16;
    public boolean C = false;

    public r(p pVar, int i10, int i11, int i12, int i13, CharSequence charSequence, int i14) {
        this.f28921n = pVar;
        this.f28908a = i11;
        this.f28909b = i10;
        this.f28910c = i12;
        this.f28911d = i13;
        this.f28912e = charSequence;
        this.f28932y = i14;
    }

    public static void a(int i10, int i11, String str, StringBuilder sb) {
        if ((i10 & i11) == i11) {
            sb.append(str);
        }
    }

    public final Drawable b(Drawable drawable) {
        if (drawable != null && this.f28930w && (this.f28928u || this.f28929v)) {
            drawable = drawable.mutate();
            if (this.f28928u) {
                k0.a.setTintList(drawable, this.f28926s);
            }
            if (this.f28929v) {
                k0.a.setTintMode(drawable, this.f28927t);
            }
            this.f28930w = false;
        }
        return drawable;
    }

    public final boolean c() {
        androidx.core.view.e eVar;
        if ((this.f28932y & 8) == 0) {
            return false;
        }
        if (this.f28933z == null && (eVar = this.A) != null) {
            this.f28933z = ((s) eVar).f28935d.onCreateActionView(this);
        }
        return this.f28933z != null;
    }

    @Override // android.view.MenuItem
    public final boolean collapseActionView() {
        if ((this.f28932y & 8) == 0) {
            return false;
        }
        if (this.f28933z == null) {
            return true;
        }
        MenuItem.OnActionExpandListener onActionExpandListener = this.B;
        if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionCollapse(this)) {
            return this.f28921n.d(this);
        }
        return false;
    }

    public final boolean d() {
        return (this.f28931x & 32) == 32;
    }

    public final void e(boolean z10) {
        this.f28931x = (z10 ? 4 : 0) | (this.f28931x & (-5));
    }

    @Override // android.view.MenuItem
    public final boolean expandActionView() {
        if (!c()) {
            return false;
        }
        MenuItem.OnActionExpandListener onActionExpandListener = this.B;
        if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionExpand(this)) {
            return this.f28921n.f(this);
        }
        return false;
    }

    public final void f(boolean z10) {
        if (z10) {
            this.f28931x |= 32;
        } else {
            this.f28931x &= -33;
        }
    }

    @Override // android.view.MenuItem
    public final ActionProvider getActionProvider() {
        throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.getActionProvider()");
    }

    @Override // l0.b, android.view.MenuItem
    public final View getActionView() {
        View view = this.f28933z;
        if (view != null) {
            return view;
        }
        androidx.core.view.e eVar = this.A;
        if (eVar == null) {
            return null;
        }
        View viewOnCreateActionView = ((s) eVar).f28935d.onCreateActionView(this);
        this.f28933z = viewOnCreateActionView;
        return viewOnCreateActionView;
    }

    @Override // l0.b, android.view.MenuItem
    public final int getAlphabeticModifiers() {
        return this.f28918k;
    }

    @Override // android.view.MenuItem
    public final char getAlphabeticShortcut() {
        return this.f28917j;
    }

    @Override // l0.b, android.view.MenuItem
    public final CharSequence getContentDescription() {
        return this.f28924q;
    }

    @Override // android.view.MenuItem
    public final int getGroupId() {
        return this.f28909b;
    }

    @Override // android.view.MenuItem
    public final Drawable getIcon() {
        Drawable drawable = this.f28919l;
        if (drawable != null) {
            return b(drawable);
        }
        int i10 = this.f28920m;
        if (i10 == 0) {
            return null;
        }
        Drawable drawable2 = f.a.getDrawable(this.f28921n.f28880a, i10);
        this.f28920m = 0;
        this.f28919l = drawable2;
        return b(drawable2);
    }

    @Override // l0.b, android.view.MenuItem
    public final ColorStateList getIconTintList() {
        return this.f28926s;
    }

    @Override // l0.b, android.view.MenuItem
    public final PorterDuff.Mode getIconTintMode() {
        return this.f28927t;
    }

    @Override // android.view.MenuItem
    public final Intent getIntent() {
        return this.f28914g;
    }

    @Override // android.view.MenuItem
    public final int getItemId() {
        return this.f28908a;
    }

    @Override // android.view.MenuItem
    public final ContextMenu.ContextMenuInfo getMenuInfo() {
        return null;
    }

    @Override // l0.b, android.view.MenuItem
    public final int getNumericModifiers() {
        return this.f28916i;
    }

    @Override // android.view.MenuItem
    public final char getNumericShortcut() {
        return this.f28915h;
    }

    @Override // android.view.MenuItem
    public final int getOrder() {
        return this.f28910c;
    }

    @Override // android.view.MenuItem
    public final SubMenu getSubMenu() {
        return this.f28922o;
    }

    @Override // l0.b
    public final androidx.core.view.e getSupportActionProvider() {
        return this.A;
    }

    @Override // android.view.MenuItem
    public final CharSequence getTitle() {
        return this.f28912e;
    }

    @Override // android.view.MenuItem
    public final CharSequence getTitleCondensed() {
        CharSequence charSequence = this.f28913f;
        return charSequence != null ? charSequence : this.f28912e;
    }

    @Override // l0.b, android.view.MenuItem
    public final CharSequence getTooltipText() {
        return this.f28925r;
    }

    @Override // android.view.MenuItem
    public final boolean hasSubMenu() {
        return this.f28922o != null;
    }

    @Override // android.view.MenuItem
    public final boolean isActionViewExpanded() {
        return this.C;
    }

    @Override // android.view.MenuItem
    public final boolean isCheckable() {
        return (this.f28931x & 1) == 1;
    }

    @Override // android.view.MenuItem
    public final boolean isChecked() {
        return (this.f28931x & 2) == 2;
    }

    @Override // android.view.MenuItem
    public final boolean isEnabled() {
        return (this.f28931x & 16) != 0;
    }

    @Override // android.view.MenuItem
    public final boolean isVisible() {
        androidx.core.view.e eVar = this.A;
        return (eVar == null || !((s) eVar).f28935d.overridesItemVisibility()) ? (this.f28931x & 8) == 0 : (this.f28931x & 8) == 0 && ((s) this.A).f28935d.isVisible();
    }

    @Override // android.view.MenuItem
    public final MenuItem setActionProvider(ActionProvider actionProvider) {
        throw new UnsupportedOperationException("This is not supported, use MenuItemCompat.setActionProvider()");
    }

    @Override // l0.b, android.view.MenuItem
    public final MenuItem setActionView(View view) {
        int i10;
        this.f28933z = view;
        this.A = null;
        if (view != null && view.getId() == -1 && (i10 = this.f28908a) > 0) {
            view.setId(i10);
        }
        p pVar = this.f28921n;
        pVar.f28890k = true;
        pVar.p(true);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setAlphabeticShortcut(char c6) {
        if (this.f28917j == c6) {
            return this;
        }
        this.f28917j = Character.toLowerCase(c6);
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setCheckable(boolean z10) {
        int i10 = this.f28931x;
        int i11 = (z10 ? 1 : 0) | (i10 & (-2));
        this.f28931x = i11;
        if (i10 != i11) {
            this.f28921n.p(false);
        }
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setChecked(boolean z10) {
        int i10 = this.f28931x;
        if ((i10 & 4) != 0) {
            p pVar = this.f28921n;
            pVar.getClass();
            ArrayList arrayList = pVar.f28885f;
            int size = arrayList.size();
            pVar.y();
            for (int i11 = 0; i11 < size; i11++) {
                r rVar = (r) arrayList.get(i11);
                if (rVar.f28909b == this.f28909b && (rVar.f28931x & 4) != 0 && rVar.isCheckable()) {
                    boolean z11 = rVar == this;
                    int i12 = rVar.f28931x;
                    int i13 = (z11 ? 2 : 0) | (i12 & (-3));
                    rVar.f28931x = i13;
                    if (i12 != i13) {
                        rVar.f28921n.p(false);
                    }
                }
            }
            pVar.x();
        } else {
            int i14 = (i10 & (-3)) | (z10 ? 2 : 0);
            this.f28931x = i14;
            if (i10 != i14) {
                this.f28921n.p(false);
            }
        }
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final /* bridge */ /* synthetic */ MenuItem setContentDescription(CharSequence charSequence) {
        setContentDescription(charSequence);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setEnabled(boolean z10) {
        if (z10) {
            this.f28931x |= 16;
        } else {
            this.f28931x &= -17;
        }
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setIcon(Drawable drawable) {
        this.f28920m = 0;
        this.f28919l = drawable;
        this.f28930w = true;
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    @NonNull
    public MenuItem setIconTintList(@Nullable ColorStateList colorStateList) {
        this.f28926s = colorStateList;
        this.f28928u = true;
        this.f28930w = true;
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final MenuItem setIconTintMode(PorterDuff.Mode mode) {
        this.f28927t = mode;
        this.f28929v = true;
        this.f28930w = true;
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setIntent(Intent intent) {
        this.f28914g = intent;
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setNumericShortcut(char c6) {
        if (this.f28915h == c6) {
            return this;
        }
        this.f28915h = c6;
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener onActionExpandListener) {
        this.B = onActionExpandListener;
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener onMenuItemClickListener) {
        this.f28923p = onMenuItemClickListener;
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setShortcut(char c6, char c10) {
        this.f28915h = c6;
        this.f28917j = Character.toLowerCase(c10);
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final 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.f28932y = i10;
        p pVar = this.f28921n;
        pVar.f28890k = true;
        pVar.p(true);
    }

    @Override // android.view.MenuItem
    public final MenuItem setShowAsActionFlags(int i10) {
        setShowAsAction(i10);
        return this;
    }

    @Override // l0.b
    public final l0.b setSupportActionProvider(androidx.core.view.e eVar) {
        androidx.core.view.e eVar2 = this.A;
        if (eVar2 != null) {
            eVar2.f1728b = null;
        }
        this.f28933z = null;
        this.A = eVar;
        this.f28921n.p(true);
        androidx.core.view.e eVar3 = this.A;
        if (eVar3 != null) {
            eVar3.setVisibilityListener(new nb.c(this, 2));
        }
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setTitle(CharSequence charSequence) {
        this.f28912e = charSequence;
        this.f28921n.p(false);
        h0 h0Var = this.f28922o;
        if (h0Var != null) {
            h0Var.setHeaderTitle(charSequence);
        }
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setTitleCondensed(CharSequence charSequence) {
        this.f28913f = charSequence;
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final /* bridge */ /* synthetic */ MenuItem setTooltipText(CharSequence charSequence) {
        setTooltipText(charSequence);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setVisible(boolean z10) {
        int i10 = this.f28931x;
        int i11 = (z10 ? 0 : 8) | (i10 & (-9));
        this.f28931x = i11;
        if (i10 != i11) {
            p pVar = this.f28921n;
            pVar.f28887h = true;
            pVar.p(true);
        }
        return this;
    }

    public final String toString() {
        CharSequence charSequence = this.f28912e;
        if (charSequence != null) {
            return charSequence.toString();
        }
        return null;
    }

    @Override // l0.b, android.view.MenuItem
    public final l0.b setContentDescription(CharSequence charSequence) {
        this.f28924q = charSequence;
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setIcon(int i10) {
        this.f28919l = null;
        this.f28920m = i10;
        this.f28930w = true;
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final MenuItem setNumericShortcut(char c6, int i10) {
        if (this.f28915h == c6 && this.f28916i == i10) {
            return this;
        }
        this.f28915h = c6;
        this.f28916i = KeyEvent.normalizeMetaState(i10);
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final l0.b setTooltipText(CharSequence charSequence) {
        this.f28925r = charSequence;
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final MenuItem setAlphabeticShortcut(char c6, int i10) {
        if (this.f28917j == c6 && this.f28918k == i10) {
            return this;
        }
        this.f28917j = Character.toLowerCase(c6);
        this.f28918k = KeyEvent.normalizeMetaState(i10);
        this.f28921n.p(false);
        return this;
    }

    @Override // l0.b, android.view.MenuItem
    public final MenuItem setShortcut(char c6, char c10, int i10, int i11) {
        this.f28915h = c6;
        this.f28916i = KeyEvent.normalizeMetaState(i10);
        this.f28917j = Character.toLowerCase(c10);
        this.f28918k = KeyEvent.normalizeMetaState(i11);
        this.f28921n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setTitle(int i10) {
        setTitle(this.f28921n.f28880a.getString(i10));
        return this;
    }

    @Override // android.view.MenuItem
    public final MenuItem setActionView(int i10) {
        int i11;
        Context context = this.f28921n.f28880a;
        View viewInflate = LayoutInflater.from(context).inflate(i10, (ViewGroup) new LinearLayout(context), false);
        this.f28933z = viewInflate;
        this.A = null;
        if (viewInflate != null && viewInflate.getId() == -1 && (i11 = this.f28908a) > 0) {
            viewInflate.setId(i11);
        }
        p pVar = this.f28921n;
        pVar.f28890k = true;
        pVar.p(true);
        return this;
    }
}
