package c.a.g;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import com.ifpdos.multiuser.R;

/* JADX INFO: loaded from: classes.dex */
public class n0 implements s {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Toolbar f5020a;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public CharSequence f5029j;
    public Window.Callback k;
    public boolean l;
    public int m;
    public Drawable n;

    public n0(Toolbar toolbar, boolean z) {
        Drawable drawable;
        this.m = 0;
        this.f5020a = toolbar;
        this.f5027h = toolbar.getTitle();
        this.f5028i = toolbar.getSubtitle();
        this.f5026g = this.f5027h != null;
        this.f5025f = toolbar.getNavigationIcon();
        l0 l0VarN = l0.n(toolbar.getContext(), null, c.a.b.f4748a, R.attr.actionBarStyle, 0);
        int i2 = 15;
        this.n = l0VarN.e(15);
        if (z) {
            CharSequence charSequenceK = l0VarN.k(27);
            if (!TextUtils.isEmpty(charSequenceK)) {
                this.f5026g = true;
                this.f5027h = charSequenceK;
                if ((this.f5021b & 8) != 0) {
                    this.f5020a.setTitle(charSequenceK);
                }
            }
            CharSequence charSequenceK2 = l0VarN.k(25);
            if (!TextUtils.isEmpty(charSequenceK2)) {
                this.f5028i = charSequenceK2;
                if ((this.f5021b & 8) != 0) {
                    this.f5020a.setSubtitle(charSequenceK2);
                }
            }
            Drawable drawableE = l0VarN.e(20);
            if (drawableE != null) {
                this.f5024e = drawableE;
                i();
            }
            Drawable drawableE2 = l0VarN.e(17);
            if (drawableE2 != null) {
                this.f5023d = drawableE2;
                i();
            }
            if (this.f5025f == null && (drawable = this.n) != null) {
                this.f5025f = drawable;
                h();
            }
            f(l0VarN.g(10, 0));
            int i3 = l0VarN.i(9, 0);
            if (i3 != 0) {
                View viewInflate = LayoutInflater.from(this.f5020a.getContext()).inflate(i3, (ViewGroup) this.f5020a, false);
                View view = this.f5022c;
                if (view != null && (this.f5021b & 16) != 0) {
                    this.f5020a.removeView(view);
                }
                this.f5022c = viewInflate;
                if (viewInflate != null && (this.f5021b & 16) != 0) {
                    this.f5020a.addView(viewInflate);
                }
                f(this.f5021b | 16);
            }
            int iH = l0VarN.h(13, 0);
            if (iH > 0) {
                ViewGroup.LayoutParams layoutParams = this.f5020a.getLayoutParams();
                layoutParams.height = iH;
                this.f5020a.setLayoutParams(layoutParams);
            }
            int iC = l0VarN.c(7, -1);
            int iC2 = l0VarN.c(3, -1);
            if (iC >= 0 || iC2 >= 0) {
                Toolbar toolbar2 = this.f5020a;
                int iMax = Math.max(iC, 0);
                int iMax2 = Math.max(iC2, 0);
                toolbar2.d();
                toolbar2.u.a(iMax, iMax2);
            }
            int i4 = l0VarN.i(28, 0);
            if (i4 != 0) {
                Toolbar toolbar3 = this.f5020a;
                Context context = toolbar3.getContext();
                toolbar3.m = i4;
                TextView textView = toolbar3.f4688c;
                if (textView != null) {
                    textView.setTextAppearance(context, i4);
                }
            }
            int i5 = l0VarN.i(26, 0);
            if (i5 != 0) {
                Toolbar toolbar4 = this.f5020a;
                Context context2 = toolbar4.getContext();
                toolbar4.n = i5;
                TextView textView2 = toolbar4.f4689d;
                if (textView2 != null) {
                    textView2.setTextAppearance(context2, i5);
                }
            }
            int i6 = l0VarN.i(22, 0);
            if (i6 != 0) {
                this.f5020a.setPopupTheme(i6);
            }
        } else {
            if (this.f5020a.getNavigationIcon() != null) {
                this.n = this.f5020a.getNavigationIcon();
            } else {
                i2 = 11;
            }
            this.f5021b = i2;
        }
        l0VarN.f5000b.recycle();
        if (R.string.abc_action_bar_up_description != this.m) {
            this.m = R.string.abc_action_bar_up_description;
            if (TextUtils.isEmpty(this.f5020a.getNavigationContentDescription())) {
                int i7 = this.m;
                this.f5029j = i7 != 0 ? e().getString(i7) : null;
                g();
            }
        }
        this.f5029j = this.f5020a.getNavigationContentDescription();
        this.f5020a.setNavigationOnClickListener(new m0(this));
    }

