package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.activity.C0064l;
import androidx.appcompat.view.menu.C0103e;
import androidx.appcompat.view.menu.C0107g;
import androidx.appcompat.view.menu.InterfaceC0112i;
import androidx.appcompat.view.menu.SubMenuC0119l;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import p007c.C0485a;
import p007c.C0494j;
import p010d.AbstractC0521a;
import p013e.C0640a;
import p022h.C0751g;
import p022h.InterfaceC0745c;
import p023h0.C0792c0;
import p023h0.C0800d0;
import p023h0.C0829h1;
import p023h0.C0936r;
import p028j.C1106g3;
import p028j.C1134k3;
import p028j.C1163o;
import p028j.C1165o1;
import p028j.C1183q;
import p028j.C1187q3;
import p028j.C1245y2;
import p028j.InterfaceC1110h2;
import p038m0.AbstractC1459a;

/* loaded from: classes.dex */
public class Toolbar extends ViewGroup {

    /* renamed from: A */
    public CharSequence f573A;

    /* renamed from: B */
    public CharSequence f574B;

    /* renamed from: C */
    public ColorStateList f575C;

    /* renamed from: D */
    public ColorStateList f576D;

    /* renamed from: E */
    public boolean f577E;

    /* renamed from: F */
    public boolean f578F;

    /* renamed from: G */
    public final ArrayList<View> f579G;

    /* renamed from: H */
    public final ArrayList<View> f580H;

    /* renamed from: I */
    public final int[] f581I;

    /* renamed from: J */
    public final C0800d0 f582J;

    /* renamed from: K */
    public ArrayList<MenuItem> f583K;

    /* renamed from: L */
    public final ActionMenuView.InterfaceC0131e f584L;

    /* renamed from: M */
    public C0180e f585M;

    /* renamed from: N */
    public C0163a f586N;

    /* renamed from: O */
    public C0157f f587O;

    /* renamed from: P */
    public InterfaceC0112i.InterfaceC0113a f588P;

    /* renamed from: Q */
    public C0103e.InterfaceC0104a f589Q;

    /* renamed from: R */
    public boolean f590R;

    /* renamed from: S */
    public OnBackInvokedCallback f591S;

    /* renamed from: T */
    public OnBackInvokedDispatcher f592T;

    /* renamed from: U */
    public boolean f593U;

    /* renamed from: V */
    public final Runnable f594V;

    /* renamed from: d */
    public ActionMenuView f595d;

    /* renamed from: e */
    public TextView f596e;

    /* renamed from: f */
    public TextView f597f;

    /* renamed from: g */
    public ImageButton f598g;

    /* renamed from: h */
    public ImageView f599h;

    /* renamed from: i */
    public Drawable f600i;

    /* renamed from: j */
    public CharSequence f601j;

    /* renamed from: k */
    public ImageButton f602k;

    /* renamed from: l */
    public View f603l;

    /* renamed from: m */
    public Context f604m;

    /* renamed from: n */
    public int f605n;

    /* renamed from: o */
    public int f606o;

    /* renamed from: p */
    public int f607p;

    /* renamed from: q */
    public int f608q;

    /* renamed from: r */
    public int f609r;

    /* renamed from: s */
    public int f610s;

    /* renamed from: t */
    public int f611t;

    /* renamed from: u */
    public int f612u;

    /* renamed from: v */
    public int f613v;

    /* renamed from: w */
    public C1245y2 f614w;

    /* renamed from: x */
    public int f615x;

    /* renamed from: y */
    public int f616y;

    /* renamed from: z */
    public int f617z;

    /* renamed from: androidx.appcompat.widget.Toolbar$a */
    /* loaded from: classes.dex */
    public class C0152a implements ActionMenuView.InterfaceC0131e {
        public C0152a() {
        }

        @Override // androidx.appcompat.widget.ActionMenuView.InterfaceC0131e
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (Toolbar.this.f582J.m2891c(menuItem)) {
                return true;
            }
            Toolbar.this.getClass();
            return false;
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$b */
    /* loaded from: classes.dex */
    public class RunnableC0153b implements Runnable {
        public RunnableC0153b() {
        }

