package c.b.f;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.widget.TextView;
import androidx.appcompat.widget.ActionMenuPresenter;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.Toolbar.f;
import c.b.e.i.g;
import c.b.e.i.m;
import com.ifpdos.debugmenu.R;
import java.util.Objects;

/* JADX INFO: compiled from: ToolbarWidgetWrapper.java */
/* JADX INFO: loaded from: classes.dex */
public class f1 implements j0 {
    public Toolbar a;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public Window.Callback f835l;
    public boolean m;
    public ActionMenuPresenter n;
    public int o;
    public Drawable p;

    /* JADX INFO: compiled from: ToolbarWidgetWrapper.java */
    public class a extends c.f.j.k0 {
        public boolean a = false;

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

        public a(int i2) {
            this.f836b = i2;
        }

        @Override // c.f.j.k0, c.f.j.j0
        public void a(View view) {
            this.a = true;
        }

        @Override // c.f.j.j0
        public void b(View view) {
            if (this.a) {
                return;
            }
            f1.this.a.setVisibility(this.f836b);
        }

        @Override // c.f.j.k0, c.f.j.j0
        public void c(View view) {
            f1.this.a.setVisibility(0);
        }
    }

    public f1(Toolbar toolbar, boolean z) {
        Drawable drawable;
        this.o = 0;
        this.a = toolbar;
        this.f832i = toolbar.getTitle();
        this.f833j = toolbar.getSubtitle();
        this.f831h = this.f832i != null;
        this.f830g = toolbar.getNavigationIcon();
        d1 d1VarO = d1.o(toolbar.getContext(), null, c.b.b.a, R.attr.actionBarStyle, 0);
        int i2 = 15;
        this.p = d1VarO.e(15);
        if (z) {
            CharSequence charSequenceL = d1VarO.l(27);
            if (!TextUtils.isEmpty(charSequenceL)) {
                this.f831h = true;
                y(charSequenceL);
            }
            CharSequence charSequenceL2 = d1VarO.l(25);
            if (!TextUtils.isEmpty(charSequenceL2)) {
                this.f833j = charSequenceL2;
                if ((this.f825b & 8) != 0) {
                    this.a.setSubtitle(charSequenceL2);
                }
            }
            Drawable drawableE = d1VarO.e(20);
            if (drawableE != null) {
                this.f829f = drawableE;
                B();
            }
            Drawable drawableE2 = d1VarO.e(17);
            if (drawableE2 != null) {
                this.f828e = drawableE2;
                B();
            }
            if (this.f830g == null && (drawable = this.p) != null) {
                this.f830g = drawable;
                A();
            }
            l(d1VarO.h(10, 0));
            int iJ = d1VarO.j(9, 0);
            if (iJ != 0) {
                View viewInflate = LayoutInflater.from(this.a.getContext()).inflate(iJ, (ViewGroup) this.a, false);
                View view = this.f827d;
                if (view != null && (this.f825b & 16) != 0) {
                    this.a.removeView(view);
                }
                this.f827d = viewInflate;
                if (viewInflate != null && (this.f825b & 16) != 0) {
                    this.a.addView(viewInflate);
                }
                l(this.f825b | 16);
            }
            int i3 = d1VarO.i(13, 0);
            if (i3 > 0) {
                ViewGroup.LayoutParams layoutParams = this.a.getLayoutParams();
                layoutParams.height = i3;
                this.a.setLayoutParams(layoutParams);
            }
            int iC = d1VarO.c(7, -1);
            int iC2 = d1VarO.c(3, -1);
            if (iC >= 0 || iC2 >= 0) {
                Toolbar toolbar2 = this.a;
                int iMax = Math.max(iC, 0);
                int iMax2 = Math.max(iC2, 0);
                toolbar2.e();
                toolbar2.w.a(iMax, iMax2);
            }
            int iJ2 = d1VarO.j(28, 0);
            if (iJ2 != 0) {
                Toolbar toolbar3 = this.a;
                Context context = toolbar3.getContext();
                toolbar3.o = iJ2;
                TextView textView = toolbar3.f203e;
                if (textView != null) {
                    textView.setTextAppearance(context, iJ2);
                }
            }
            int iJ3 = d1VarO.j(26, 0);
            if (iJ3 != 0) {
                Toolbar toolbar4 = this.a;
                Context context2 = toolbar4.getContext();
                toolbar4.p = iJ3;
                TextView textView2 = toolbar4.f204f;
                if (textView2 != null) {
                    textView2.setTextAppearance(context2, iJ3);
                }
            }
            int iJ4 = d1VarO.j(22, 0);
            if (iJ4 != 0) {
                this.a.setPopupTheme(iJ4);
            }
        } else {
            if (this.a.getNavigationIcon() != null) {
                this.p = this.a.getNavigationIcon();
            } else {
                i2 = 11;
            }
            this.f825b = i2;
        }
        d1VarO.f806b.recycle();
        if (R.string.abc_action_bar_up_description != this.o) {
            this.o = R.string.abc_action_bar_up_description;
            if (TextUtils.isEmpty(this.a.getNavigationContentDescription())) {
                int i4 = this.o;
                this.f834k = i4 != 0 ? e().getString(i4) : null;
                z();
            }
        }
        this.f834k = this.a.getNavigationContentDescription();
        this.a.setNavigationOnClickListener(new e1(this));
    }

