package d.b.f.i;

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 d.h.j.e;
import java.util.Objects;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public i(g gVar, int i2, int i3, int i4, int i5, CharSequence charSequence, int i6) {
        this.f1837y = 0;
        this.f1826n = gVar;
        this.a = i3;
        this.f1814b = i2;
        this.f1815c = i4;
        this.f1816d = i5;
        this.f1817e = charSequence;
        this.f1837y = i6;
    }

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

    @Override // d.h.e.a.b
    public d.h.e.a.b a(d.h.j.e eVar) {
        d.h.j.e eVar2 = this.A;
        if (eVar2 != null) {
            eVar2.a = null;
        }
        this.f1838z = null;
        this.A = eVar;
        this.f1826n.q(true);
        d.h.j.e eVar3 = this.A;
        if (eVar3 != null) {
            eVar3.h(new a());
        }
        return this;
    }

    @Override // d.h.e.a.b
    public d.h.j.e b() {
        return this.A;
    }

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

    public final Drawable d(Drawable drawable) {
        if (drawable != null && this.f1835w && (this.f1833u || this.f1834v)) {
            drawable = drawable.mutate();
            if (this.f1833u) {
                d.h.d.k.b.h(drawable, this.f1831s);
            }
            if (this.f1834v) {
                d.h.d.k.b.i(drawable, this.f1832t);
            }
            this.f1835w = false;
        }
        return drawable;
    }

    public char e() {
        return this.f1826n.n() ? this.f1822j : this.f1820h;
    }

    @Override // d.h.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.f1826n.f(this);
        }
        return false;
    }

    public boolean f() {
        d.h.j.e eVar;
        if ((this.f1837y & 8) == 0) {
            return false;
        }
        if (this.f1838z == null && (eVar = this.A) != null) {
            this.f1838z = eVar.d(this);
        }
        return this.f1838z != null;
    }

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

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

    @Override // d.h.e.a.b, android.view.MenuItem
    public View getActionView() {
        View view = this.f1838z;
        if (view != null) {
            return view;
        }
        d.h.j.e eVar = this.A;
        if (eVar == null) {
            return null;
        }
        View viewD = eVar.d(this);
        this.f1838z = viewD;
        return viewD;
    }

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

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

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

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

    @Override // android.view.MenuItem
    public Drawable getIcon() {
        Drawable drawable = this.f1824l;
        if (drawable != null) {
            return d(drawable);
        }
        int i2 = this.f1825m;
        if (i2 == 0) {
            return null;
        }
        Drawable drawableA = d.b.d.a.a.a(this.f1826n.f1787b, i2);
        this.f1825m = 0;
        this.f1824l = drawableA;
        return d(drawableA);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public d.h.e.a.b i(View view) {
        int i2;
        this.f1838z = view;
        this.A = null;
        if (view != null && view.getId() == -1 && (i2 = this.a) > 0) {
            view.setId(i2);
        }
        this.f1826n.p();
        return this;
    }

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

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

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

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

    @Override // android.view.MenuItem
    public boolean isVisible() {
        d.h.j.e eVar = this.A;
        return (eVar == null || !eVar.g()) ? (this.f1836x & 8) == 0 : (this.f1836x & 8) == 0 && this.A.b();
    }

    public void j(boolean z2) {
        int i2 = this.f1836x;
        int i3 = (z2 ? 2 : 0) | (i2 & (-3));
        this.f1836x = i3;
        if (i2 != i3) {
            this.f1826n.q(false);
        }
    }

    public void k(boolean z2) {
        this.f1836x = z2 ? this.f1836x | 32 : this.f1836x & (-33);
    }

    public boolean l(boolean z2) {
        int i2 = this.f1836x;
        int i3 = (z2 ? 0 : 8) | (i2 & (-9));
        this.f1836x = i3;
        return i2 != i3;
    }

    public boolean m() {
        return this.f1826n.o() && e() != 0;
    }

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

    @Override // d.h.e.a.b, android.view.MenuItem
    public MenuItem setActionView(int i2) {
        Context context = this.f1826n.f1787b;
        i(LayoutInflater.from(context).inflate(i2, (ViewGroup) new LinearLayout(context), false));
        return this;
    }

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

    @Override // android.view.MenuItem
    public MenuItem setAlphabeticShortcut(char c2) {
        if (this.f1822j == c2) {
            return this;
        }
        this.f1822j = Character.toLowerCase(c2);
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.e.a.b, android.view.MenuItem
    public MenuItem setAlphabeticShortcut(char c2, int i2) {
        if (this.f1822j == c2 && this.f1823k == i2) {
            return this;
        }
        this.f1822j = Character.toLowerCase(c2);
        this.f1823k = KeyEvent.normalizeMetaState(i2);
        this.f1826n.q(false);
        return this;
    }

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

    @Override // android.view.MenuItem
    public MenuItem setChecked(boolean z2) {
        if ((this.f1836x & 4) != 0) {
            g gVar = this.f1826n;
            Objects.requireNonNull(gVar);
            int groupId = getGroupId();
            int size = gVar.f1792g.size();
            gVar.z();
            for (int i2 = 0; i2 < size; i2++) {
                i iVar = gVar.f1792g.get(i2);
                if (iVar.f1814b == groupId && iVar.h() && iVar.isCheckable()) {
                    iVar.j(iVar == this);
                }
            }
            gVar.y();
        } else {
            j(z2);
        }
        return this;
    }

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

    @Override // d.h.e.a.b, android.view.MenuItem
    public d.h.e.a.b setContentDescription(CharSequence charSequence) {
        this.f1829q = charSequence;
        this.f1826n.q(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setEnabled(boolean z2) {
        this.f1836x = z2 ? this.f1836x | 16 : this.f1836x & (-17);
        this.f1826n.q(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setIcon(int i2) {
        this.f1824l = null;
        this.f1825m = i2;
        this.f1835w = true;
        this.f1826n.q(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setIcon(Drawable drawable) {
        this.f1825m = 0;
        this.f1824l = drawable;
        this.f1835w = true;
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.e.a.b, android.view.MenuItem
    public MenuItem setIconTintList(ColorStateList colorStateList) {
        this.f1831s = colorStateList;
        this.f1833u = true;
        this.f1835w = true;
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.e.a.b, android.view.MenuItem
    public MenuItem setIconTintMode(PorterDuff.Mode mode) {
        this.f1832t = mode;
        this.f1834v = true;
        this.f1835w = true;
        this.f1826n.q(false);
        return this;
    }

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

    @Override // android.view.MenuItem
    public MenuItem setNumericShortcut(char c2) {
        if (this.f1820h == c2) {
            return this;
        }
        this.f1820h = c2;
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.e.a.b, android.view.MenuItem
    public MenuItem setNumericShortcut(char c2, int i2) {
        if (this.f1820h == c2 && this.f1821i == i2) {
            return this;
        }
        this.f1820h = c2;
        this.f1821i = KeyEvent.normalizeMetaState(i2);
        this.f1826n.q(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.f1828p = onMenuItemClickListener;
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setShortcut(char c2, char c3) {
        this.f1820h = c2;
        this.f1822j = Character.toLowerCase(c3);
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.e.a.b, android.view.MenuItem
    public MenuItem setShortcut(char c2, char c3, int i2, int i3) {
        this.f1820h = c2;
        this.f1821i = KeyEvent.normalizeMetaState(i2);
        this.f1822j = Character.toLowerCase(c3);
        this.f1823k = KeyEvent.normalizeMetaState(i3);
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.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.f1837y = i2;
        this.f1826n.p();
    }

    @Override // d.h.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.f1826n.f1787b.getString(i2));
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setTitle(CharSequence charSequence) {
        this.f1817e = charSequence;
        this.f1826n.q(false);
        r rVar = this.f1827o;
        if (rVar != null) {
            rVar.setHeaderTitle(charSequence);
        }
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setTitleCondensed(CharSequence charSequence) {
        this.f1818f = charSequence;
        this.f1826n.q(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setTooltipText(CharSequence charSequence) {
        this.f1830r = charSequence;
        this.f1826n.q(false);
        return this;
    }

    @Override // d.h.e.a.b, android.view.MenuItem
    public d.h.e.a.b setTooltipText(CharSequence charSequence) {
        this.f1830r = charSequence;
        this.f1826n.q(false);
        return this;
    }

    @Override // android.view.MenuItem
    public MenuItem setVisible(boolean z2) {
        if (l(z2)) {
            g gVar = this.f1826n;
            gVar.f1794i = true;
            gVar.q(true);
        }
        return this;
    }

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