    @Override // c.a.g.s
    public void a() {
        c cVar;
        ActionMenuView actionMenuView = this.f5020a.f4687b;
        if (actionMenuView == null || (cVar = actionMenuView.u) == null) {
            return;
        }
        cVar.b();
    }

    @Override // c.a.g.s
    public void b(CharSequence charSequence) {
        if (this.f5026g) {
            return;
        }
        this.f5027h = charSequence;
        if ((this.f5021b & 8) != 0) {
            this.f5020a.setTitle(charSequence);
        }
    }

    @Override // c.a.g.s
    public void c(Window.Callback callback) {
        this.k = callback;
    }

    @Override // c.a.g.s
    public void d(int i2) {
        this.f5024e = i2 != 0 ? c.a.d.a.a.a(e(), i2) : null;
        i();
    }

    public Context e() {
        return this.f5020a.getContext();
    }

    public void f(int i2) {
        View view;
        CharSequence charSequence;
        Toolbar toolbar;
        int i3 = this.f5021b ^ i2;
        this.f5021b = i2;
        if (i3 != 0) {
            if ((i3 & 4) != 0) {
                if ((i2 & 4) != 0) {
                    g();
                }
                h();
            }
            if ((i3 & 3) != 0) {
                i();
            }
            if ((i3 & 8) != 0) {
                if ((i2 & 8) != 0) {
                    this.f5020a.setTitle(this.f5027h);
                    toolbar = this.f5020a;
                    charSequence = this.f5028i;
                } else {
                    charSequence = null;
                    this.f5020a.setTitle((CharSequence) null);
                    toolbar = this.f5020a;
                }
                toolbar.setSubtitle(charSequence);
            }
            if ((i3 & 16) == 0 || (view = this.f5022c) == null) {
                return;
            }
            if ((i2 & 16) != 0) {
                this.f5020a.addView(view);
            } else {
                this.f5020a.removeView(view);
            }
        }
    }

    public final void g() {
        if ((this.f5021b & 4) != 0) {
            if (TextUtils.isEmpty(this.f5029j)) {
                this.f5020a.setNavigationContentDescription(this.m);
            } else {
                this.f5020a.setNavigationContentDescription(this.f5029j);
            }
        }
    }

    @Override // c.a.g.s
    public CharSequence getTitle() {
        return this.f5020a.getTitle();
    }

    public final void h() {
        Toolbar toolbar;
        Drawable drawable;
        if ((this.f5021b & 4) != 0) {
            toolbar = this.f5020a;
            drawable = this.f5025f;
            if (drawable == null) {
                drawable = this.n;
            }
        } else {
            toolbar = this.f5020a;
            drawable = null;
        }
        toolbar.setNavigationIcon(drawable);
    }

    public final void i() {
        Drawable drawable;
        int i2 = this.f5021b;
        if ((i2 & 2) == 0) {
            drawable = null;
        } else if ((i2 & 1) == 0 || (drawable = this.f5024e) == null) {
            drawable = this.f5023d;
        }
        this.f5020a.setLogo(drawable);
    }

    @Override // c.a.g.s
    public void setIcon(int i2) {
        this.f5023d = i2 != 0 ? c.a.d.a.a.a(e(), i2) : null;
        i();
    }

    @Override // c.a.g.s
    public void setIcon(Drawable drawable) {
        this.f5023d = drawable;
        i();
    }
}
