package p037.p041.p051;

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.C0069;
import p037.p041.C1468;
import p037.p041.C1475;
import p037.p041.C1477;
import p037.p041.p043.p044.C1527;
import p037.p041.p049.p050.C1572;
import p037.p041.p049.p050.C1576;
import p037.p041.p049.p050.InterfaceC1587;
import p037.p065.p078.C1920;
import p037.p065.p078.C1931;
import p037.p065.p078.C1935;

/* JADX INFO: renamed from: މ.ؠ.ގ.ࢪ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C1691 implements InterfaceC1649 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public Toolbar f5500;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public int f5501;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public View f5502;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public View f5503;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public Drawable f5504;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public Drawable f5505;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public Drawable f5506;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public boolean f5507;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public CharSequence f5508;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public CharSequence f5509;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public CharSequence f5510;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public Window.Callback f5511;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public boolean f5512;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public C1601 f5513;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public int f5514;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public int f5515;

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public Drawable f5516;

    /* JADX INFO: renamed from: މ.ؠ.ގ.ࢪ$֏, reason: contains not printable characters */
    public class C1692 extends C1935 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public boolean f5517 = false;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final /* synthetic */ int f5518;

        public C1692(int i) {
            this.f5518 = i;
        }

        @Override // p037.p065.p078.C1935, p037.p065.p078.InterfaceC1934
        /* JADX INFO: renamed from: ֏ */
        public void mo3137(View view) {
            this.f5517 = true;
        }

        @Override // p037.p065.p078.InterfaceC1934
        /* JADX INFO: renamed from: ؠ */
        public void mo2861(View view) {
            if (this.f5517) {
                return;
            }
            C1691.this.f5500.setVisibility(this.f5518);
        }

        @Override // p037.p065.p078.C1935, p037.p065.p078.InterfaceC1934
        /* JADX INFO: renamed from: ހ */
        public void mo2997(View view) {
            C1691.this.f5500.setVisibility(0);
        }
    }

    public C1691(Toolbar toolbar, boolean z) {
        int i;
        Drawable drawable;
        int i2 = C1475.abc_action_bar_up_description;
        this.f5514 = 0;
        this.f5515 = 0;
        this.f5500 = toolbar;
        this.f5508 = toolbar.getTitle();
        this.f5509 = toolbar.getSubtitle();
        this.f5507 = this.f5508 != null;
        this.f5506 = toolbar.getNavigationIcon();
        C1689 c1689M3294 = C1689.m3294(toolbar.getContext(), null, C1477.ActionBar, C1468.actionBarStyle, 0);
        this.f5516 = c1689M3294.m3300(C1477.ActionBar_homeAsUpIndicator);
        if (z) {
            CharSequence charSequenceM3306 = c1689M3294.m3306(C1477.ActionBar_title);
            if (!TextUtils.isEmpty(charSequenceM3306)) {
                this.f5507 = true;
                this.f5508 = charSequenceM3306;
                if ((this.f5501 & 8) != 0) {
                    this.f5500.setTitle(charSequenceM3306);
                }
            }
            CharSequence charSequenceM33062 = c1689M3294.m3306(C1477.ActionBar_subtitle);
            if (!TextUtils.isEmpty(charSequenceM33062)) {
                this.f5509 = charSequenceM33062;
                if ((this.f5501 & 8) != 0) {
                    this.f5500.setSubtitle(charSequenceM33062);
                }
            }
            Drawable drawableM3300 = c1689M3294.m3300(C1477.ActionBar_logo);
            if (drawableM3300 != null) {
                this.f5505 = drawableM3300;
                m3310();
            }
            Drawable drawableM33002 = c1689M3294.m3300(C1477.ActionBar_icon);
            if (drawableM33002 != null) {
                this.f5504 = drawableM33002;
                m3310();
            }
            if (this.f5506 == null && (drawable = this.f5516) != null) {
                this.f5506 = drawable;
                m3309();
            }
            mo3224(c1689M3294.m3301(C1477.ActionBar_displayOptions, 0));
            int iM3305 = c1689M3294.m3305(C1477.ActionBar_customNavigationLayout, 0);
            if (iM3305 != 0) {
                View viewInflate = LayoutInflater.from(this.f5500.getContext()).inflate(iM3305, (ViewGroup) this.f5500, false);
                View view = this.f5503;
                if (view != null && (this.f5501 & 16) != 0) {
                    this.f5500.removeView(view);
                }
                this.f5503 = viewInflate;
                if (viewInflate != null && (this.f5501 & 16) != 0) {
                    this.f5500.addView(viewInflate);
                }
                mo3224(this.f5501 | 16);
            }
            int iM3303 = c1689M3294.m3303(C1477.ActionBar_height, 0);
            if (iM3303 > 0) {
                ViewGroup.LayoutParams layoutParams = this.f5500.getLayoutParams();
                layoutParams.height = iM3303;
                this.f5500.setLayoutParams(layoutParams);
            }
            int iM3295 = c1689M3294.m3295(C1477.ActionBar_contentInsetStart, -1);
            int iM32952 = c1689M3294.m3295(C1477.ActionBar_contentInsetEnd, -1);
            if (iM3295 >= 0 || iM32952 >= 0) {
                Toolbar toolbar2 = this.f5500;
                int iMax = Math.max(iM3295, 0);
                int iMax2 = Math.max(iM32952, 0);
                toolbar2.m191();
                toolbar2.f455.m3277(iMax, iMax2);
            }
            int iM33052 = c1689M3294.m3305(C1477.ActionBar_titleTextStyle, 0);
            if (iM33052 != 0) {
                Toolbar toolbar3 = this.f5500;
                Context context = toolbar3.getContext();
                toolbar3.f447 = iM33052;
                TextView textView = toolbar3.f437;
                if (textView != null) {
                    textView.setTextAppearance(context, iM33052);
                }
            }
            int iM33053 = c1689M3294.m3305(C1477.ActionBar_subtitleTextStyle, 0);
            if (iM33053 != 0) {
                Toolbar toolbar4 = this.f5500;
                Context context2 = toolbar4.getContext();
                toolbar4.f448 = iM33053;
                TextView textView2 = toolbar4.f438;
                if (textView2 != null) {
                    textView2.setTextAppearance(context2, iM33053);
                }
            }
            int iM33054 = c1689M3294.m3305(C1477.ActionBar_popupTheme, 0);
            if (iM33054 != 0) {
                this.f5500.setPopupTheme(iM33054);
            }
        } else {
            if (this.f5500.getNavigationIcon() != null) {
                i = 15;
                this.f5516 = this.f5500.getNavigationIcon();
            } else {
                i = 11;
            }
            this.f5501 = i;
        }
        c1689M3294.f5496.recycle();
        if (i2 != this.f5515) {
            this.f5515 = i2;
            if (TextUtils.isEmpty(this.f5500.getNavigationContentDescription())) {
                int i3 = this.f5515;
                this.f5510 = i3 != 0 ? mo3218().getString(i3) : null;
                m3308();
            }
        }
        this.f5510 = this.f5500.getNavigationContentDescription();
        this.f5500.setNavigationOnClickListener(new ViewOnClickListenerC1690(this));
    }

    @Override // p037.p041.p051.InterfaceC1649
    public void collapseActionView() {
        Toolbar.C0069 c0069 = this.f5500.f472;
        C1576 c1576 = c0069 == null ? null : c0069.f479;
        if (c1576 != null) {
            c1576.collapseActionView();
        }
    }

    @Override // p037.p041.p051.InterfaceC1649
    public CharSequence getTitle() {
        return this.f5500.getTitle();
    }

    @Override // p037.p041.p051.InterfaceC1649
    public void setIcon(int i) {
        this.f5504 = i != 0 ? C1527.m3025(mo3218(), i) : null;
        m3310();
    }

    @Override // p037.p041.p051.InterfaceC1649
    public void setIcon(Drawable drawable) {
        this.f5504 = drawable;
        m3310();
    }

    @Override // p037.p041.p051.InterfaceC1649
    public void setWindowCallback(Window.Callback callback) {
        this.f5511 = callback;
    }

    @Override // p037.p041.p051.InterfaceC1649
    public void setWindowTitle(CharSequence charSequence) {
        if (this.f5507) {
            return;
        }
        this.f5508 = charSequence;
        if ((this.f5501 & 8) != 0) {
            this.f5500.setTitle(charSequence);
        }
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ֏ */
    public Context mo3218() {
        return this.f5500.getContext();
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ֏ */
    public C1931 mo3219(int i, long j) {
        C1931 c1931M3736 = C1920.m3736(this.f5500);
        c1931M3736.m3786(i == 0 ? 1.0f : 0.0f);
        c1931M3736.m3787(j);
        C1692 c1692 = new C1692(i);
        View view = c1931M3736.f6382.get();
        if (view != null) {
            c1931M3736.m3791(view, c1692);
        }
        return c1931M3736;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ֏ */
    public void mo3220(int i) {
        this.f5500.setVisibility(i);
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ֏ */
    public void mo3221(Menu menu, InterfaceC1587.InterfaceC1588 interfaceC1588) {
        C1576 c1576;
        if (this.f5513 == null) {
            this.f5513 = new C1601(this.f5500.getContext());
        }
        C1601 c1601 = this.f5513;
        c1601.f5015 = interfaceC1588;
        Toolbar toolbar = this.f5500;
        C1572 c1572 = (C1572) menu;
        if (c1572 == null && toolbar.f436 == null) {
            return;
        }
        toolbar.m194();
        C1572 c15722 = toolbar.f436.f284;
        if (c15722 == c1572) {
            return;
        }
        if (c15722 != null) {
            c15722.m3091(toolbar.f471);
            c15722.m3091(toolbar.f472);
        }
        if (toolbar.f472 == null) {
            toolbar.f472 = toolbar.new C0069();
        }
        c1601.f5207 = true;
        if (c1572 != null) {
            c1572.m3092(c1601, toolbar.f445);
            c1572.m3092(toolbar.f472, toolbar.f445);
        } else {
            c1601.mo199(toolbar.f445, (C1572) null);
            Toolbar.C0069 c0069 = toolbar.f472;
            C1572 c15723 = c0069.f478;
            if (c15723 != null && (c1576 = c0069.f479) != null) {
                c15723.mo3097(c1576);
            }
            c0069.f478 = null;
            c1601.mo202(true);
            toolbar.f472.mo202(true);
        }
        toolbar.f436.setPopupTheme(toolbar.f446);
        toolbar.f436.setPresenter(c1601);
        toolbar.f471 = c1601;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ֏ */
    public void mo3222(C1680 c1680) {
        View view = this.f5502;
        if (view != null) {
            ViewParent parent = view.getParent();
            Toolbar toolbar = this.f5500;
            if (parent == toolbar) {
                toolbar.removeView(this.f5502);
            }
        }
        this.f5502 = c1680;
        if (c1680 == null || this.f5514 != 2) {
            return;
        }
        this.f5500.addView(c1680, 0);
        Toolbar.C0070 c0070 = (Toolbar.C0070) this.f5502.getLayoutParams();
        ((ViewGroup.MarginLayoutParams) c0070).width = -2;
        ((ViewGroup.MarginLayoutParams) c0070).height = -2;
        c0070.f4653 = 8388691;
        c1680.setAllowCollapse(true);
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ֏ */
    public void mo3223(boolean z) {
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ؠ */
    public void mo3224(int i) {
        View view;
        int i2 = this.f5501 ^ i;
        this.f5501 = i;
        if (i2 != 0) {
            if ((i2 & 4) != 0) {
                if ((i & 4) != 0) {
                    m3308();
                }
                m3309();
            }
            if ((i2 & 3) != 0) {
                m3310();
            }
            if ((i2 & 8) != 0) {
                if ((i & 8) != 0) {
                    this.f5500.setTitle(this.f5508);
                    this.f5500.setSubtitle(this.f5509);
                } else {
                    this.f5500.setTitle((CharSequence) null);
                    this.f5500.setSubtitle((CharSequence) null);
                }
            }
            if ((i2 & 16) == 0 || (view = this.f5503) == null) {
                return;
            }
            if ((i & 16) != 0) {
                this.f5500.addView(view);
            } else {
                this.f5500.removeView(view);
            }
        }
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ؠ */
    public void mo3225(boolean z) {
        this.f5500.setCollapsible(z);
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ؠ */
    public boolean mo3226() {
        return this.f5500.m197();
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ހ */
    public void mo3227() {
        this.f5512 = true;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ހ */
    public void mo3228(int i) {
        this.f5505 = i != 0 ? C1527.m3025(mo3218(), i) : null;
        m3310();
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x001e  */
    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ށ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean mo3229() {
        boolean z;
        ActionMenuView actionMenuView = this.f5500.f436;
        if (actionMenuView == null) {
            return false;
        }
        C1601 c1601 = actionMenuView.f288;
        if (c1601 == null) {
            z = false;
        } else {
            if (c1601.f5212 != null || c1601.m3141()) {
                z = true;
            }
        }
        return z;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ނ */
    public boolean mo3230() {
        ActionMenuView actionMenuView = this.f5500.f436;
        if (actionMenuView == null) {
            return false;
        }
        C1601 c1601 = actionMenuView.f288;
        return c1601 != null && c1601.m3139();
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ރ */
    public boolean mo3231() {
        return this.f5500.m198();
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ބ */
    public boolean mo3232() {
        ActionMenuView actionMenuView;
        Toolbar toolbar = this.f5500;
        return toolbar.getVisibility() == 0 && (actionMenuView = toolbar.f436) != null && actionMenuView.f287;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ޅ */
    public void mo3233() {
        C1601 c1601;
        ActionMenuView actionMenuView = this.f5500.f436;
        if (actionMenuView == null || (c1601 = actionMenuView.f288) == null) {
            return;
        }
        c1601.m3138();
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ކ */
    public ViewGroup mo3234() {
        return this.f5500;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: އ */
    public boolean mo3235() {
        Toolbar.C0069 c0069 = this.f5500.f472;
        return (c0069 == null || c0069.f479 == null) ? false : true;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ވ */
    public int mo3236() {
        return this.f5501;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: މ */
    public int mo3237() {
        return this.f5514;
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ފ */
    public void mo3238() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    @Override // p037.p041.p051.InterfaceC1649
    /* JADX INFO: renamed from: ދ */
    public void mo3239() {
        Log.i("ToolbarWidgetWrapper", "Progress display unsupported");
    }

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public final void m3308() {
        if ((this.f5501 & 4) != 0) {
            if (TextUtils.isEmpty(this.f5510)) {
                this.f5500.setNavigationContentDescription(this.f5515);
            } else {
                this.f5500.setNavigationContentDescription(this.f5510);
            }
        }
    }

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public final void m3309() {
        if ((this.f5501 & 4) == 0) {
            this.f5500.setNavigationIcon((Drawable) null);
            return;
        }
        Toolbar toolbar = this.f5500;
        Drawable drawable = this.f5506;
        if (drawable == null) {
            drawable = this.f5516;
        }
        toolbar.setNavigationIcon(drawable);
    }

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final void m3310() {
        Drawable drawable;
        int i = this.f5501;
        if ((i & 2) == 0) {
            drawable = null;
        } else if ((i & 1) == 0 || (drawable = this.f5505) == null) {
            drawable = this.f5504;
        }
        this.f5500.setLogo(drawable);
    }
}