        @Override // java.lang.Runnable
        public void run() {
            Toolbar.this.m4697P();
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$c */
    /* loaded from: classes.dex */
    public class C0154c implements C0103e.InterfaceC0104a {
        public C0154c() {
        }

        @Override // androidx.appcompat.view.menu.C0103e.InterfaceC0104a
        /* renamed from: a */
        public boolean mo3009a(C0103e c0103e, MenuItem menuItem) {
            C0103e.InterfaceC0104a interfaceC0104a = Toolbar.this.f589Q;
            return interfaceC0104a != null && interfaceC0104a.mo3009a(c0103e, menuItem);
        }

        @Override // androidx.appcompat.view.menu.C0103e.InterfaceC0104a
        /* renamed from: b */
        public void mo3008b(C0103e c0103e) {
            if (!Toolbar.this.f595d.m4782F()) {
                Toolbar.this.f582J.m2890d(c0103e);
            }
            C0103e.InterfaceC0104a interfaceC0104a = Toolbar.this.f589Q;
            if (interfaceC0104a != null) {
                interfaceC0104a.mo3008b(c0103e);
            }
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$d */
    /* loaded from: classes.dex */
    public class View$OnClickListenerC0155d implements View.OnClickListener {
        public View$OnClickListenerC0155d() {
        }

        @Override // android.view.View.OnClickListener
        public void onClick(View view) {
            Toolbar.this.m4691e();
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$e */
    /* loaded from: classes.dex */
    public static class C0156e {
        /* renamed from: a */
        public static OnBackInvokedDispatcher m4669a(View view) {
            return view.findOnBackInvokedDispatcher();
        }

        /* renamed from: b */
        public static OnBackInvokedCallback m4668b(Runnable runnable) {
            runnable.getClass();
            return new C0064l(runnable);
        }

        /* renamed from: c */
        public static void m4667c(Object obj, Object obj2) {
            ((OnBackInvokedDispatcher) obj).registerOnBackInvokedCallback(1000000, (OnBackInvokedCallback) obj2);
        }

        /* renamed from: d */
        public static void m4666d(Object obj, Object obj2) {
            ((OnBackInvokedDispatcher) obj).unregisterOnBackInvokedCallback((OnBackInvokedCallback) obj2);
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$f */
    /* loaded from: classes.dex */
    public class C0157f implements InterfaceC0112i {

        /* renamed from: d */
        public C0103e f622d;

        /* renamed from: e */
        public C0107g f623e;

        public C0157f() {
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: a */
        public void mo4649a(C0103e c0103e, boolean z) {
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: c */
        public boolean mo4648c() {
            return false;
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: d */
        public void mo2399d(Context context, C0103e c0103e) {
            C0107g c0107g;
            C0103e c0103e2 = this.f622d;
            if (c0103e2 != null && (c0107g = this.f623e) != null) {
                c0103e2.mo4813f(c0107g);
            }
            this.f622d = c0103e;
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: e */
        public boolean mo2398e(C0103e c0103e, C0107g c0107g) {
            View view = Toolbar.this.f603l;
            if (view instanceof InterfaceC0745c) {
                ((InterfaceC0745c) view).onActionViewCollapsed();
            }
            Toolbar toolbar = Toolbar.this;
            toolbar.removeView(toolbar.f603l);
            Toolbar toolbar2 = Toolbar.this;
            toolbar2.removeView(toolbar2.f602k);
            Toolbar toolbar3 = Toolbar.this;
            toolbar3.f603l = null;
            toolbar3.m4695a();
            this.f623e = null;
            Toolbar.this.requestLayout();
            c0107g.m4846r(false);
            Toolbar.this.m4696Q();
            return true;
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: g */
        public boolean mo2397g(C0103e c0103e, C0107g c0107g) {
            Toolbar.this.m4689g();
            ViewParent parent = Toolbar.this.f602k.getParent();
            Toolbar toolbar = Toolbar.this;
            if (parent != toolbar) {
                if (parent instanceof ViewGroup) {
                    ((ViewGroup) parent).removeView(toolbar.f602k);
                }
                Toolbar toolbar2 = Toolbar.this;
                toolbar2.addView(toolbar2.f602k);
            }
            Toolbar.this.f603l = c0107g.getActionView();
            this.f623e = c0107g;
            ViewParent parent2 = Toolbar.this.f603l.getParent();
            Toolbar toolbar3 = Toolbar.this;
            if (parent2 != toolbar3) {
                if (parent2 instanceof ViewGroup) {
                    ((ViewGroup) parent2).removeView(toolbar3.f603l);
                }
                C0158g generateDefaultLayoutParams = Toolbar.this.generateDefaultLayoutParams();
                Toolbar toolbar4 = Toolbar.this;
                generateDefaultLayoutParams.f1935a = (toolbar4.f608q & 112) | 8388611;
                generateDefaultLayoutParams.f625b = 2;
                toolbar4.f603l.setLayoutParams(generateDefaultLayoutParams);
                Toolbar toolbar5 = Toolbar.this;
                toolbar5.addView(toolbar5.f603l);
            }
            Toolbar.this.m4704I();
            Toolbar.this.requestLayout();
            c0107g.m4846r(true);
            View view = Toolbar.this.f603l;
            if (view instanceof InterfaceC0745c) {
                ((InterfaceC0745c) view).onActionViewExpanded();
            }
            Toolbar.this.m4696Q();
            return true;
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: i */
        public boolean mo4646i(SubMenuC0119l subMenuC0119l) {
            return false;
        }

        @Override // androidx.appcompat.view.menu.InterfaceC0112i
        /* renamed from: j */
        public void mo4645j(boolean z) {
            if (this.f623e != null) {
                C0103e c0103e = this.f622d;
                boolean z2 = false;
                if (c0103e != null) {
                    int size = c0103e.size();
                    int i = 0;
                    while (true) {
                        if (i >= size) {
                            break;
                        } else if (this.f622d.getItem(i) == this.f623e) {
                            z2 = true;
                            break;
                        } else {
                            i++;
                        }
                    }
                }
                if (z2) {
                    return;
                }
                mo2398e(this.f622d, this.f623e);
            }
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$g */
    /* loaded from: classes.dex */
    public static class C0158g extends AbstractC0521a.C0522a {

        /* renamed from: b */
        public int f625b;

        public C0158g(int i, int i2) {
            super(i, i2);
            this.f625b = 0;
            this.f1935a = 8388627;
        }

        public C0158g(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f625b = 0;
        }

        public C0158g(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f625b = 0;
        }

        public C0158g(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
            this.f625b = 0;
            m4665a(marginLayoutParams);
        }

        public C0158g(C0158g c0158g) {
            super((AbstractC0521a.C0522a) c0158g);
            this.f625b = 0;
            this.f625b = c0158g.f625b;
        }

        public C0158g(AbstractC0521a.C0522a c0522a) {
            super(c0522a);
            this.f625b = 0;
        }

        /* renamed from: a */
        public void m4665a(ViewGroup.MarginLayoutParams marginLayoutParams) {
            ((ViewGroup.MarginLayoutParams) this).leftMargin = marginLayoutParams.leftMargin;
            ((ViewGroup.MarginLayoutParams) this).topMargin = marginLayoutParams.topMargin;
            ((ViewGroup.MarginLayoutParams) this).rightMargin = marginLayoutParams.rightMargin;
            ((ViewGroup.MarginLayoutParams) this).bottomMargin = marginLayoutParams.bottomMargin;
        }
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$h */
    /* loaded from: classes.dex */
    public interface InterfaceC0159h {
    }

    /* renamed from: androidx.appcompat.widget.Toolbar$i */
    /* loaded from: classes.dex */
    public static class C0160i extends AbstractC1459a {
        public static final Parcelable.Creator<C0160i> CREATOR = new C0161a();

        /* renamed from: f */
        public int f626f;

        /* renamed from: g */
        public boolean f627g;

        /* renamed from: androidx.appcompat.widget.Toolbar$i$a */
        /* loaded from: classes.dex */
        public class C0161a implements Parcelable.ClassLoaderCreator<C0160i> {
            @Override // android.os.Parcelable.Creator
            /* renamed from: a */
            public C0160i createFromParcel(Parcel parcel) {
                return new C0160i(parcel, null);
            }

            @Override // android.os.Parcelable.ClassLoaderCreator
            /* renamed from: b */
            public C0160i createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new C0160i(parcel, classLoader);
            }

            @Override // android.os.Parcelable.Creator
            /* renamed from: c */
            public C0160i[] newArray(int i) {
                return new C0160i[i];
            }
        }

        public C0160i(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.f626f = parcel.readInt();
            this.f627g = parcel.readInt() != 0;
        }

        public C0160i(Parcelable parcelable) {
            super(parcelable);
        }

        @Override // p038m0.AbstractC1459a, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeInt(this.f626f);
            parcel.writeInt(this.f627g ? 1 : 0);
        }
    }

    public Toolbar(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, C0485a.toolbarStyle);
    }

    public Toolbar(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f617z = 8388627;
        this.f579G = new ArrayList<>();
        this.f580H = new ArrayList<>();
        this.f581I = new int[2];
        this.f582J = new C0800d0(new Runnable() { // from class: j.h3
            @Override // java.lang.Runnable
            public final void run() {
                Toolbar.this.m4671y();
            }
        });
        this.f583K = new ArrayList<>();
        this.f584L = new C0152a();
        this.f594V = new RunnableC0153b();
        Context context2 = getContext();
        int[] iArr = C0494j.f1768R2;
        C1106g3 m2160u = C1106g3.m2160u(context2, attributeSet, iArr, i, 0);
        C0829h1.m2850M(this, context, iArr, attributeSet, m2160u.m2164q(), i, 0);
        this.f606o = m2160u.m2168m(C0494j.f1900t3, 0);
        this.f607p = m2160u.m2168m(C0494j.f1855k3, 0);
        this.f617z = m2160u.m2170k(C0494j.f1772S2, this.f617z);
        this.f608q = m2160u.m2170k(C0494j.f1776T2, 48);
        int m2177d = m2160u.m2177d(C0494j.f1870n3, 0);
        int i2 = C0494j.f1895s3;
        m2177d = m2160u.m2163r(i2) ? m2160u.m2177d(i2, m2177d) : m2177d;
        this.f613v = m2177d;
        this.f612u = m2177d;
        this.f611t = m2177d;
        this.f610s = m2177d;
        int m2177d2 = m2160u.m2177d(C0494j.f1885q3, -1);
        if (m2177d2 >= 0) {
            this.f610s = m2177d2;
        }
        int m2177d3 = m2160u.m2177d(C0494j.f1880p3, -1);
        if (m2177d3 >= 0) {
            this.f611t = m2177d3;
        }
        int m2177d4 = m2160u.m2177d(C0494j.f1890r3, -1);
        if (m2177d4 >= 0) {
            this.f612u = m2177d4;
        }
        int m2177d5 = m2160u.m2177d(C0494j.f1875o3, -1);
        if (m2177d5 >= 0) {
            this.f613v = m2177d5;
        }
        this.f609r = m2160u.m2176e(C0494j.f1825e3, -1);
        int m2177d6 = m2160u.m2177d(C0494j.f1805a3, Integer.MIN_VALUE);
        int m2177d7 = m2160u.m2177d(C0494j.f1788W2, Integer.MIN_VALUE);
        int m2176e = m2160u.m2176e(C0494j.f1796Y2, 0);
        int m2176e2 = m2160u.m2176e(C0494j.f1800Z2, 0);
        m4688h();
        this.f614w.m1790e(m2176e, m2176e2);
        if (m2177d6 != Integer.MIN_VALUE || m2177d7 != Integer.MIN_VALUE) {
            this.f614w.m1788g(m2177d6, m2177d7);
        }
        this.f615x = m2160u.m2177d(C0494j.f1810b3, Integer.MIN_VALUE);
        this.f616y = m2160u.m2177d(C0494j.f1792X2, Integer.MIN_VALUE);
        this.f600i = m2160u.m2175f(C0494j.f1784V2);
        this.f601j = m2160u.m2166o(C0494j.f1780U2);
        CharSequence m2166o = m2160u.m2166o(C0494j.f1865m3);
        if (!TextUtils.isEmpty(m2166o)) {
            setTitle(m2166o);
        }
        CharSequence m2166o2 = m2160u.m2166o(C0494j.f1850j3);
        if (!TextUtils.isEmpty(m2166o2)) {
            setSubtitle(m2166o2);
        }
        this.f604m = getContext();
        setPopupTheme(m2160u.m2168m(C0494j.f1845i3, 0));
        Drawable m2175f = m2160u.m2175f(C0494j.f1840h3);
        if (m2175f != null) {
            setNavigationIcon(m2175f);
        }
        CharSequence m2166o3 = m2160u.m2166o(C0494j.f1835g3);
        if (!TextUtils.isEmpty(m2166o3)) {
            setNavigationContentDescription(m2166o3);
        }
        Drawable m2175f2 = m2160u.m2175f(C0494j.f1815c3);
        if (m2175f2 != null) {
            setLogo(m2175f2);
        }
        CharSequence m2166o4 = m2160u.m2166o(C0494j.f1820d3);
        if (!TextUtils.isEmpty(m2166o4)) {
            setLogoDescription(m2166o4);
        }
        int i3 = C0494j.f1905u3;
        if (m2160u.m2163r(i3)) {
            setTitleTextColor(m2160u.m2178c(i3));
        }
        int i4 = C0494j.f1860l3;
        if (m2160u.m2163r(i4)) {
            setSubtitleTextColor(m2160u.m2178c(i4));
        }
        int i5 = C0494j.f1830f3;
        if (m2160u.m2163r(i5)) {
            m4672x(m2160u.m2168m(i5, 0));
        }
        m2160u.m2159v();
    }

    private ArrayList<MenuItem> getCurrentMenuItems() {
        ArrayList<MenuItem> arrayList = new ArrayList<>();
        Menu menu = getMenu();
        for (int i = 0; i < menu.size(); i++) {
            arrayList.add(menu.getItem(i));
        }
        return arrayList;
    }

    private MenuInflater getMenuInflater() {
        return new C0751g(getContext());
    }

    /* renamed from: A */
    public boolean m4712A() {
        ActionMenuView actionMenuView = this.f595d;
        return actionMenuView != null && actionMenuView.m4783E();
    }

    /* renamed from: B */
    public boolean m4711B() {
        ActionMenuView actionMenuView = this.f595d;
        return actionMenuView != null && actionMenuView.m4782F();
    }

    /* renamed from: C */
    public final int m4710C(View view, int i, int[] iArr, int i2) {
        C0158g c0158g = (C0158g) view.getLayoutParams();
        int i3 = ((ViewGroup.MarginLayoutParams) c0158g).leftMargin - iArr[0];
        int max = i + Math.max(0, i3);
        iArr[0] = Math.max(0, -i3);
        int m4679q = m4679q(view, i2);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(max, m4679q, max + measuredWidth, view.getMeasuredHeight() + m4679q);
        return max + measuredWidth + ((ViewGroup.MarginLayoutParams) c0158g).rightMargin;
    }

    /* renamed from: D */
    public final int m4709D(View view, int i, int[] iArr, int i2) {
        C0158g c0158g = (C0158g) view.getLayoutParams();
        int i3 = ((ViewGroup.MarginLayoutParams) c0158g).rightMargin - iArr[1];
        int max = i - Math.max(0, i3);
        iArr[1] = Math.max(0, -i3);
        int m4679q = m4679q(view, i2);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(max - measuredWidth, m4679q, max, view.getMeasuredHeight() + m4679q);
        return max - (measuredWidth + ((ViewGroup.MarginLayoutParams) c0158g).leftMargin);
    }

    /* renamed from: E */
    public final int m4708E(View view, int i, int i2, int i3, int i4, int[] iArr) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int i5 = marginLayoutParams.leftMargin - iArr[0];
        int i6 = marginLayoutParams.rightMargin - iArr[1];
        int max = Math.max(0, i5) + Math.max(0, i6);
        iArr[0] = Math.max(0, -i5);
        iArr[1] = Math.max(0, -i6);
        view.measure(ViewGroup.getChildMeasureSpec(i, getPaddingLeft() + getPaddingRight() + max + i2, marginLayoutParams.width), ViewGroup.getChildMeasureSpec(i3, getPaddingTop() + getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i4, marginLayoutParams.height));
        return view.getMeasuredWidth() + max;
    }

    /* renamed from: F */
    public final void m4707F(View view, int i, int i2, int i3, int i4, int i5) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int childMeasureSpec = ViewGroup.getChildMeasureSpec(i, getPaddingLeft() + getPaddingRight() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i2, marginLayoutParams.width);
        int childMeasureSpec2 = ViewGroup.getChildMeasureSpec(i3, getPaddingTop() + getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i4, marginLayoutParams.height);
        int mode = View.MeasureSpec.getMode(childMeasureSpec2);
        if (mode != 1073741824 && i5 >= 0) {
            if (mode != 0) {
                i5 = Math.min(View.MeasureSpec.getSize(childMeasureSpec2), i5);
            }
            childMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i5, 1073741824);
        }
        view.measure(childMeasureSpec, childMeasureSpec2);
    }

    /* renamed from: G */
    public final void m4706G() {
        Menu menu = getMenu();
        ArrayList<MenuItem> currentMenuItems = getCurrentMenuItems();
        this.f582J.m2893a(menu, getMenuInflater());
        ArrayList<MenuItem> currentMenuItems2 = getCurrentMenuItems();
        currentMenuItems2.removeAll(currentMenuItems);
        this.f583K = currentMenuItems2;
    }

    /* renamed from: H */
    public final void m4705H() {
        removeCallbacks(this.f594V);
        post(this.f594V);
    }

    /* renamed from: I */
    public void m4704I() {
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = getChildAt(childCount);
            if (((C0158g) childAt.getLayoutParams()).f625b != 2 && childAt != this.f595d) {
                removeViewAt(childCount);
                this.f580H.add(childAt);
            }
        }
    }

    /* renamed from: J */
    public void m4703J(int i, int i2) {
        m4688h();
        this.f614w.m1788g(i, i2);
    }

    /* renamed from: K */
    public void m4702K(C0103e c0103e, C0163a c0163a) {
        if (c0103e == null && this.f595d == null) {
            return;
        }
        m4685k();
        C0103e m4778J = this.f595d.m4778J();
        if (m4778J == c0103e) {
            return;
        }
        if (m4778J != null) {
            m4778J.m4902O(this.f586N);
            m4778J.m4902O(this.f587O);
        }
        if (this.f587O == null) {
            this.f587O = new C0157f();
        }
        c0163a.m4654G(true);
        if (c0103e != null) {
            c0103e.m4887c(c0163a, this.f604m);
            c0103e.m4887c(this.f587O, this.f604m);
        } else {
            c0163a.mo2399d(this.f604m, null);
            this.f587O.mo2399d(this.f604m, null);
            c0163a.mo4645j(true);
            this.f587O.mo4645j(true);
        }
        this.f595d.setPopupTheme(this.f605n);
        this.f595d.setPresenter(c0163a);
        this.f586N = c0163a;
        m4696Q();
    }

    /* renamed from: L */
    public void m4701L(Context context, int i) {
        this.f607p = i;
        TextView textView = this.f597f;
        if (textView != null) {
            textView.setTextAppearance(context, i);
        }
    }

    /* renamed from: M */
    public void m4700M(Context context, int i) {
        this.f606o = i;
        TextView textView = this.f596e;
        if (textView != null) {
            textView.setTextAppearance(context, i);
        }
    }

    /* renamed from: N */
    public final boolean m4699N() {
        if (this.f590R) {
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
                View childAt = getChildAt(i);
                if (m4698O(childAt) && childAt.getMeasuredWidth() > 0 && childAt.getMeasuredHeight() > 0) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    /* renamed from: O */
    public final boolean m4698O(View view) {
        return (view == null || view.getParent() != this || view.getVisibility() == 8) ? false : true;
    }

    /* renamed from: P */
    public boolean m4697P() {
        ActionMenuView actionMenuView = this.f595d;
        return actionMenuView != null && actionMenuView.m4776L();
    }

    /* renamed from: Q */
    public void m4696Q() {
        OnBackInvokedDispatcher onBackInvokedDispatcher;
        if (Build.VERSION.SDK_INT >= 33) {
            OnBackInvokedDispatcher m4669a = C0156e.m4669a(this);
            boolean z = m4674v() && m4669a != null && C0829h1.m2862A(this) && this.f593U;
            if (z && this.f592T == null) {
                if (this.f591S == null) {
                    this.f591S = C0156e.m4668b(new Runnable() { // from class: j.i3
                        @Override // java.lang.Runnable
                        public final void run() {
                            Toolbar.this.m4691e();
                        }
                    });
                }
                C0156e.m4667c(m4669a, this.f591S);
            } else if (z || (onBackInvokedDispatcher = this.f592T) == null) {
                return;
            } else {
                C0156e.m4666d(onBackInvokedDispatcher, this.f591S);
                m4669a = null;
            }
            this.f592T = m4669a;
        }
    }

    /* renamed from: a */
    public void m4695a() {
        for (int size = this.f580H.size() - 1; size >= 0; size--) {
            addView(this.f580H.get(size));
        }
        this.f580H.clear();
    }

    /* renamed from: b */
    public final void m4694b(List<View> list, int i) {
        boolean z = C0829h1.m2816r(this) == 1;
        int childCount = getChildCount();
        int m2528a = C0936r.m2528a(i, C0829h1.m2816r(this));
        list.clear();
        if (!z) {
            for (int i2 = 0; i2 < childCount; i2++) {
                View childAt = getChildAt(i2);
                C0158g c0158g = (C0158g) childAt.getLayoutParams();
                if (c0158g.f625b == 0 && m4698O(childAt) && m4680p(c0158g.f1935a) == m2528a) {
                    list.add(childAt);
                }
            }
            return;
        }
        for (int i3 = childCount - 1; i3 >= 0; i3--) {
            View childAt2 = getChildAt(i3);
            C0158g c0158g2 = (C0158g) childAt2.getLayoutParams();
            if (c0158g2.f625b == 0 && m4698O(childAt2) && m4680p(c0158g2.f1935a) == m2528a) {
                list.add(childAt2);
            }
        }
    }

    /* renamed from: c */
    public final void m4693c(View view, boolean z) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        C0158g generateDefaultLayoutParams = layoutParams == null ? generateDefaultLayoutParams() : !checkLayoutParams(layoutParams) ? generateLayoutParams(layoutParams) : (C0158g) layoutParams;
        generateDefaultLayoutParams.f625b = 1;
        if (!z || this.f603l == null) {
            addView(view, generateDefaultLayoutParams);
            return;
        }
        view.setLayoutParams(generateDefaultLayoutParams);
        this.f580H.add(view);
    }

    @Override // android.view.ViewGroup
    public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return super.checkLayoutParams(layoutParams) && (layoutParams instanceof C0158g);
    }

    /* renamed from: d */
    public boolean m4692d() {
        ActionMenuView actionMenuView;
        return getVisibility() == 0 && (actionMenuView = this.f595d) != null && actionMenuView.m4781G();
    }

    /* renamed from: e */
    public void m4691e() {
        C0157f c0157f = this.f587O;
        C0107g c0107g = c0157f == null ? null : c0157f.f623e;
        if (c0107g != null) {
            c0107g.collapseActionView();
        }
    }

    /* renamed from: f */
    public void m4690f() {
        ActionMenuView actionMenuView = this.f595d;
        if (actionMenuView != null) {
            actionMenuView.m4773x();
        }
    }

    /* renamed from: g */
    public void m4689g() {
        if (this.f602k == null) {
            C1163o c1163o = new C1163o(getContext(), null, C0485a.toolbarNavigationButtonStyle);
            this.f602k = c1163o;
            c1163o.setImageDrawable(this.f600i);
            this.f602k.setContentDescription(this.f601j);
            C0158g generateDefaultLayoutParams = generateDefaultLayoutParams();
            generateDefaultLayoutParams.f1935a = (this.f608q & 112) | 8388611;
            generateDefaultLayoutParams.f625b = 2;
            this.f602k.setLayoutParams(generateDefaultLayoutParams);
            this.f602k.setOnClickListener(new View$OnClickListenerC0155d());
        }
    }

    public CharSequence getCollapseContentDescription() {
        ImageButton imageButton = this.f602k;
        if (imageButton != null) {
            return imageButton.getContentDescription();
        }
        return null;
    }

    public Drawable getCollapseIcon() {
        ImageButton imageButton = this.f602k;
        if (imageButton != null) {
            return imageButton.getDrawable();
        }
        return null;
    }

    public int getContentInsetEnd() {
        C1245y2 c1245y2 = this.f614w;
        if (c1245y2 != null) {
            return c1245y2.m1794a();
        }
        return 0;
    }

    public int getContentInsetEndWithActions() {
        int i = this.f616y;
        return i != Integer.MIN_VALUE ? i : getContentInsetEnd();
    }

    public int getContentInsetLeft() {
        C1245y2 c1245y2 = this.f614w;
        if (c1245y2 != null) {
            return c1245y2.m1793b();
        }
        return 0;
    }

    public int getContentInsetRight() {
        C1245y2 c1245y2 = this.f614w;
        if (c1245y2 != null) {
            return c1245y2.m1792c();
        }
        return 0;
    }

    public int getContentInsetStart() {
        C1245y2 c1245y2 = this.f614w;
        if (c1245y2 != null) {
            return c1245y2.m1791d();
        }
        return 0;
    }

    public int getContentInsetStartWithNavigation() {
        int i = this.f615x;
        return i != Integer.MIN_VALUE ? i : getContentInsetStart();
    }

    public int getCurrentContentInsetEnd() {
        C0103e m4778J;
        ActionMenuView actionMenuView = this.f595d;
        return actionMenuView != null && (m4778J = actionMenuView.m4778J()) != null && m4778J.hasVisibleItems() ? Math.max(getContentInsetEnd(), Math.max(this.f616y, 0)) : getContentInsetEnd();
    }

    public int getCurrentContentInsetLeft() {
        return C0829h1.m2816r(this) == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart();
    }

    public int getCurrentContentInsetRight() {
        return C0829h1.m2816r(this) == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd();
    }

    public int getCurrentContentInsetStart() {
        return getNavigationIcon() != null ? Math.max(getContentInsetStart(), Math.max(this.f615x, 0)) : getContentInsetStart();
    }

    public Drawable getLogo() {
        ImageView imageView = this.f599h;
        if (imageView != null) {
            return imageView.getDrawable();
        }
        return null;
    }

    public CharSequence getLogoDescription() {
        ImageView imageView = this.f599h;
        if (imageView != null) {
            return imageView.getContentDescription();
        }
        return null;
    }

    public Menu getMenu() {
        m4686j();
        return this.f595d.getMenu();
    }

    public View getNavButtonView() {
        return this.f598g;
    }

    public CharSequence getNavigationContentDescription() {
        ImageButton imageButton = this.f598g;
        if (imageButton != null) {
            return imageButton.getContentDescription();
        }
        return null;
    }

    public Drawable getNavigationIcon() {
        ImageButton imageButton = this.f598g;
        if (imageButton != null) {
            return imageButton.getDrawable();
        }
        return null;
    }

    public C0163a getOuterActionMenuPresenter() {
        return this.f586N;
    }

    public Drawable getOverflowIcon() {
        m4686j();
        return this.f595d.getOverflowIcon();
    }

    public Context getPopupContext() {
        return this.f604m;
    }

    public int getPopupTheme() {
        return this.f605n;
    }

    public CharSequence getSubtitle() {
        return this.f574B;
    }

    public final TextView getSubtitleTextView() {
        return this.f597f;
    }

    public CharSequence getTitle() {
        return this.f573A;
    }

    public int getTitleMarginBottom() {
        return this.f613v;
    }

    public int getTitleMarginEnd() {
        return this.f611t;
    }

    public int getTitleMarginStart() {
        return this.f610s;
    }

    public int getTitleMarginTop() {
        return this.f612u;
    }

    public final TextView getTitleTextView() {
        return this.f596e;
    }

    public InterfaceC1110h2 getWrapper() {
        if (this.f585M == null) {
            this.f585M = new C0180e(this, true);
        }
        return this.f585M;
    }

    /* renamed from: h */
    public final void m4688h() {
        if (this.f614w == null) {
            this.f614w = new C1245y2();
        }
    }

    /* renamed from: i */
    public final void m4687i() {
        if (this.f599h == null) {
            this.f599h = new C1183q(getContext());
        }
    }

    /* renamed from: j */
    public final void m4686j() {
        m4685k();
        if (this.f595d.m4778J() == null) {
            C0103e c0103e = (C0103e) this.f595d.getMenu();
            if (this.f587O == null) {
                this.f587O = new C0157f();
            }
            this.f595d.setExpandedActionViewsExclusive(true);
            c0103e.m4887c(this.f587O, this.f604m);
            m4696Q();
        }
    }

    /* renamed from: k */
    public final void m4685k() {
        if (this.f595d == null) {
            ActionMenuView actionMenuView = new ActionMenuView(getContext());
            this.f595d = actionMenuView;
            actionMenuView.setPopupTheme(this.f605n);
            this.f595d.setOnMenuItemClickListener(this.f584L);
            this.f595d.m4777K(this.f588P, new C0154c());
            C0158g generateDefaultLayoutParams = generateDefaultLayoutParams();
            generateDefaultLayoutParams.f1935a = (this.f608q & 112) | 8388613;
            this.f595d.setLayoutParams(generateDefaultLayoutParams);
            m4693c(this.f595d, false);
        }
    }

    /* renamed from: l */
    public final void m4684l() {
        if (this.f598g == null) {
            this.f598g = new C1163o(getContext(), null, C0485a.toolbarNavigationButtonStyle);
            C0158g generateDefaultLayoutParams = generateDefaultLayoutParams();
            generateDefaultLayoutParams.f1935a = (this.f608q & 112) | 8388611;
            this.f598g.setLayoutParams(generateDefaultLayoutParams);
        }
    }

    @Override // android.view.ViewGroup
    /* renamed from: m */
    public C0158g generateDefaultLayoutParams() {
        return new C0158g(-2, -2);
    }

    @Override // android.view.ViewGroup
    /* renamed from: n */
    public C0158g generateLayoutParams(AttributeSet attributeSet) {
        return new C0158g(getContext(), attributeSet);
    }

    @Override // android.view.ViewGroup
    /* renamed from: o */
    public C0158g generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof C0158g ? new C0158g((C0158g) layoutParams) : layoutParams instanceof AbstractC0521a.C0522a ? new C0158g((AbstractC0521a.C0522a) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new C0158g((ViewGroup.MarginLayoutParams) layoutParams) : new C0158g(layoutParams);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        m4696Q();
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        removeCallbacks(this.f594V);
        m4696Q();
    }

    @Override // android.view.View
    public boolean onHoverEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 9) {
            this.f578F = false;
        }
        if (!this.f578F) {
            boolean onHoverEvent = super.onHoverEvent(motionEvent);
            if (actionMasked == 9 && !onHoverEvent) {
                this.f578F = true;
            }
        }
        if (actionMasked == 10 || actionMasked == 3) {
            this.f578F = false;
        }
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:110:0x0295 A[LOOP:0: B:109:0x0293->B:110:0x0295, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:113:0x02b7 A[LOOP:1: B:112:0x02b5->B:113:0x02b7, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:117:0x02e1  */
    /* JADX WARN: Removed duplicated region for block: B:122:0x02f0 A[LOOP:2: B:121:0x02ee->B:122:0x02f0, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x005d  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0072  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x00ad  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x00c2  */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00dd  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x00fb  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x0113  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x0123  */
    /* JADX WARN: Removed duplicated region for block: B:56:0x0126  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x012a  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x012d  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x015e  */
    /* JADX WARN: Removed duplicated region for block: B:81:0x019c  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x01ad  */
    /* JADX WARN: Removed duplicated region for block: B:96:0x021d  */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void onLayout(boolean z, int i, int i2, int i3, int i4) {
        int i5;
        int i6;
        boolean m4698O;
        boolean m4698O2;
        int i7;
        int i8;
        int i9;
        int i10;
        int i11;
        int i12;
        int i13;
        int paddingTop;
        int i14;
        int i15;
        int i16;
        int i17;
        int i18;
        int i19;
        int size;
        int i20;
        int size2;
        int i21;
        int i22;
        int size3;
        boolean z2 = C0829h1.m2816r(this) == 1;
        int width = getWidth();
        int height = getHeight();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int paddingTop2 = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int i23 = width - paddingRight;
        int[] iArr = this.f581I;
        iArr[1] = 0;
        iArr[0] = 0;
        int m2815s = C0829h1.m2815s(this);
        int min = m2815s >= 0 ? Math.min(m2815s, i4 - i2) : 0;
        if (m4698O(this.f598g)) {
            ImageButton imageButton = this.f598g;
            if (z2) {
                i6 = m4709D(imageButton, i23, iArr, min);
                i5 = paddingLeft;
                if (m4698O(this.f602k)) {
                    ImageButton imageButton2 = this.f602k;
                    if (z2) {
                        i6 = m4709D(imageButton2, i6, iArr, min);
                    } else {
                        i5 = m4710C(imageButton2, i5, iArr, min);
                    }
                }
                if (m4698O(this.f595d)) {
                    ActionMenuView actionMenuView = this.f595d;
                    if (z2) {
                        i5 = m4710C(actionMenuView, i5, iArr, min);
                    } else {
                        i6 = m4709D(actionMenuView, i6, iArr, min);
                    }
                }
                int currentContentInsetLeft = getCurrentContentInsetLeft();
                int currentContentInsetRight = getCurrentContentInsetRight();
                iArr[0] = Math.max(0, currentContentInsetLeft - i5);
                iArr[1] = Math.max(0, currentContentInsetRight - (i23 - i6));
                int max = Math.max(i5, currentContentInsetLeft);
                int min2 = Math.min(i6, i23 - currentContentInsetRight);
                if (m4698O(this.f603l)) {
                    View view = this.f603l;
                    if (z2) {
                        min2 = m4709D(view, min2, iArr, min);
                    } else {
                        max = m4710C(view, max, iArr, min);
                    }
                }
                if (m4698O(this.f599h)) {
                    ImageView imageView = this.f599h;
                    if (z2) {
                        min2 = m4709D(imageView, min2, iArr, min);
                    } else {
                        max = m4710C(imageView, max, iArr, min);
                    }
                }
                m4698O = m4698O(this.f596e);
                m4698O2 = m4698O(this.f597f);
                if (m4698O) {
                    i7 = paddingRight;
                    i8 = 0;
                } else {
                    C0158g c0158g = (C0158g) this.f596e.getLayoutParams();
                    i7 = paddingRight;
                    i8 = ((ViewGroup.MarginLayoutParams) c0158g).topMargin + this.f596e.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) c0158g).bottomMargin + 0;
                }
                if (m4698O2) {
                    i9 = width;
                } else {
                    C0158g c0158g2 = (C0158g) this.f597f.getLayoutParams();
                    i9 = width;
                    i8 += ((ViewGroup.MarginLayoutParams) c0158g2).topMargin + this.f597f.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) c0158g2).bottomMargin;
                }
                if (!m4698O || m4698O2) {
                    TextView textView = !m4698O ? this.f596e : this.f597f;
                    TextView textView2 = !m4698O2 ? this.f597f : this.f596e;
                    C0158g c0158g3 = (C0158g) textView.getLayoutParams();
                    C0158g c0158g4 = (C0158g) textView2.getLayoutParams();
                    boolean z3 = (!m4698O && this.f596e.getMeasuredWidth() > 0) || (m4698O2 && this.f597f.getMeasuredWidth() > 0);
                    i10 = this.f617z & 112;
                    i11 = paddingLeft;
                    if (i10 != 48) {
                        i12 = max;
                        i13 = min;
                        paddingTop = getPaddingTop() + ((ViewGroup.MarginLayoutParams) c0158g3).topMargin + this.f612u;
                    } else if (i10 != 80) {
                        int i24 = (((height - paddingTop2) - paddingBottom) - i8) / 2;
                        int i25 = ((ViewGroup.MarginLayoutParams) c0158g3).topMargin;
                        i13 = min;
                        int i26 = this.f612u;
                        i12 = max;
                        if (i24 < i25 + i26) {
                            i24 = i25 + i26;
                        } else {
                            int i27 = (((height - paddingBottom) - i8) - i24) - paddingTop2;
                            int i28 = ((ViewGroup.MarginLayoutParams) c0158g3).bottomMargin;
                            int i29 = this.f613v;
                            if (i27 < i28 + i29) {
                                i24 = Math.max(0, i24 - ((((ViewGroup.MarginLayoutParams) c0158g4).bottomMargin + i29) - i27));
                            }
                        }
                        paddingTop = paddingTop2 + i24;
                    } else {
                        i12 = max;
                        i13 = min;
                        paddingTop = (((height - paddingBottom) - ((ViewGroup.MarginLayoutParams) c0158g4).bottomMargin) - this.f613v) - i8;
                    }
                    if (z2) {
                        if (z3) {
                            i15 = this.f610s;
                            i14 = 0;
                        } else {
                            i14 = 0;
                            i15 = 0;
                        }
                        int i30 = i15 - iArr[i14];
                        max = i12 + Math.max(i14, i30);
                        iArr[i14] = Math.max(i14, -i30);
                        if (m4698O) {
                            int measuredWidth = this.f596e.getMeasuredWidth() + max;
                            int measuredHeight = this.f596e.getMeasuredHeight() + paddingTop;
                            this.f596e.layout(max, paddingTop, measuredWidth, measuredHeight);
                            i16 = measuredWidth + this.f611t;
                            paddingTop = measuredHeight + ((ViewGroup.MarginLayoutParams) ((C0158g) this.f596e.getLayoutParams())).bottomMargin;
                        } else {
                            i16 = max;
                        }
                        if (m4698O2) {
                            int i31 = paddingTop + ((ViewGroup.MarginLayoutParams) ((C0158g) this.f597f.getLayoutParams())).topMargin;
                            int measuredWidth2 = this.f597f.getMeasuredWidth() + max;
                            this.f597f.layout(max, i31, measuredWidth2, this.f597f.getMeasuredHeight() + i31);
                            i17 = measuredWidth2 + this.f611t;
                        } else {
                            i17 = max;
                        }
                        if (z3) {
                            max = Math.max(i16, i17);
                        }
                        m4694b(this.f579G, 3);
                        size = this.f579G.size();
                        for (i20 = 0; i20 < size; i20++) {
                            max = m4710C(this.f579G.get(i20), max, iArr, i13);
                        }
                        int i32 = i13;
                        m4694b(this.f579G, 5);
                        size2 = this.f579G.size();
                        for (i21 = 0; i21 < size2; i21++) {
                            min2 = m4709D(this.f579G.get(i21), min2, iArr, i32);
                        }
                        m4694b(this.f579G, 1);
                        int m4675u = m4675u(this.f579G, iArr);
                        i22 = (i11 + (((i9 - i11) - i7) / 2)) - (m4675u / 2);
                        int i33 = m4675u + i22;
                        if (i22 >= max) {
                            max = i33 > min2 ? i22 - (i33 - min2) : i22;
                        }
                        size3 = this.f579G.size();
                        while (i14 < size3) {
                            max = m4710C(this.f579G.get(i14), max, iArr, i32);
                            i14++;
                        }
                        this.f579G.clear();
                        return;
                    }
                    int i34 = (z3 ? this.f610s : 0) - iArr[1];
                    min2 -= Math.max(0, i34);
                    iArr[1] = Math.max(0, -i34);
                    if (m4698O) {
                        int measuredWidth3 = min2 - this.f596e.getMeasuredWidth();
                        int measuredHeight2 = this.f596e.getMeasuredHeight() + paddingTop;
                        this.f596e.layout(measuredWidth3, paddingTop, min2, measuredHeight2);
                        i18 = measuredWidth3 - this.f611t;
                        paddingTop = measuredHeight2 + ((ViewGroup.MarginLayoutParams) ((C0158g) this.f596e.getLayoutParams())).bottomMargin;
                    } else {
                        i18 = min2;
                    }
                    if (m4698O2) {
                        int i35 = paddingTop + ((ViewGroup.MarginLayoutParams) ((C0158g) this.f597f.getLayoutParams())).topMargin;
                        this.f597f.layout(min2 - this.f597f.getMeasuredWidth(), i35, min2, this.f597f.getMeasuredHeight() + i35);
                        i19 = min2 - this.f611t;
                    } else {
                        i19 = min2;
                    }
                    if (z3) {
                        min2 = Math.min(i18, i19);
                    }
                    max = i12;
                } else {
                    i11 = paddingLeft;
                    i13 = min;
                }
                i14 = 0;
                m4694b(this.f579G, 3);
                size = this.f579G.size();
                while (i20 < size) {
                }
                int i322 = i13;
                m4694b(this.f579G, 5);
                size2 = this.f579G.size();
                while (i21 < size2) {
                }
                m4694b(this.f579G, 1);
                int m4675u2 = m4675u(this.f579G, iArr);
                i22 = (i11 + (((i9 - i11) - i7) / 2)) - (m4675u2 / 2);
                int i332 = m4675u2 + i22;
                if (i22 >= max) {
                }
                size3 = this.f579G.size();
                while (i14 < size3) {
                }
                this.f579G.clear();
                return;
            }
            i5 = m4710C(imageButton, paddingLeft, iArr, min);
        } else {
            i5 = paddingLeft;
        }
        i6 = i23;
        if (m4698O(this.f602k)) {
        }
        if (m4698O(this.f595d)) {
        }
        int currentContentInsetLeft2 = getCurrentContentInsetLeft();
        int currentContentInsetRight2 = getCurrentContentInsetRight();
        iArr[0] = Math.max(0, currentContentInsetLeft2 - i5);
        iArr[1] = Math.max(0, currentContentInsetRight2 - (i23 - i6));
        int max2 = Math.max(i5, currentContentInsetLeft2);
        int min22 = Math.min(i6, i23 - currentContentInsetRight2);
        if (m4698O(this.f603l)) {
        }
        if (m4698O(this.f599h)) {
        }
        m4698O = m4698O(this.f596e);
        m4698O2 = m4698O(this.f597f);
        if (m4698O) {
        }
        if (m4698O2) {
        }
        if (m4698O) {
        }
        if (!m4698O) {
        }
        if (!m4698O2) {
        }
        C0158g c0158g32 = (C0158g) textView.getLayoutParams();
        C0158g c0158g42 = (C0158g) textView2.getLayoutParams();
        if (m4698O) {
        }
        i10 = this.f617z & 112;
        i11 = paddingLeft;
        if (i10 != 48) {
        }
        if (z2) {
        }
    }

    @Override // android.view.View
    public void onMeasure(int i, int i2) {
        int i3;
        int i4;
        int i5;
        int i6;
        int i7;
        int i8;
        int i9;
        int[] iArr = this.f581I;
        boolean m1905b = C1187q3.m1905b(this);
        int i10 = !m1905b ? 1 : 0;
        if (m4698O(this.f598g)) {
            m4707F(this.f598g, i, 0, i2, 0, this.f609r);
            i3 = this.f598g.getMeasuredWidth() + m4677s(this.f598g);
            i4 = Math.max(0, this.f598g.getMeasuredHeight() + m4676t(this.f598g));
            i5 = View.combineMeasuredStates(0, this.f598g.getMeasuredState());
        } else {
            i3 = 0;
            i4 = 0;
            i5 = 0;
        }
        if (m4698O(this.f602k)) {
            m4707F(this.f602k, i, 0, i2, 0, this.f609r);
            i3 = this.f602k.getMeasuredWidth() + m4677s(this.f602k);
            i4 = Math.max(i4, this.f602k.getMeasuredHeight() + m4676t(this.f602k));
            i5 = View.combineMeasuredStates(i5, this.f602k.getMeasuredState());
        }
        int currentContentInsetStart = getCurrentContentInsetStart();
        int max = 0 + Math.max(currentContentInsetStart, i3);
        iArr[m1905b ? 1 : 0] = Math.max(0, currentContentInsetStart - i3);
        if (m4698O(this.f595d)) {
            m4707F(this.f595d, i, max, i2, 0, this.f609r);
            i6 = this.f595d.getMeasuredWidth() + m4677s(this.f595d);
            i4 = Math.max(i4, this.f595d.getMeasuredHeight() + m4676t(this.f595d));
            i5 = View.combineMeasuredStates(i5, this.f595d.getMeasuredState());
        } else {
            i6 = 0;
        }
        int currentContentInsetEnd = getCurrentContentInsetEnd();
        int max2 = max + Math.max(currentContentInsetEnd, i6);
        iArr[i10] = Math.max(0, currentContentInsetEnd - i6);
        if (m4698O(this.f603l)) {
            max2 += m4708E(this.f603l, i, max2, i2, 0, iArr);
            i4 = Math.max(i4, this.f603l.getMeasuredHeight() + m4676t(this.f603l));
            i5 = View.combineMeasuredStates(i5, this.f603l.getMeasuredState());
        }
        if (m4698O(this.f599h)) {
            max2 += m4708E(this.f599h, i, max2, i2, 0, iArr);
            i4 = Math.max(i4, this.f599h.getMeasuredHeight() + m4676t(this.f599h));
            i5 = View.combineMeasuredStates(i5, this.f599h.getMeasuredState());
        }
        int childCount = getChildCount();
        for (int i11 = 0; i11 < childCount; i11++) {
            View childAt = getChildAt(i11);
            if (((C0158g) childAt.getLayoutParams()).f625b == 0 && m4698O(childAt)) {
                max2 += m4708E(childAt, i, max2, i2, 0, iArr);
                i4 = Math.max(i4, childAt.getMeasuredHeight() + m4676t(childAt));
                i5 = View.combineMeasuredStates(i5, childAt.getMeasuredState());
            }
        }
        int i12 = this.f612u + this.f613v;
        int i13 = this.f610s + this.f611t;
        if (m4698O(this.f596e)) {
            m4708E(this.f596e, i, max2 + i13, i2, i12, iArr);
            int measuredWidth = this.f596e.getMeasuredWidth() + m4677s(this.f596e);
            i9 = this.f596e.getMeasuredHeight() + m4676t(this.f596e);
            i7 = View.combineMeasuredStates(i5, this.f596e.getMeasuredState());
            i8 = measuredWidth;
        } else {
            i7 = i5;
            i8 = 0;
            i9 = 0;
        }
        if (m4698O(this.f597f)) {
            i8 = Math.max(i8, m4708E(this.f597f, i, max2 + i13, i2, i9 + i12, iArr));
            i9 += this.f597f.getMeasuredHeight() + m4676t(this.f597f);
            i7 = View.combineMeasuredStates(i7, this.f597f.getMeasuredState());
        }
        int max3 = Math.max(i4, i9);
        setMeasuredDimension(View.resolveSizeAndState(Math.max(max2 + i8 + getPaddingLeft() + getPaddingRight(), getSuggestedMinimumWidth()), i, (-16777216) & i7), m4699N() ? 0 : View.resolveSizeAndState(Math.max(max3 + getPaddingTop() + getPaddingBottom(), getSuggestedMinimumHeight()), i2, i7 << 16));
    }

    @Override // android.view.View
    public void onRestoreInstanceState(Parcelable parcelable) {
        MenuItem findItem;
        if (!(parcelable instanceof C0160i)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        C0160i c0160i = (C0160i) parcelable;
        super.onRestoreInstanceState(c0160i.m1308a());
        ActionMenuView actionMenuView = this.f595d;
        C0103e m4778J = actionMenuView != null ? actionMenuView.m4778J() : null;
        int i = c0160i.f626f;
        if (i != 0 && this.f587O != null && m4778J != null && (findItem = m4778J.findItem(i)) != null) {
            findItem.expandActionView();
        }
        if (c0160i.f627g) {
            m4705H();
        }
    }

    @Override // android.view.View
    public void onRtlPropertiesChanged(int i) {
        if (Build.VERSION.SDK_INT >= 17) {
            super.onRtlPropertiesChanged(i);
        }
        m4688h();
        this.f614w.m1789f(i == 1);
    }

    @Override // android.view.View
    public Parcelable onSaveInstanceState() {
        C0107g c0107g;
        C0160i c0160i = new C0160i(super.onSaveInstanceState());
        C0157f c0157f = this.f587O;
        if (c0157f != null && (c0107g = c0157f.f623e) != null) {
            c0160i.f626f = c0107g.getItemId();
        }
        c0160i.f627g = m4711B();
        return c0160i;
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f577E = false;
        }
        if (!this.f577E) {
            boolean onTouchEvent = super.onTouchEvent(motionEvent);
            if (actionMasked == 0 && !onTouchEvent) {
                this.f577E = true;
            }
        }
        if (actionMasked == 1 || actionMasked == 3) {
            this.f577E = false;
        }
        return true;
    }

    /* renamed from: p */
    public final int m4680p(int i) {
        int m2816r = C0829h1.m2816r(this);
        int m2528a = C0936r.m2528a(i, m2816r) & 7;
        return (m2528a == 1 || m2528a == 3 || m2528a == 5) ? m2528a : m2816r == 1 ? 5 : 3;
    }

    /* renamed from: q */
    public final int m4679q(View view, int i) {
        C0158g c0158g = (C0158g) view.getLayoutParams();
        int measuredHeight = view.getMeasuredHeight();
        int i2 = i > 0 ? (measuredHeight - i) / 2 : 0;
        int m4678r = m4678r(c0158g.f1935a);
        if (m4678r != 48) {
            if (m4678r != 80) {
                int paddingTop = getPaddingTop();
                int paddingBottom = getPaddingBottom();
                int height = getHeight();
                int i3 = (((height - paddingTop) - paddingBottom) - measuredHeight) / 2;
                int i4 = ((ViewGroup.MarginLayoutParams) c0158g).topMargin;
                if (i3 < i4) {
                    i3 = i4;
                } else {
                    int i5 = (((height - paddingBottom) - measuredHeight) - i3) - paddingTop;
                    int i6 = ((ViewGroup.MarginLayoutParams) c0158g).bottomMargin;
                    if (i5 < i6) {
                        i3 = Math.max(0, i3 - (i6 - i5));
                    }
                }
                return paddingTop + i3;
            }
            return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) c0158g).bottomMargin) - i2;
        }
        return getPaddingTop() - i2;
    }

    /* renamed from: r */
    public final int m4678r(int i) {
        int i2 = i & 112;
        return (i2 == 16 || i2 == 48 || i2 == 80) ? i2 : this.f617z & 112;
    }

    /* renamed from: s */
    public final int m4677s(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return C0792c0.m2907b(marginLayoutParams) + C0792c0.m2908a(marginLayoutParams);
    }

    public void setBackInvokedCallbackEnabled(boolean z) {
        if (this.f593U != z) {
            this.f593U = z;
            m4696Q();
        }
    }

    public void setCollapseContentDescription(int i) {
        setCollapseContentDescription(i != 0 ? getContext().getText(i) : null);
    }

    public void setCollapseContentDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            m4689g();
        }
        ImageButton imageButton = this.f602k;
        if (imageButton != null) {
            imageButton.setContentDescription(charSequence);
        }
    }

    public void setCollapseIcon(int i) {
        setCollapseIcon(C0640a.m3229b(getContext(), i));
    }

    public void setCollapseIcon(Drawable drawable) {
        if (drawable != null) {
            m4689g();
            this.f602k.setImageDrawable(drawable);
            return;
        }
        ImageButton imageButton = this.f602k;
        if (imageButton != null) {
            imageButton.setImageDrawable(this.f600i);
        }
    }

    public void setCollapsible(boolean z) {
        this.f590R = z;
        requestLayout();
    }

    public void setContentInsetEndWithActions(int i) {
        if (i < 0) {
            i = Integer.MIN_VALUE;
        }
        if (i != this.f616y) {
            this.f616y = i;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    public void setContentInsetStartWithNavigation(int i) {
        if (i < 0) {
            i = Integer.MIN_VALUE;
        }
        if (i != this.f615x) {
            this.f615x = i;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    public void setLogo(int i) {
        setLogo(C0640a.m3229b(getContext(), i));
    }

    public void setLogo(Drawable drawable) {
        if (drawable != null) {
            m4687i();
            if (!m4670z(this.f599h)) {
                m4693c(this.f599h, true);
            }
        } else {
            ImageView imageView = this.f599h;
            if (imageView != null && m4670z(imageView)) {
                removeView(this.f599h);
                this.f580H.remove(this.f599h);
            }
        }
        ImageView imageView2 = this.f599h;
        if (imageView2 != null) {
            imageView2.setImageDrawable(drawable);
        }
    }

    public void setLogoDescription(int i) {
        setLogoDescription(getContext().getText(i));
    }

    public void setLogoDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            m4687i();
        }
        ImageView imageView = this.f599h;
        if (imageView != null) {
            imageView.setContentDescription(charSequence);
        }
    }

    public void setNavigationContentDescription(int i) {
        setNavigationContentDescription(i != 0 ? getContext().getText(i) : null);
    }

    public void setNavigationContentDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            m4684l();
        }
        ImageButton imageButton = this.f598g;
        if (imageButton != null) {
            imageButton.setContentDescription(charSequence);
            C1134k3.m2064a(this.f598g, charSequence);
        }
    }

    public void setNavigationIcon(int i) {
        setNavigationIcon(C0640a.m3229b(getContext(), i));
    }

    public void setNavigationIcon(Drawable drawable) {
        if (drawable != null) {
            m4684l();
            if (!m4670z(this.f598g)) {
                m4693c(this.f598g, true);
            }
        } else {
            ImageButton imageButton = this.f598g;
            if (imageButton != null && m4670z(imageButton)) {
                removeView(this.f598g);
                this.f580H.remove(this.f598g);
            }
        }
        ImageButton imageButton2 = this.f598g;
        if (imageButton2 != null) {
            imageButton2.setImageDrawable(drawable);
        }
    }

    public void setNavigationOnClickListener(View.OnClickListener onClickListener) {
        m4684l();
        this.f598g.setOnClickListener(onClickListener);
    }

    public void setOnMenuItemClickListener(InterfaceC0159h interfaceC0159h) {
    }

    public void setOverflowIcon(Drawable drawable) {
        m4686j();
        this.f595d.setOverflowIcon(drawable);
    }

    public void setPopupTheme(int i) {
        if (this.f605n != i) {
            this.f605n = i;
            if (i == 0) {
                this.f604m = getContext();
            } else {
                this.f604m = new ContextThemeWrapper(getContext(), i);
            }
        }
    }

    public void setSubtitle(int i) {
        setSubtitle(getContext().getText(i));
    }

    public void setSubtitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            TextView textView = this.f597f;
            if (textView != null && m4670z(textView)) {
                removeView(this.f597f);
                this.f580H.remove(this.f597f);
            }
        } else {
            if (this.f597f == null) {
                Context context = getContext();
                C1165o1 c1165o1 = new C1165o1(context);
                this.f597f = c1165o1;
                c1165o1.setSingleLine();
                this.f597f.setEllipsize(TextUtils.TruncateAt.END);
                int i = this.f607p;
                if (i != 0) {
                    this.f597f.setTextAppearance(context, i);
                }
                ColorStateList colorStateList = this.f576D;
                if (colorStateList != null) {
                    this.f597f.setTextColor(colorStateList);
                }
            }
            if (!m4670z(this.f597f)) {
                m4693c(this.f597f, true);
            }
        }
        TextView textView2 = this.f597f;
        if (textView2 != null) {
            textView2.setText(charSequence);
        }
        this.f574B = charSequence;
    }

