package c.b.f.d;

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.ViewDebug;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import c.e.i.b;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public final class g implements c.e.e.a.b {
    public c.e.i.b A;
    public MenuItem.OnActionExpandListener B;
    public ContextMenu.ContextMenuInfo D;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public char f4860j;
    public Drawable l;
    public f n;
    public p o;
    public MenuItem.OnMenuItemClickListener p;
    public CharSequence q;
    public CharSequence r;
    public int y;
    public View z;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f4859i = 4096;
    public int k = 4096;
    public int m = 0;
    public ColorStateList s = null;
    public PorterDuff.Mode t = null;
    public boolean u = false;
    public boolean v = false;
    public boolean w = false;
    public int x = 16;
    public boolean C = false;

    public class a implements b.a {
        public a() {
        }
    }

    public g(f fVar, int i2, int i3, int i4, int i5, CharSequence charSequence, int i6) {
        this.y = 0;
        this.n = fVar;
        this.f4851a = i3;
        this.f4852b = i2;
        this.f4853c = i4;
        this.f4854d = i5;
        this.f4855e = charSequence;
        this.y = i6;
    }

    public static void c(StringBuilder sb, int i2, int i3, String str) {
        if ((i2 & i3) == i3) {
            sb.append(str);
        }
    }

    @Override // c.e.e.a.b
    public c.e.e.a.b a(c.e.i.b bVar) {
        c.e.i.b bVar2 = this.A;
        if (bVar2 != null) {
            bVar2.f5255a = null;
        }
        this.z = null;
        this.A = bVar;
        this.n.p(true);
        c.e.i.b bVar3 = this.A;
        if (bVar3 != null) {
            bVar3.h(new a());
        }
        return this;
    }

    @Override // c.e.e.a.b
    public c.e.i.b b() {
        return this.A;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public boolean collapseActionView() {
        if ((this.y & 8) == 0) {
            return false;
        }
        if (this.z == null) {
            return true;
        }
        MenuItem.OnActionExpandListener onActionExpandListener = this.B;
        if (onActionExpandListener == null || onActionExpandListener.onMenuItemActionCollapse(this)) {
            return this.n.d(this);
        }
        return false;
    }

    public final Drawable d(Drawable drawable) {
        if (drawable != null && this.w && (this.u || this.v)) {
            drawable = drawable.mutate();
            if (this.u) {
                drawable.setTintList(this.s);
            }
            if (this.v) {
                drawable.setTintMode(this.t);
            }
            this.w = false;
        }
        return drawable;
    }

    public char e() {
        return this.n.m() ? this.f4860j : this.f4858h;
    }

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

    public boolean f() {
        c.e.i.b bVar;
        if ((this.y & 8) == 0) {
            return false;
        }
        if (this.z == null && (bVar = this.A) != null) {
            this.z = bVar.d(this);
        }
        return this.z != null;
    }

    public boolean g() {
        return (this.x & 32) == 32;
    }

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

    @Override // c.e.e.a.b, android.view.MenuItem
    public View getActionView() {
        View view = this.z;
        if (view != null) {
            return view;
        }
        c.e.i.b bVar = this.A;
        if (bVar == null) {
            return null;
        }
        View viewD = bVar.d(this);
        this.z = viewD;
        return viewD;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public int getAlphabeticModifiers() {
        return this.k;
    }

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

    @Override // c.e.e.a.b, android.view.MenuItem
    public CharSequence getContentDescription() {
        return this.q;
    }

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

    @Override // android.view.MenuItem
    public Drawable getIcon() {
        Drawable drawable = this.l;
        if (drawable != null) {
            return d(drawable);
        }
        int i2 = this.m;
        if (i2 == 0) {
            return null;
        }
        Drawable drawableA = c.b.d.a.a.a(this.n.f4842b, i2);
        this.m = 0;
        this.l = drawableA;
        return d(drawableA);
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public ColorStateList getIconTintList() {
        return this.s;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public PorterDuff.Mode getIconTintMode() {
        return this.t;
    }

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

    @Override // android.view.MenuItem
    @ViewDebug.CapturedViewProperty
    public int getItemId() {
        return this.f4851a;
    }

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

    @Override // c.e.e.a.b, android.view.MenuItem
    public int getNumericModifiers() {
        return this.f4859i;
    }

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

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

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

    @Override // android.view.MenuItem
    @ViewDebug.CapturedViewProperty
    public CharSequence getTitle() {
        return this.f4855e;
    }

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

    @Override // c.e.e.a.b, android.view.MenuItem
    public CharSequence getTooltipText() {
        return this.r;
    }

    public boolean h() {
        return (this.x & 4) != 0;
    }

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

    public boolean i() {
        return (this.y & 1) == 1;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public boolean isActionViewExpanded() {
        return this.C;
    }

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

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

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

    @Override // android.view.MenuItem
    public boolean isVisible() {
        c.e.i.b bVar = this.A;
        return (bVar == null || !bVar.g()) ? (this.x & 8) == 0 : (this.x & 8) == 0 && this.A.b();
    }

    public c.e.e.a.b j(View view) {
        int i2;
        this.z = view;
        this.A = null;
        if (view != null && view.getId() == -1 && (i2 = this.f4851a) > 0) {
            view.setId(i2);
        }
        this.n.o();
        return this;
    }

    public void k(boolean z) {
        int i2 = this.x;
        int i3 = (z ? 2 : 0) | (i2 & (-3));
        this.x = i3;
        if (i2 != i3) {
            this.n.p(false);
        }
    }

    public void l(boolean z) {
        this.x = z ? this.x | 32 : this.x & (-33);
    }

    public boolean m(boolean z) {
        int i2 = this.x;
        int i3 = (z ? 0 : 8) | (i2 & (-9));
        this.x = i3;
        return i2 != i3;
    }

    public boolean n() {
        return this.n.n() && e() != 0;
    }

    public boolean requiresActionButton() {
        return (this.y & 2) == 2;
    }

    public boolean requiresOverflow() {
        return (requiresActionButton() || i()) ? false : true;
    }

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

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setActionView(int i2) {
        Context context = this.n.f4842b;
        j(LayoutInflater.from(context).inflate(i2, (ViewGroup) new LinearLayout(context), false));
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public /* bridge */ /* synthetic */ MenuItem setActionView(View view) {
        j(view);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setAlphabeticShortcut(char c2) {
        if (this.f4860j == c2) {
            return this;
        }
        this.f4860j = Character.toLowerCase(c2);
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setAlphabeticShortcut(char c2, int i2) {
        if (this.f4860j == c2 && this.k == i2) {
            return this;
        }
        this.f4860j = Character.toLowerCase(c2);
        this.k = KeyEvent.normalizeMetaState(i2);
        this.n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setCheckable(boolean z) {
        int i2 = this.x;
        int i3 = (z ? 1 : 0) | (i2 & (-2));
        this.x = i3;
        if (i2 != i3) {
            this.n.p(false);
        }
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setChecked(boolean z) {
        if ((this.x & 4) != 0) {
            f fVar = this.n;
            Objects.requireNonNull(fVar);
            int groupId = getGroupId();
            int size = fVar.f4847g.size();
            fVar.w();
            for (int i2 = 0; i2 < size; i2++) {
                g gVar = fVar.f4847g.get(i2);
                if (gVar.f4852b == groupId && gVar.h() && gVar.isCheckable()) {
                    gVar.k(gVar == this);
                }
            }
            fVar.v();
        } else {
            k(z);
        }
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setContentDescription(CharSequence charSequence) {
        this.q = charSequence;
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public c.e.e.a.b setContentDescription(CharSequence charSequence) {
        this.q = charSequence;
        this.n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setEnabled(boolean z) {
        this.x = z ? this.x | 16 : this.x & (-17);
        this.n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setIcon(int i2) {
        this.l = null;
        this.m = i2;
        this.w = true;
        this.n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setIcon(Drawable drawable) {
        this.m = 0;
        this.l = drawable;
        this.w = true;
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setIconTintList(ColorStateList colorStateList) {
        this.s = colorStateList;
        this.u = true;
        this.w = true;
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setIconTintMode(PorterDuff.Mode mode) {
        this.t = mode;
        this.v = true;
        this.w = true;
        this.n.p(false);
        return this;
    }

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

    @Override // android.view.MenuItem
    public MenuItem setNumericShortcut(char c2) {
        if (this.f4858h == c2) {
            return this;
        }
        this.f4858h = c2;
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setNumericShortcut(char c2, int i2) {
        if (this.f4858h == c2 && this.f4859i == i2) {
            return this;
        }
        this.f4858h = c2;
        this.f4859i = KeyEvent.normalizeMetaState(i2);
        this.n.p(false);
        return this;
    }

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

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

    @Override // android.view.MenuItem
    public MenuItem setShortcut(char c2, char c3) {
        this.f4858h = c2;
        this.f4860j = Character.toLowerCase(c3);
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setShortcut(char c2, char c3, int i2, int i3) {
        this.f4858h = c2;
        this.f4859i = KeyEvent.normalizeMetaState(i2);
        this.f4860j = Character.toLowerCase(c3);
        this.k = KeyEvent.normalizeMetaState(i3);
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public void setShowAsAction(int i2) {
        int i3 = i2 & 3;
        if (i3 != 0 && i3 != 1 && i3 != 2) {
            throw new IllegalArgumentException("SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, and SHOW_AS_ACTION_NEVER are mutually exclusive.");
        }
        this.y = i2;
        this.n.o();
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public MenuItem setShowAsActionFlags(int i2) {
        setShowAsAction(i2);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setTitle(int i2) {
        setTitle(this.n.f4842b.getString(i2));
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setTitle(CharSequence charSequence) {
        this.f4855e = charSequence;
        this.n.p(false);
        p pVar = this.o;
        if (pVar != null) {
            pVar.setHeaderTitle(charSequence);
        }
        return this;
    }

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

    @Override // android.view.MenuItem
    public MenuItem setTooltipText(CharSequence charSequence) {
        this.r = charSequence;
        this.n.p(false);
        return this;
    }

    @Override // c.e.e.a.b, android.view.MenuItem
    public c.e.e.a.b setTooltipText(CharSequence charSequence) {
        this.r = charSequence;
        this.n.p(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setVisible(boolean z) {
        if (m(z)) {
            f fVar = this.n;
            fVar.f4849i = true;
            fVar.p(true);
        }
        return this;
    }

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