package l;

import android.content.res.TypedArray;
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 androidx.appcompat.widget.ScrollingTabContainerView;
import androidx.appcompat.widget.Toolbar;

/* JADX INFO: loaded from: classes.dex */
public final class w3 implements m1 {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public w3(Toolbar toolbar, boolean z10) {
        int i10;
        Drawable drawable;
        int i11 = d.h.abc_action_bar_up_description;
        this.f29897o = 0;
        this.f29883a = toolbar;
        this.f29891i = toolbar.getTitle();
        this.f29892j = toolbar.getSubtitle();
        this.f29890h = this.f29891i != null;
        this.f29889g = toolbar.getNavigationIcon();
        p3 p3VarD = p3.d(toolbar.getContext(), null, d.j.ActionBar, d.a.actionBarStyle);
        this.f29898p = p3VarD.b(d.j.ActionBar_homeAsUpIndicator);
        if (z10) {
            int i12 = d.j.ActionBar_title;
            TypedArray typedArray = p3VarD.f29809b;
            CharSequence text = typedArray.getText(i12);
            if (!TextUtils.isEmpty(text)) {
                this.f29890h = true;
                this.f29891i = text;
                if ((this.f29884b & 8) != 0) {
                    Toolbar toolbar2 = this.f29883a;
                    toolbar2.setTitle(text);
                    if (this.f29890h) {
                        androidx.core.view.s1.setAccessibilityPaneTitle(toolbar2.getRootView(), text);
                    }
                }
            }
            CharSequence text2 = typedArray.getText(d.j.ActionBar_subtitle);
            if (!TextUtils.isEmpty(text2)) {
                this.f29892j = text2;
                if ((this.f29884b & 8) != 0) {
                    toolbar.setSubtitle(text2);
                }
            }
            Drawable drawableB = p3VarD.b(d.j.ActionBar_logo);
            if (drawableB != null) {
                this.f29888f = drawableB;
                c();
            }
            Drawable drawableB2 = p3VarD.b(d.j.ActionBar_icon);
            if (drawableB2 != null) {
                this.f29887e = drawableB2;
                c();
            }
            if (this.f29889g == null && (drawable = this.f29898p) != null) {
                this.f29889g = drawable;
                int i13 = this.f29884b & 4;
                Toolbar toolbar3 = this.f29883a;
                if (i13 != 0) {
                    toolbar3.setNavigationIcon(drawable);
                } else {
                    toolbar3.setNavigationIcon((Drawable) null);
                }
            }
            a(typedArray.getInt(d.j.ActionBar_displayOptions, 0));
            int resourceId = typedArray.getResourceId(d.j.ActionBar_customNavigationLayout, 0);
            if (resourceId != 0) {
                View viewInflate = LayoutInflater.from(toolbar.getContext()).inflate(resourceId, (ViewGroup) toolbar, false);
                View view = this.f29886d;
                if (view != null && (this.f29884b & 16) != 0) {
                    toolbar.removeView(view);
                }
                this.f29886d = viewInflate;
                if (viewInflate != null && (this.f29884b & 16) != 0) {
                    toolbar.addView(viewInflate);
                }
                a(this.f29884b | 16);
            }
            int layoutDimension = typedArray.getLayoutDimension(d.j.ActionBar_height, 0);
            if (layoutDimension > 0) {
                ViewGroup.LayoutParams layoutParams = toolbar.getLayoutParams();
                layoutParams.height = layoutDimension;
                toolbar.setLayoutParams(layoutParams);
            }
            int dimensionPixelOffset = typedArray.getDimensionPixelOffset(d.j.ActionBar_contentInsetStart, -1);
            int dimensionPixelOffset2 = typedArray.getDimensionPixelOffset(d.j.ActionBar_contentInsetEnd, -1);
            if (dimensionPixelOffset >= 0 || dimensionPixelOffset2 >= 0) {
                toolbar.setContentInsetsRelative(Math.max(dimensionPixelOffset, 0), Math.max(dimensionPixelOffset2, 0));
            }
            int resourceId2 = typedArray.getResourceId(d.j.ActionBar_titleTextStyle, 0);
            if (resourceId2 != 0) {
                toolbar.setTitleTextAppearance(toolbar.getContext(), resourceId2);
            }
            int resourceId3 = typedArray.getResourceId(d.j.ActionBar_subtitleTextStyle, 0);
            if (resourceId3 != 0) {
                toolbar.setSubtitleTextAppearance(toolbar.getContext(), resourceId3);
            }
            int resourceId4 = typedArray.getResourceId(d.j.ActionBar_popupTheme, 0);
            if (resourceId4 != 0) {
                toolbar.setPopupTheme(resourceId4);
            }
        } else {
            if (toolbar.getNavigationIcon() != null) {
                this.f29898p = toolbar.getNavigationIcon();
                i10 = 15;
            } else {
                i10 = 11;
            }
            this.f29884b = i10;
        }
        p3VarD.e();
        if (i11 != this.f29897o) {
            this.f29897o = i11;
            if (TextUtils.isEmpty(toolbar.getNavigationContentDescription())) {
                int i14 = this.f29897o;
                this.f29893k = i14 != 0 ? toolbar.getContext().getString(i14) : null;
                b();
            }
        }
        this.f29893k = toolbar.getNavigationContentDescription();
        toolbar.setNavigationOnClickListener(new d(this));
    }

    public final void a(int i10) {
        View view;
        int i11 = this.f29884b ^ i10;
        this.f29884b = i10;
        if (i11 != 0) {
            if ((i11 & 4) != 0) {
                if ((i10 & 4) != 0) {
                    b();
                }
                int i12 = this.f29884b & 4;
                Toolbar toolbar = this.f29883a;
                if (i12 != 0) {
                    Drawable drawable = this.f29889g;
                    if (drawable == null) {
                        drawable = this.f29898p;
                    }
                    toolbar.setNavigationIcon(drawable);
                } else {
                    toolbar.setNavigationIcon((Drawable) null);
                }
            }
            if ((i11 & 3) != 0) {
                c();
            }
            int i13 = i11 & 8;
            Toolbar toolbar2 = this.f29883a;
            if (i13 != 0) {
                if ((i10 & 8) != 0) {
                    toolbar2.setTitle(this.f29891i);
                    toolbar2.setSubtitle(this.f29892j);
                } else {
                    toolbar2.setTitle((CharSequence) null);
                    toolbar2.setSubtitle((CharSequence) null);
                }
            }
            if ((i11 & 16) == 0 || (view = this.f29886d) == null) {
                return;
            }
            if ((i10 & 16) != 0) {
                toolbar2.addView(view);
            } else {
                toolbar2.removeView(view);
            }
        }
    }

    public final void b() {
        if ((this.f29884b & 4) != 0) {
            boolean zIsEmpty = TextUtils.isEmpty(this.f29893k);
            Toolbar toolbar = this.f29883a;
            if (zIsEmpty) {
                toolbar.setNavigationContentDescription(this.f29897o);
            } else {
                toolbar.setNavigationContentDescription(this.f29893k);
            }
        }
    }

    public final void c() {
        Drawable drawable;
        int i10 = this.f29884b;
        if ((i10 & 2) == 0) {
            drawable = null;
        } else if ((i10 & 1) == 0 || (drawable = this.f29888f) == null) {
            drawable = this.f29887e;
        }
        this.f29883a.setLogo(drawable);
    }
}