    public void setSubtitleTextColor(int i) {
        setSubtitleTextColor(ColorStateList.valueOf(i));
    }

    public void setSubtitleTextColor(ColorStateList colorStateList) {
        this.f576D = colorStateList;
        TextView textView = this.f597f;
        if (textView != null) {
            textView.setTextColor(colorStateList);
        }
    }

    public void setTitle(int i) {
        setTitle(getContext().getText(i));
    }

    public void setTitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            TextView textView = this.f596e;
            if (textView != null && m4670z(textView)) {
                removeView(this.f596e);
                this.f580H.remove(this.f596e);
            }
        } else {
            if (this.f596e == null) {
                Context context = getContext();
                C1165o1 c1165o1 = new C1165o1(context);
                this.f596e = c1165o1;
                c1165o1.setSingleLine();
                this.f596e.setEllipsize(TextUtils.TruncateAt.END);
                int i = this.f606o;
                if (i != 0) {
                    this.f596e.setTextAppearance(context, i);
                }
                ColorStateList colorStateList = this.f575C;
                if (colorStateList != null) {
                    this.f596e.setTextColor(colorStateList);
                }
            }
            if (!m4670z(this.f596e)) {
                m4693c(this.f596e, true);
            }
        }
        TextView textView2 = this.f596e;
        if (textView2 != null) {
            textView2.setText(charSequence);
        }
        this.f573A = charSequence;
    }

    public void setTitleMarginBottom(int i) {
        this.f613v = i;
        requestLayout();
    }

    public void setTitleMarginEnd(int i) {
        this.f611t = i;
        requestLayout();
    }

    public void setTitleMarginStart(int i) {
        this.f610s = i;
        requestLayout();
    }

    public void setTitleMarginTop(int i) {
        this.f612u = i;
        requestLayout();
    }

    public void setTitleTextColor(int i) {
        setTitleTextColor(ColorStateList.valueOf(i));
    }

    public void setTitleTextColor(ColorStateList colorStateList) {
        this.f575C = colorStateList;
        TextView textView = this.f596e;
        if (textView != null) {
            textView.setTextColor(colorStateList);
        }
    }

    /* renamed from: t */
    public final int m4676t(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
    }

    /* renamed from: u */
    public final int m4675u(List<View> list, int[] iArr) {
        int i = iArr[0];
        int i2 = iArr[1];
        int size = list.size();
        int i3 = 0;
        int i4 = 0;
        while (i3 < size) {
            View view = list.get(i3);
            C0158g c0158g = (C0158g) view.getLayoutParams();
            int i5 = ((ViewGroup.MarginLayoutParams) c0158g).leftMargin - i;
            int i6 = ((ViewGroup.MarginLayoutParams) c0158g).rightMargin - i2;
            int max = Math.max(0, i5);
            int max2 = Math.max(0, i6);
            int max3 = Math.max(0, -i5);
            int max4 = Math.max(0, -i6);
            i4 += max + view.getMeasuredWidth() + max2;
            i3++;
            i2 = max4;
            i = max3;
        }
        return i4;
    }

    /* renamed from: v */
    public boolean m4674v() {
        C0157f c0157f = this.f587O;
        return (c0157f == null || c0157f.f623e == null) ? false : true;
    }

    /* renamed from: w */
    public boolean m4673w() {
        ActionMenuView actionMenuView = this.f595d;
        return actionMenuView != null && actionMenuView.m4784D();
    }

    /* renamed from: x */
    public void m4672x(int i) {
        getMenuInflater().inflate(i, getMenu());
    }

    /* renamed from: y */
    public void m4671y() {
        Iterator<MenuItem> it = this.f583K.iterator();
        while (it.hasNext()) {
            getMenu().removeItem(it.next().getItemId());
        }
        m4706G();
    }

    /* renamed from: z */
    public final boolean m4670z(View view) {
        return view.getParent() == this || this.f580H.contains(view);
    }
}