package d.b.g;

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.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.widget.Toolbar.d;
import com.ifpdos.udi.service.core.pc.R;
import d.b.f.i.g;
import d.b.f.i.m;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class b1 implements f0 {
    public Toolbar a;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public Window.Callback f1909l;

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

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

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

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

    public class a extends d.h.j.f0 {
        public boolean a = false;

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

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

        @Override // d.h.j.f0, d.h.j.e0
        public void a(View view) {
            this.a = true;
        }

        @Override // d.h.j.e0
        public void b(View view) {
            if (this.a) {
                return;
            }
            b1.this.a.setVisibility(this.f1914b);
        }

        @Override // d.h.j.f0, d.h.j.e0
        public void c(View view) {
            b1.this.a.setVisibility(0);
        }
    }

    public b1(Toolbar toolbar, boolean z2) {
        Drawable drawable;
        this.f1912o = 0;
        this.a = toolbar;
        this.f1906i = toolbar.getTitle();
        this.f1907j = toolbar.getSubtitle();
        this.f1905h = this.f1906i != null;
        this.f1904g = toolbar.getNavigationIcon();
        z0 z0VarQ = z0.q(toolbar.getContext(), null, d.b.b.a, R.attr.actionBarStyle, 0);
        int i2 = 15;
        this.f1913p = z0VarQ.g(15);
        if (z2) {
            CharSequence charSequenceN = z0VarQ.n(27);
            if (!TextUtils.isEmpty(charSequenceN)) {
                this.f1905h = true;
                this.f1906i = charSequenceN;
                if ((this.f1899b & 8) != 0) {
                    this.a.setTitle(charSequenceN);
                }
            }
            CharSequence charSequenceN2 = z0VarQ.n(25);
            if (!TextUtils.isEmpty(charSequenceN2)) {
                this.f1907j = charSequenceN2;
                if ((this.f1899b & 8) != 0) {
                    this.a.setSubtitle(charSequenceN2);
                }
            }
            Drawable drawableG = z0VarQ.g(20);
            if (drawableG != null) {
                this.f1903f = drawableG;
                z();
            }
            Drawable drawableG2 = z0VarQ.g(17);
            if (drawableG2 != null) {
                this.f1902e = drawableG2;
                z();
            }
            if (this.f1904g == null && (drawable = this.f1913p) != null) {
                this.f1904g = drawable;
                y();
            }
            k(z0VarQ.j(10, 0));
            int iL = z0VarQ.l(9, 0);
            if (iL != 0) {
                View viewInflate = LayoutInflater.from(this.a.getContext()).inflate(iL, (ViewGroup) this.a, false);
                View view = this.f1901d;
                if (view != null && (this.f1899b & 16) != 0) {
                    this.a.removeView(view);
                }
                this.f1901d = viewInflate;
                if (viewInflate != null && (this.f1899b & 16) != 0) {
                    this.a.addView(viewInflate);
                }
                k(this.f1899b | 16);
            }
            int iK = z0VarQ.k(13, 0);
            if (iK > 0) {
                ViewGroup.LayoutParams layoutParams = this.a.getLayoutParams();
                layoutParams.height = iK;
                this.a.setLayoutParams(layoutParams);
            }
            int iE = z0VarQ.e(7, -1);
            int iE2 = z0VarQ.e(3, -1);
            if (iE >= 0 || iE2 >= 0) {
                Toolbar toolbar2 = this.a;
                int iMax = Math.max(iE, 0);
                int iMax2 = Math.max(iE2, 0);
                toolbar2.d();
                toolbar2.E.a(iMax, iMax2);
            }
            int iL2 = z0VarQ.l(28, 0);
            if (iL2 != 0) {
                Toolbar toolbar3 = this.a;
                Context context = toolbar3.getContext();
                toolbar3.f552w = iL2;
                TextView textView = toolbar3.f542m;
                if (textView != null) {
                    textView.setTextAppearance(context, iL2);
                }
            }
            int iL3 = z0VarQ.l(26, 0);
            if (iL3 != 0) {
                Toolbar toolbar4 = this.a;
                Context context2 = toolbar4.getContext();
                toolbar4.f553x = iL3;
                TextView textView2 = toolbar4.f543n;
                if (textView2 != null) {
                    textView2.setTextAppearance(context2, iL3);
                }
            }
            int iL4 = z0VarQ.l(22, 0);
            if (iL4 != 0) {
                this.a.setPopupTheme(iL4);
            }
        } else {
            if (this.a.getNavigationIcon() != null) {
                this.f1913p = this.a.getNavigationIcon();
            } else {
                i2 = 11;
            }
            this.f1899b = i2;
        }
        z0VarQ.f2138b.recycle();
        if (R.string.abc_action_bar_up_description != this.f1912o) {
            this.f1912o = R.string.abc_action_bar_up_description;
            if (TextUtils.isEmpty(this.a.getNavigationContentDescription())) {
                int i3 = this.f1912o;
                this.f1908k = i3 != 0 ? getContext().getString(i3) : null;
                x();
            }
        }
        this.f1908k = this.a.getNavigationContentDescription();
        this.a.setNavigationOnClickListener(new a1(this));
    }

    @Override // d.b.g.f0
    public void a(Menu menu, m.a aVar) {
        d.b.f.i.i iVar;
        if (this.f1911n == null) {
            c cVar = new c(this.a.getContext());
            this.f1911n = cVar;
            Objects.requireNonNull(cVar);
        }
        c cVar2 = this.f1911n;
        cVar2.f1744p = aVar;
        Toolbar toolbar = this.a;
        d.b.f.i.g gVar = (d.b.f.i.g) menu;
        if (gVar == null && toolbar.f541f == null) {
            return;
        }
        toolbar.f();
        d.b.f.i.g gVar2 = toolbar.f541f.A;
        if (gVar2 == gVar) {
            return;
        }
        if (gVar2 != null) {
            gVar2.u(toolbar.U);
            gVar2.u(toolbar.V);
        }
        if (toolbar.V == null) {
            toolbar.V = toolbar.new d();
        }
        cVar2.B = true;
        if (gVar != null) {
            gVar.b(cVar2, toolbar.f550u);
            gVar.b(toolbar.V, toolbar.f550u);
        } else {
            cVar2.i(toolbar.f550u, null);
            Toolbar.d dVar = toolbar.V;
            d.b.f.i.g gVar3 = dVar.f558f;
            if (gVar3 != null && (iVar = dVar.f559m) != null) {
                gVar3.d(iVar);
            }
            dVar.f558f = null;
            cVar2.c(true);
            toolbar.V.c(true);
        }
        toolbar.f541f.setPopupTheme(toolbar.f551v);
        toolbar.f541f.setPresenter(cVar2);
        toolbar.U = cVar2;
    }

    @Override // d.b.g.f0
    public boolean b() {
        return this.a.p();
    }

    @Override // d.b.g.f0
    public void c() {
        this.f1910m = true;
    }

    @Override // d.b.g.f0
    public void collapseActionView() {
        Toolbar.d dVar = this.a.V;
        d.b.f.i.i iVar = dVar == null ? null : dVar.f559m;
        if (iVar != null) {
            iVar.collapseActionView();
        }
    }

    @Override // d.b.g.f0
    public boolean d() {
        ActionMenuView actionMenuView;
        Toolbar toolbar = this.a;
        return toolbar.getVisibility() == 0 && (actionMenuView = toolbar.f541f) != null && actionMenuView.D;
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x001e  */
    /* JADX WARN: Removed duplicated region for block: B:20:? A[RETURN, SYNTHETIC] */
    @Override // d.b.g.f0
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean e() {
        /*
            r4 = this;
            androidx.appcompat.widget.Toolbar r0 = r4.a
            androidx.appcompat.widget.ActionMenuView r0 = r0.f541f
            r1 = 1
            r2 = 0
            if (r0 == 0) goto L22
            d.b.g.c r0 = r0.E
            if (r0 == 0) goto L1e
            d.b.g.c$c r3 = r0.G
            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: d.b.g.b1.e():boolean");
    }

    @Override // d.b.g.f0
    public boolean f() {
        ActionMenuView actionMenuView = this.a.f541f;
        if (actionMenuView != null) {
            c cVar = actionMenuView.E;
            if (cVar != null && cVar.j()) {
                return true;
            }
        }
        return false;
    }

    @Override // d.b.g.f0
    public boolean g() {
        return this.a.v();
    }

    @Override // d.b.g.f0
    public Context getContext() {
        return this.a.getContext();
    }

    @Override // d.b.g.f0
    public CharSequence getTitle() {
        return this.a.getTitle();
    }

    @Override // d.b.g.f0
    public void h() {
        c cVar;
        ActionMenuView actionMenuView = this.a.f541f;
        if (actionMenuView == null || (cVar = actionMenuView.E) == null) {
            return;
        }
        cVar.a();
    }

    @Override // d.b.g.f0
    public void i(s0 s0Var) {
        View view = this.f1900c;
        if (view != null) {
            ViewParent parent = view.getParent();
            Toolbar toolbar = this.a;
            if (parent == toolbar) {
                toolbar.removeView(this.f1900c);
            }
        }
        this.f1900c = null;
    }

    @Override // d.b.g.f0
    public boolean j() {
        Toolbar.d dVar = this.a.V;
        return (dVar == null || dVar.f559m == null) ? false : true;
    }

    @Override // d.b.g.f0
    public void k(int i2) {
        View view;
        CharSequence charSequence;
        Toolbar toolbar;
        int i3 = this.f1899b ^ i2;
        this.f1899b = i2;
        if (i3 != 0) {
            if ((i3 & 4) != 0) {
                if ((i2 & 4) != 0) {
                    x();
                }
                y();
            }
            if ((i3 & 3) != 0) {
                z();
            }
            if ((i3 & 8) != 0) {
                if ((i2 & 8) != 0) {
                    this.a.setTitle(this.f1906i);
                    toolbar = this.a;
                    charSequence = this.f1907j;
                } else {
                    charSequence = null;
                    this.a.setTitle((CharSequence) null);
                    toolbar = this.a;
                }
                toolbar.setSubtitle(charSequence);
            }
            if ((i3 & 16) == 0 || (view = this.f1901d) == null) {
                return;
            }
            if ((i2 & 16) != 0) {
                this.a.addView(view);
            } else {
                this.a.removeView(view);
            }
        }
    }

    @Override // d.b.g.f0
    public Menu l() {
        return this.a.getMenu();
    }

    @Override // d.b.g.f0
    public void m(int i2) {
        this.f1903f = i2 != 0 ? d.b.d.a.a.a(getContext(), i2) : null;
        z();
    }

    @Override // d.b.g.f0
    public int n() {
        return 0;
    }

    @Override // d.b.g.f0
    public d.h.j.d0 o(int i2, long j2) {
        d.h.j.d0 d0VarB = d.h.j.y.b(this.a);
        d0VarB.a(i2 == 0 ? 1.0f : 0.0f);
        d0VarB.c(j2);
        a aVar = new a(i2);
        View view = d0VarB.a.get();
        if (view != null) {
            d0VarB.e(view, aVar);
        }
        return d0VarB;
    }

    @Override // d.b.g.f0
    public void p(m.a aVar, g.a aVar2) {
        Toolbar toolbar = this.a;
        toolbar.W = aVar;
        toolbar.f538a0 = aVar2;
        ActionMenuView actionMenuView = toolbar.f541f;
        if (actionMenuView != null) {
            actionMenuView.F = aVar;
            actionMenuView.G = aVar2;
        }
    }

    @Override // d.b.g.f0
    public void q(int i2) {
        this.a.setVisibility(i2);
    }

    @Override // d.b.g.f0
    public ViewGroup r() {
        return this.a;
    }

    @Override // d.b.g.f0
    public void s(boolean z2) {
    }

    @Override // d.b.g.f0
    public void setIcon(int i2) {
        this.f1902e = i2 != 0 ? d.b.d.a.a.a(getContext(), i2) : null;
        z();
    }

    @Override // d.b.g.f0
    public void setIcon(Drawable drawable) {
        this.f1902e = drawable;
        z();
    }

    @Override // d.b.g.f0
    public void setWindowCallback(Window.Callback callback) {
        this.f1909l = callback;
    }

    @Override // d.b.g.f0
    public void setWindowTitle(CharSequence charSequence) {
        if (this.f1905h) {
            return;
        }
        this.f1906i = charSequence;
        if ((this.f1899b & 8) != 0) {
            this.a.setTitle(charSequence);
        }
    }

    @Override // d.b.g.f0
    public int t() {
        return this.f1899b;
    }

    @Override // d.b.g.f0
    public void u() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    @Override // d.b.g.f0
    public void v() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    @Override // d.b.g.f0
    public void w(boolean z2) {
        this.a.setCollapsible(z2);
    }

    public final void x() {
        if ((this.f1899b & 4) != 0) {
            if (TextUtils.isEmpty(this.f1908k)) {
                this.a.setNavigationContentDescription(this.f1912o);
            } else {
                this.a.setNavigationContentDescription(this.f1908k);
            }
        }
    }

    public final void y() {
        Toolbar toolbar;
        Drawable drawable;
        if ((this.f1899b & 4) != 0) {
            toolbar = this.a;
            drawable = this.f1904g;
            if (drawable == null) {
                drawable = this.f1913p;
            }
        } else {
            toolbar = this.a;
            drawable = null;
        }
        toolbar.setNavigationIcon(drawable);
    }

    public final void z() {
        Drawable drawable;
        int i2 = this.f1899b;
        if ((i2 & 2) == 0) {
            drawable = null;
        } else if ((i2 & 1) == 0 || (drawable = this.f1903f) == null) {
            drawable = this.f1902e;
        }
        this.a.setLogo(drawable);
    }
}