    public final void A() {
        if ((this.f825b & 4) == 0) {
            this.a.setNavigationIcon((Drawable) null);
            return;
        }
        Toolbar toolbar = this.a;
        Drawable drawable = this.f830g;
        if (drawable == null) {
            drawable = this.p;
        }
        toolbar.setNavigationIcon(drawable);
    }

    public final void B() {
        Drawable drawable;
        int i2 = this.f825b;
        if ((i2 & 2) == 0) {
            drawable = null;
        } else if ((i2 & 1) == 0 || (drawable = this.f829f) == null) {
            drawable = this.f828e;
        }
        this.a.setLogo(drawable);
    }

    @Override // c.b.f.j0
    public void a(Menu menu, m.a aVar) {
        c.b.e.i.i iVar;
        if (this.n == null) {
            ActionMenuPresenter actionMenuPresenter = new ActionMenuPresenter(this.a.getContext());
            this.n = actionMenuPresenter;
            Objects.requireNonNull(actionMenuPresenter);
        }
        ActionMenuPresenter actionMenuPresenter2 = this.n;
        actionMenuPresenter2.f675h = aVar;
        Toolbar toolbar = this.a;
        c.b.e.i.g gVar = (c.b.e.i.g) menu;
        if (gVar == null && toolbar.f202b == null) {
            return;
        }
        toolbar.g();
        c.b.e.i.g gVar2 = toolbar.f202b.s;
        if (gVar2 == gVar) {
            return;
        }
        if (gVar2 != null) {
            gVar2.u(toolbar.O);
            gVar2.u(toolbar.P);
        }
        if (toolbar.P == null) {
            toolbar.P = toolbar.new f();
        }
        actionMenuPresenter2.t = true;
        if (gVar != null) {
            gVar.b(actionMenuPresenter2, toolbar.m);
            gVar.b(toolbar.P, toolbar.m);
        } else {
            actionMenuPresenter2.i(toolbar.m, null);
            Toolbar.f fVar = toolbar.P;
            c.b.e.i.g gVar3 = fVar.f216b;
            if (gVar3 != null && (iVar = fVar.f217e) != null) {
                gVar3.d(iVar);
            }
            fVar.f216b = null;
            actionMenuPresenter2.c(true);
            toolbar.P.c(true);
        }
        toolbar.f202b.setPopupTheme(toolbar.n);
        toolbar.f202b.setPresenter(actionMenuPresenter2);
        toolbar.O = actionMenuPresenter2;
        toolbar.x();
    }

    @Override // c.b.f.j0
    public boolean b() {
        return this.a.q();
    }

    @Override // c.b.f.j0
    public void c() {
        this.m = true;
    }

    @Override // c.b.f.j0
    public void collapseActionView() {
        this.a.c();
    }

    @Override // c.b.f.j0
    public boolean d() {
        ActionMenuView actionMenuView;
        Toolbar toolbar = this.a;
        return toolbar.getVisibility() == 0 && (actionMenuView = toolbar.f202b) != null && actionMenuView.v;
    }

    @Override // c.b.f.j0
    public Context e() {
        return this.a.getContext();
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x001e  */
    /* JADX WARN: Removed duplicated region for block: B:20:? A[RETURN, SYNTHETIC] */
    @Override // c.b.f.j0
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean f() {
        /*
            r4 = this;
            androidx.appcompat.widget.Toolbar r0 = r4.a
            androidx.appcompat.widget.ActionMenuView r0 = r0.f202b
            r1 = 1
            r2 = 0
            if (r0 == 0) goto L22
            androidx.appcompat.widget.ActionMenuPresenter r0 = r0.w
            if (r0 == 0) goto L1e
            androidx.appcompat.widget.ActionMenuPresenter$c r3 = r0.y
            if (r3 != 0) goto L19
            boolean r0 = r0.m()
            if (r0 == 0) goto L17
            goto L19
        L17:
            r0 = r2
            goto L1a
        L19:
            r0 = r1
        L1a:
            if (r0 == 0) goto L1e
            r0 = r1
            goto L1f
        L1e:
            r0 = r2
        L1f:
            if (r0 == 0) goto L22
            goto L23
        L22:
            r1 = r2
        L23:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: c.b.f.f1.f():boolean");
    }

    @Override // c.b.f.j0
    public boolean g() {
        ActionMenuView actionMenuView = this.a.f202b;
        if (actionMenuView != null) {
            ActionMenuPresenter actionMenuPresenter = actionMenuView.w;
            if (actionMenuPresenter != null && actionMenuPresenter.j()) {
                return true;
            }
        }
        return false;
    }

    @Override // c.b.f.j0
    public CharSequence getTitle() {
        return this.a.getTitle();
    }

    @Override // c.b.f.j0
    public boolean h() {
        return this.a.w();
    }

    @Override // c.b.f.j0
    public void i() {
        ActionMenuPresenter actionMenuPresenter;
        ActionMenuView actionMenuView = this.a.f202b;
        if (actionMenuView == null || (actionMenuPresenter = actionMenuView.w) == null) {
            return;
        }
        actionMenuPresenter.a();
    }

    @Override // c.b.f.j0
    public void j(w0 w0Var) {
        View view = this.f826c;
        if (view != null) {
            ViewParent parent = view.getParent();
            Toolbar toolbar = this.a;
            if (parent == toolbar) {
                toolbar.removeView(this.f826c);
            }
        }
        this.f826c = null;
    }

    @Override // c.b.f.j0
    public boolean k() {
        Toolbar.f fVar = this.a.P;
        return (fVar == null || fVar.f217e == null) ? false : true;
    }

    @Override // c.b.f.j0
    public void l(int i2) {
        View view;
        int i3 = this.f825b ^ i2;
        this.f825b = i2;
        if (i3 != 0) {
            if ((i3 & 4) != 0) {
                if ((i2 & 4) != 0) {
                    z();
                }
                A();
            }
            if ((i3 & 3) != 0) {
                B();
            }
            if ((i3 & 8) != 0) {
                if ((i2 & 8) != 0) {
                    this.a.setTitle(this.f832i);
                    this.a.setSubtitle(this.f833j);
                } else {
                    this.a.setTitle((CharSequence) null);
                    this.a.setSubtitle((CharSequence) null);
                }
            }
            if ((i3 & 16) == 0 || (view = this.f827d) == null) {
                return;
            }
            if ((i2 & 16) != 0) {
                this.a.addView(view);
            } else {
                this.a.removeView(view);
            }
        }
    }

    @Override // c.b.f.j0
    public Menu m() {
        return this.a.getMenu();
    }

    @Override // c.b.f.j0
    public void n(int i2) {
        this.f829f = i2 != 0 ? c.b.a.e(e(), i2) : null;
        B();
    }

    @Override // c.b.f.j0
    public int o() {
        return 0;
    }

    @Override // c.b.f.j0
    public c.f.j.i0 p(int i2, long j2) {
        c.f.j.i0 i0VarA = c.f.j.a0.a(this.a);
        i0VarA.a(i2 == 0 ? 1.0f : 0.0f);
        i0VarA.c(j2);
        a aVar = new a(i2);
        View view = i0VarA.a.get();
        if (view != null) {
            i0VarA.e(view, aVar);
        }
        return i0VarA;
    }

    @Override // c.b.f.j0
    public void q(m.a aVar, g.a aVar2) {
        Toolbar toolbar = this.a;
        toolbar.Q = aVar;
        toolbar.R = aVar2;
        ActionMenuView actionMenuView = toolbar.f202b;
        if (actionMenuView != null) {
            actionMenuView.x = aVar;
            actionMenuView.y = aVar2;
        }
    }

    @Override // c.b.f.j0
    public void r(int i2) {
        this.a.setVisibility(i2);
    }

    @Override // c.b.f.j0
    public ViewGroup s() {
        return this.a;
    }

    @Override // c.b.f.j0
    public void setIcon(int i2) {
        this.f828e = i2 != 0 ? c.b.a.e(e(), i2) : null;
        B();
    }

    @Override // c.b.f.j0
    public void setWindowCallback(Window.Callback callback) {
        this.f835l = callback;
    }

    @Override // c.b.f.j0
    public void setWindowTitle(CharSequence charSequence) {
        if (this.f831h) {
            return;
        }
        y(charSequence);
    }

    @Override // c.b.f.j0
    public void t(boolean z) {
    }

    @Override // c.b.f.j0
    public int u() {
        return this.f825b;
    }

    @Override // c.b.f.j0
    public void v() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    @Override // c.b.f.j0
    public void w() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    @Override // c.b.f.j0
    public void x(boolean z) {
        this.a.setCollapsible(z);
    }

    public final void y(CharSequence charSequence) {
        this.f832i = charSequence;
        if ((this.f825b & 8) != 0) {
            this.a.setTitle(charSequence);
            if (this.f831h) {
                c.f.j.a0.m(this.a.getRootView(), charSequence);
            }
        }
    }

    public final void z() {
        if ((this.f825b & 4) != 0) {
            if (TextUtils.isEmpty(this.f834k)) {
                this.a.setNavigationContentDescription(this.o);
            } else {
                this.a.setNavigationContentDescription(this.f834k);
            }
        }
    }

    @Override // c.b.f.j0
    public void setIcon(Drawable drawable) {
        this.f828e = drawable;
        B();
    }
}
