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.KeyEvent;
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 androidx.appcompat.app.a;
import androidx.appcompat.view.menu.g;
import androidx.appcompat.view.menu.m;
import androidx.appcompat.widget.ActionMenuView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class Toolbar extends ViewGroup {
    private int A;
    private CharSequence B;
    private CharSequence C;
    private ColorStateList D;
    private ColorStateList E;
    private boolean F;
    private boolean G;
    private final ArrayList<View> H;
    private final ArrayList<View> I;
    private final int[] J;
    final androidx.core.view.i K;
    private ArrayList<MenuItem> L;
    f M;
    private final ActionMenuView.e N;
    private c1 O;
    private androidx.appcompat.widget.c P;
    private d Q;
    private m.a R;
    private g.a S;
    private boolean T;
    private final Runnable U;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private ActionMenuView f728e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private TextView f729f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private TextView f730g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private ImageButton f731h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private ImageView f732i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private Drawable f733j;

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    ImageButton f735l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    View f736m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private Context f737n;

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

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private int f739p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    private int f740q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    int f741r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    private int f742s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    private int f743t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    private int f744u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    private int f745v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    private int f746w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private s0 f747x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    private int f748y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    private int f749z;

    class a implements ActionMenuView.e {
        a() {
        }

        @Override // androidx.appcompat.widget.ActionMenuView.e
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (Toolbar.this.K.c(menuItem)) {
                return true;
            }
            f fVar = Toolbar.this.M;
            if (fVar != null) {
                return fVar.onMenuItemClick(menuItem);
            }
            return false;
        }
    }

    class b implements Runnable {
        b() {
        }

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

    class c implements View.OnClickListener {
        c() {
        }

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

    private class d implements androidx.appcompat.view.menu.m {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        androidx.appcompat.view.menu.g f753e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        androidx.appcompat.view.menu.i f754f;

        d() {
        }

        @Override // androidx.appcompat.view.menu.m
        public void b(androidx.appcompat.view.menu.g gVar, boolean z2) {
        }

        @Override // androidx.appcompat.view.menu.m
        public boolean d() {
            return false;
        }

        @Override // androidx.appcompat.view.menu.m
        public void e(Context context, androidx.appcompat.view.menu.g gVar) {
            androidx.appcompat.view.menu.i iVar;
            androidx.appcompat.view.menu.g gVar2 = this.f753e;
            if (gVar2 != null && (iVar = this.f754f) != null) {
                gVar2.f(iVar);
            }
            this.f753e = gVar;
        }

        @Override // androidx.appcompat.view.menu.m
        public boolean f(androidx.appcompat.view.menu.g gVar, androidx.appcompat.view.menu.i iVar) {
            KeyEvent.Callback callback = Toolbar.this.f736m;
            if (callback instanceof androidx.appcompat.view.c) {
                ((androidx.appcompat.view.c) callback).f();
            }
            Toolbar toolbar = Toolbar.this;
            toolbar.removeView(toolbar.f736m);
            Toolbar toolbar2 = Toolbar.this;
            toolbar2.removeView(toolbar2.f735l);
            Toolbar toolbar3 = Toolbar.this;
            toolbar3.f736m = null;
            toolbar3.a();
            this.f754f = null;
            Toolbar.this.requestLayout();
            iVar.q(false);
            return true;
        }

        @Override // androidx.appcompat.view.menu.m
        public boolean g(androidx.appcompat.view.menu.g gVar, androidx.appcompat.view.menu.i iVar) {
            Toolbar.this.g();
            ViewParent parent = Toolbar.this.f735l.getParent();
            Toolbar toolbar = Toolbar.this;
            if (parent != toolbar) {
                if (parent instanceof ViewGroup) {
                    ((ViewGroup) parent).removeView(toolbar.f735l);
                }
                Toolbar toolbar2 = Toolbar.this;
                toolbar2.addView(toolbar2.f735l);
            }
            Toolbar.this.f736m = iVar.getActionView();
            this.f754f = iVar;
            ViewParent parent2 = Toolbar.this.f736m.getParent();
            Toolbar toolbar3 = Toolbar.this;
            if (parent2 != toolbar3) {
                if (parent2 instanceof ViewGroup) {
                    ((ViewGroup) parent2).removeView(toolbar3.f736m);
                }
                e eVarGenerateDefaultLayoutParams = Toolbar.this.generateDefaultLayoutParams();
                Toolbar toolbar4 = Toolbar.this;
                eVarGenerateDefaultLayoutParams.f163a = 8388611 | (toolbar4.f741r & 112);
                eVarGenerateDefaultLayoutParams.f756b = 2;
                toolbar4.f736m.setLayoutParams(eVarGenerateDefaultLayoutParams);
                Toolbar toolbar5 = Toolbar.this;
                toolbar5.addView(toolbar5.f736m);
            }
            Toolbar.this.I();
            Toolbar.this.requestLayout();
            iVar.q(true);
            KeyEvent.Callback callback = Toolbar.this.f736m;
            if (callback instanceof androidx.appcompat.view.c) {
                ((androidx.appcompat.view.c) callback).c();
            }
            return true;
        }

        @Override // androidx.appcompat.view.menu.m
        public boolean i(androidx.appcompat.view.menu.r rVar) {
            return false;
        }

        @Override // androidx.appcompat.view.menu.m
        public void j(boolean z2) {
            if (this.f754f != null) {
                androidx.appcompat.view.menu.g gVar = this.f753e;
                boolean z3 = false;
                if (gVar != null) {
                    int size = gVar.size();
                    int i3 = 0;
                    while (true) {
                        if (i3 >= size) {
                            break;
                        }
                        if (this.f753e.getItem(i3) == this.f754f) {
                            z3 = true;
                            break;
                        }
                        i3++;
                    }
                }
                if (z3) {
                    return;
                }
                f(this.f753e, this.f754f);
            }
        }
    }

    public interface f {
        boolean onMenuItemClick(MenuItem menuItem);
    }

    public Toolbar(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, c.a.N);
    }

    private int C(View view, int i3, int[] iArr, int i4) {
        e eVar = (e) view.getLayoutParams();
        int i5 = ((ViewGroup.MarginLayoutParams) eVar).leftMargin - iArr[0];
        int iMax = i3 + Math.max(0, i5);
        iArr[0] = Math.max(0, -i5);
        int iQ = q(view, i4);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax, iQ, iMax + measuredWidth, view.getMeasuredHeight() + iQ);
        return iMax + measuredWidth + ((ViewGroup.MarginLayoutParams) eVar).rightMargin;
    }

    private int D(View view, int i3, int[] iArr, int i4) {
        e eVar = (e) view.getLayoutParams();
        int i5 = ((ViewGroup.MarginLayoutParams) eVar).rightMargin - iArr[1];
        int iMax = i3 - Math.max(0, i5);
        iArr[1] = Math.max(0, -i5);
        int iQ = q(view, i4);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax - measuredWidth, iQ, iMax, view.getMeasuredHeight() + iQ);
        return iMax - (measuredWidth + ((ViewGroup.MarginLayoutParams) eVar).leftMargin);
    }

    private int E(View view, int i3, int i4, int i5, int i6, int[] iArr) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int i7 = marginLayoutParams.leftMargin - iArr[0];
        int i8 = marginLayoutParams.rightMargin - iArr[1];
        int iMax = Math.max(0, i7) + Math.max(0, i8);
        iArr[0] = Math.max(0, -i7);
        iArr[1] = Math.max(0, -i8);
        view.measure(ViewGroup.getChildMeasureSpec(i3, getPaddingLeft() + getPaddingRight() + iMax + i4, marginLayoutParams.width), ViewGroup.getChildMeasureSpec(i5, getPaddingTop() + getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i6, marginLayoutParams.height));
        return view.getMeasuredWidth() + iMax;
    }

    private void F(View view, int i3, int i4, int i5, int i6, int i7) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int childMeasureSpec = ViewGroup.getChildMeasureSpec(i3, getPaddingLeft() + getPaddingRight() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i4, marginLayoutParams.width);
        int childMeasureSpec2 = ViewGroup.getChildMeasureSpec(i5, getPaddingTop() + getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i6, marginLayoutParams.height);
        int mode = View.MeasureSpec.getMode(childMeasureSpec2);
        if (mode != 1073741824 && i7 >= 0) {
            if (mode != 0) {
                i7 = Math.min(View.MeasureSpec.getSize(childMeasureSpec2), i7);
            }
            childMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i7, 1073741824);
        }
        view.measure(childMeasureSpec, childMeasureSpec2);
    }

    private void G() {
        Menu menu = getMenu();
        ArrayList<MenuItem> currentMenuItems = getCurrentMenuItems();
        this.K.a(menu, getMenuInflater());
        ArrayList<MenuItem> currentMenuItems2 = getCurrentMenuItems();
        currentMenuItems2.removeAll(currentMenuItems);
        this.L = currentMenuItems2;
        this.K.d(menu);
    }

    private void H() {
        removeCallbacks(this.U);
        post(this.U);
    }

    private boolean N() {
        if (!this.T) {
            return false;
        }
        int childCount = getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View childAt = getChildAt(i3);
            if (O(childAt) && childAt.getMeasuredWidth() > 0 && childAt.getMeasuredHeight() > 0) {
                return false;
            }
        }
        return true;
    }

    private boolean O(View view) {
        return (view == null || view.getParent() != this || view.getVisibility() == 8) ? false : true;
    }

    private void b(List<View> list, int i3) {
        boolean z2 = androidx.core.view.y.E(this) == 1;
        int childCount = getChildCount();
        int iB = androidx.core.view.e.b(i3, androidx.core.view.y.E(this));
        list.clear();
        if (!z2) {
            for (int i4 = 0; i4 < childCount; i4++) {
                View childAt = getChildAt(i4);
                e eVar = (e) childAt.getLayoutParams();
                if (eVar.f756b == 0 && O(childAt) && p(eVar.f163a) == iB) {
                    list.add(childAt);
                }
            }
            return;
        }
        for (int i5 = childCount - 1; i5 >= 0; i5--) {
            View childAt2 = getChildAt(i5);
            e eVar2 = (e) childAt2.getLayoutParams();
            if (eVar2.f756b == 0 && O(childAt2) && p(eVar2.f163a) == iB) {
                list.add(childAt2);
            }
        }
    }

    private void c(View view, boolean z2) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        e eVarGenerateDefaultLayoutParams = layoutParams == null ? generateDefaultLayoutParams() : !checkLayoutParams(layoutParams) ? generateLayoutParams(layoutParams) : (e) layoutParams;
        eVarGenerateDefaultLayoutParams.f756b = 1;
        if (!z2 || this.f736m == null) {
            addView(view, eVarGenerateDefaultLayoutParams);
        } else {
            view.setLayoutParams(eVarGenerateDefaultLayoutParams);
            this.I.add(view);
        }
    }

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

    private MenuInflater getMenuInflater() {
        return new androidx.appcompat.view.g(getContext());
    }

    private void h() {
        if (this.f747x == null) {
            this.f747x = new s0();
        }
    }

    private void i() {
        if (this.f732i == null) {
            this.f732i = new r(getContext());
        }
    }

    private void j() {
        k();
        if (this.f728e.N() == null) {
            androidx.appcompat.view.menu.g gVar = (androidx.appcompat.view.menu.g) this.f728e.getMenu();
            if (this.Q == null) {
                this.Q = new d();
            }
            this.f728e.setExpandedActionViewsExclusive(true);
            gVar.c(this.Q, this.f737n);
        }
    }

    private void k() {
        if (this.f728e == null) {
            ActionMenuView actionMenuView = new ActionMenuView(getContext());
            this.f728e = actionMenuView;
            actionMenuView.setPopupTheme(this.f738o);
            this.f728e.setOnMenuItemClickListener(this.N);
            this.f728e.O(this.R, this.S);
            e eVarGenerateDefaultLayoutParams = generateDefaultLayoutParams();
            eVarGenerateDefaultLayoutParams.f163a = 8388613 | (this.f741r & 112);
            this.f728e.setLayoutParams(eVarGenerateDefaultLayoutParams);
            c(this.f728e, false);
        }
    }

    private void l() {
        if (this.f731h == null) {
            this.f731h = new p(getContext(), null, c.a.M);
            e eVarGenerateDefaultLayoutParams = generateDefaultLayoutParams();
            eVarGenerateDefaultLayoutParams.f163a = 8388611 | (this.f741r & 112);
            this.f731h.setLayoutParams(eVarGenerateDefaultLayoutParams);
        }
    }

    private int p(int i3) {
        int iE = androidx.core.view.y.E(this);
        int iB = androidx.core.view.e.b(i3, iE) & 7;
        return (iB == 1 || iB == 3 || iB == 5) ? iB : iE == 1 ? 5 : 3;
    }

    private int q(View view, int i3) {
        e eVar = (e) view.getLayoutParams();
        int measuredHeight = view.getMeasuredHeight();
        int i4 = i3 > 0 ? (measuredHeight - i3) / 2 : 0;
        int iR = r(eVar.f163a);
        if (iR == 48) {
            return getPaddingTop() - i4;
        }
        if (iR == 80) {
            return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) eVar).bottomMargin) - i4;
        }
        int paddingTop = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int height = getHeight();
        int iMax = (((height - paddingTop) - paddingBottom) - measuredHeight) / 2;
        int i5 = ((ViewGroup.MarginLayoutParams) eVar).topMargin;
        if (iMax < i5) {
            iMax = i5;
        } else {
            int i6 = (((height - paddingBottom) - measuredHeight) - iMax) - paddingTop;
            int i7 = ((ViewGroup.MarginLayoutParams) eVar).bottomMargin;
            if (i6 < i7) {
                iMax = Math.max(0, iMax - (i7 - i6));
            }
        }
        return paddingTop + iMax;
    }

    private int r(int i3) {
        int i4 = i3 & 112;
        return (i4 == 16 || i4 == 48 || i4 == 80) ? i4 : this.A & 112;
    }

    private int s(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return androidx.core.view.h.b(marginLayoutParams) + androidx.core.view.h.a(marginLayoutParams);
    }

    private int t(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
    }

    private int u(List<View> list, int[] iArr) {
        int i3 = iArr[0];
        int i4 = iArr[1];
        int size = list.size();
        int i5 = 0;
        int measuredWidth = 0;
        while (i5 < size) {
            View view = list.get(i5);
            e eVar = (e) view.getLayoutParams();
            int i6 = ((ViewGroup.MarginLayoutParams) eVar).leftMargin - i3;
            int i7 = ((ViewGroup.MarginLayoutParams) eVar).rightMargin - i4;
            int iMax = Math.max(0, i6);
            int iMax2 = Math.max(0, i7);
            int iMax3 = Math.max(0, -i6);
            int iMax4 = Math.max(0, -i7);
            measuredWidth += iMax + view.getMeasuredWidth() + iMax2;
            i5++;
            i4 = iMax4;
            i3 = iMax3;
        }
        return measuredWidth;
    }

    private boolean z(View view) {
        return view.getParent() == this || this.I.contains(view);
    }

    public boolean A() {
        ActionMenuView actionMenuView = this.f728e;
        return actionMenuView != null && actionMenuView.I();
    }

    public boolean B() {
        ActionMenuView actionMenuView = this.f728e;
        return actionMenuView != null && actionMenuView.J();
    }

    void I() {
        for (int childCount = getChildCount() - 1; childCount >= 0; childCount--) {
            View childAt = getChildAt(childCount);
            if (((e) childAt.getLayoutParams()).f756b != 2 && childAt != this.f728e) {
                removeViewAt(childCount);
                this.I.add(childAt);
            }
        }
    }

    public void J(int i3, int i4) {
        h();
        this.f747x.g(i3, i4);
    }

    public void K(androidx.appcompat.view.menu.g gVar, androidx.appcompat.widget.c cVar) {
        if (gVar == null && this.f728e == null) {
            return;
        }
        k();
        androidx.appcompat.view.menu.g gVarN = this.f728e.N();
        if (gVarN == gVar) {
            return;
        }
        if (gVarN != null) {
            gVarN.O(this.P);
            gVarN.O(this.Q);
        }
        if (this.Q == null) {
            this.Q = new d();
        }
        cVar.G(true);
        if (gVar != null) {
            gVar.c(cVar, this.f737n);
            gVar.c(this.Q, this.f737n);
        } else {
            cVar.e(this.f737n, null);
            this.Q.e(this.f737n, null);
            cVar.j(true);
            this.Q.j(true);
        }
        this.f728e.setPopupTheme(this.f738o);
        this.f728e.setPresenter(cVar);
        this.P = cVar;
    }

    public void L(Context context, int i3) {
        this.f740q = i3;
        TextView textView = this.f730g;
        if (textView != null) {
            textView.setTextAppearance(context, i3);
        }
    }

    public void M(Context context, int i3) {
        this.f739p = i3;
        TextView textView = this.f729f;
        if (textView != null) {
            textView.setTextAppearance(context, i3);
        }
    }

    public boolean P() {
        ActionMenuView actionMenuView = this.f728e;
        return actionMenuView != null && actionMenuView.P();
    }

    void a() {
        for (int size = this.I.size() - 1; size >= 0; size--) {
            addView(this.I.get(size));
        }
        this.I.clear();
    }

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

    public boolean d() {
        ActionMenuView actionMenuView;
        return getVisibility() == 0 && (actionMenuView = this.f728e) != null && actionMenuView.K();
    }

    public void e() {
        d dVar = this.Q;
        androidx.appcompat.view.menu.i iVar = dVar == null ? null : dVar.f754f;
        if (iVar != null) {
            iVar.collapseActionView();
        }
    }

    public void f() {
        ActionMenuView actionMenuView = this.f728e;
        if (actionMenuView != null) {
            actionMenuView.B();
        }
    }

    void g() {
        if (this.f735l == null) {
            p pVar = new p(getContext(), null, c.a.M);
            this.f735l = pVar;
            pVar.setImageDrawable(this.f733j);
            this.f735l.setContentDescription(this.f734k);
            e eVarGenerateDefaultLayoutParams = generateDefaultLayoutParams();
            eVarGenerateDefaultLayoutParams.f163a = 8388611 | (this.f741r & 112);
            eVarGenerateDefaultLayoutParams.f756b = 2;
            this.f735l.setLayoutParams(eVarGenerateDefaultLayoutParams);
            this.f735l.setOnClickListener(new c());
        }
    }

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

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

    public int getContentInsetEnd() {
        s0 s0Var = this.f747x;
        if (s0Var != null) {
            return s0Var.a();
        }
        return 0;
    }

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

    public int getContentInsetLeft() {
        s0 s0Var = this.f747x;
        if (s0Var != null) {
            return s0Var.b();
        }
        return 0;
    }

    public int getContentInsetRight() {
        s0 s0Var = this.f747x;
        if (s0Var != null) {
            return s0Var.c();
        }
        return 0;
    }

    public int getContentInsetStart() {
        s0 s0Var = this.f747x;
        if (s0Var != null) {
            return s0Var.d();
        }
        return 0;
    }

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

    public int getCurrentContentInsetEnd() {
        androidx.appcompat.view.menu.g gVarN;
        ActionMenuView actionMenuView = this.f728e;
        return actionMenuView != null && (gVarN = actionMenuView.N()) != null && gVarN.hasVisibleItems() ? Math.max(getContentInsetEnd(), Math.max(this.f749z, 0)) : getContentInsetEnd();
    }

    public int getCurrentContentInsetLeft() {
        return androidx.core.view.y.E(this) == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart();
    }

    public int getCurrentContentInsetRight() {
        return androidx.core.view.y.E(this) == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd();
    }

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

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

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

    public Menu getMenu() {
        j();
        return this.f728e.getMenu();
    }

    View getNavButtonView() {
        return this.f731h;
    }

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

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

    androidx.appcompat.widget.c getOuterActionMenuPresenter() {
        return this.P;
    }

    public Drawable getOverflowIcon() {
        j();
        return this.f728e.getOverflowIcon();
    }

    Context getPopupContext() {
        return this.f737n;
    }

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

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

    final TextView getSubtitleTextView() {
        return this.f730g;
    }

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

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

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

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

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

    final TextView getTitleTextView() {
        return this.f729f;
    }

    public h0 getWrapper() {
        if (this.O == null) {
            this.O = new c1(this, true);
        }
        return this.O;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: m, reason: merged with bridge method [inline-methods] */
    public e generateDefaultLayoutParams() {
        return new e(-2, -2);
    }

    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: n, reason: merged with bridge method [inline-methods] */
    public e generateLayoutParams(AttributeSet attributeSet) {
        return new e(getContext(), attributeSet);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.view.ViewGroup
    /* JADX INFO: renamed from: o, reason: merged with bridge method [inline-methods] */
    public e generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof e ? new e((e) layoutParams) : layoutParams instanceof a.C0002a ? new e((a.C0002a) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new e((ViewGroup.MarginLayoutParams) layoutParams) : new e(layoutParams);
    }

    @Override // android.view.ViewGroup, android.view.View
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        removeCallbacks(this.U);
    }

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

    /* JADX WARN: Removed duplicated region for block: B:105:0x029f A[LOOP:0: B:104:0x029d->B:105:0x029f, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:108:0x02c1 A[LOOP:1: B:107:0x02bf->B:108:0x02c1, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:112:0x02eb  */
    /* JADX WARN: Removed duplicated region for block: B:117:0x02fa A[LOOP:2: B:116:0x02f8->B:117:0x02fa, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x005f  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0076  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00b3  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00ca  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00e7  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0100  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0105  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x011d  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x012b  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x012d  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x0130  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0134  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0137  */
    /* JADX WARN: Removed duplicated region for block: B:66:0x0168  */
    /* JADX WARN: Removed duplicated region for block: B:76:0x01a6  */
    /* JADX WARN: Removed duplicated region for block: B:78:0x01b7  */
    /* JADX WARN: Removed duplicated region for block: B:91:0x0227  */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    protected void onLayout(boolean r20, int r21, int r22, int r23, int r24) {
        /*
            Method dump skipped, instruction units count: 783
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.Toolbar.onLayout(boolean, int, int, int, int):void");
    }

    @Override // android.view.View
    protected void onMeasure(int i3, int i4) {
        int measuredWidth;
        int iMax;
        int iCombineMeasuredStates;
        int measuredWidth2;
        int measuredHeight;
        int iCombineMeasuredStates2;
        int iMax2;
        int[] iArr = this.J;
        boolean zB = j1.b(this);
        int i5 = !zB ? 1 : 0;
        if (O(this.f731h)) {
            F(this.f731h, i3, 0, i4, 0, this.f742s);
            measuredWidth = this.f731h.getMeasuredWidth() + s(this.f731h);
            iMax = Math.max(0, this.f731h.getMeasuredHeight() + t(this.f731h));
            iCombineMeasuredStates = View.combineMeasuredStates(0, this.f731h.getMeasuredState());
        } else {
            measuredWidth = 0;
            iMax = 0;
            iCombineMeasuredStates = 0;
        }
        if (O(this.f735l)) {
            F(this.f735l, i3, 0, i4, 0, this.f742s);
            measuredWidth = this.f735l.getMeasuredWidth() + s(this.f735l);
            iMax = Math.max(iMax, this.f735l.getMeasuredHeight() + t(this.f735l));
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f735l.getMeasuredState());
        }
        int currentContentInsetStart = getCurrentContentInsetStart();
        int iMax3 = 0 + Math.max(currentContentInsetStart, measuredWidth);
        iArr[zB ? 1 : 0] = Math.max(0, currentContentInsetStart - measuredWidth);
        if (O(this.f728e)) {
            F(this.f728e, i3, iMax3, i4, 0, this.f742s);
            measuredWidth2 = this.f728e.getMeasuredWidth() + s(this.f728e);
            iMax = Math.max(iMax, this.f728e.getMeasuredHeight() + t(this.f728e));
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f728e.getMeasuredState());
        } else {
            measuredWidth2 = 0;
        }
        int currentContentInsetEnd = getCurrentContentInsetEnd();
        int iMax4 = iMax3 + Math.max(currentContentInsetEnd, measuredWidth2);
        iArr[i5] = Math.max(0, currentContentInsetEnd - measuredWidth2);
        if (O(this.f736m)) {
            iMax4 += E(this.f736m, i3, iMax4, i4, 0, iArr);
            iMax = Math.max(iMax, this.f736m.getMeasuredHeight() + t(this.f736m));
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f736m.getMeasuredState());
        }
        if (O(this.f732i)) {
            iMax4 += E(this.f732i, i3, iMax4, i4, 0, iArr);
            iMax = Math.max(iMax, this.f732i.getMeasuredHeight() + t(this.f732i));
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f732i.getMeasuredState());
        }
        int childCount = getChildCount();
        for (int i6 = 0; i6 < childCount; i6++) {
            View childAt = getChildAt(i6);
            if (((e) childAt.getLayoutParams()).f756b == 0 && O(childAt)) {
                iMax4 += E(childAt, i3, iMax4, i4, 0, iArr);
                iMax = Math.max(iMax, childAt.getMeasuredHeight() + t(childAt));
                iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, childAt.getMeasuredState());
            }
        }
        int i7 = this.f745v + this.f746w;
        int i8 = this.f743t + this.f744u;
        if (O(this.f729f)) {
            E(this.f729f, i3, iMax4 + i8, i4, i7, iArr);
            int measuredWidth3 = this.f729f.getMeasuredWidth() + s(this.f729f);
            measuredHeight = this.f729f.getMeasuredHeight() + t(this.f729f);
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates, this.f729f.getMeasuredState());
            iMax2 = measuredWidth3;
        } else {
            measuredHeight = 0;
            iCombineMeasuredStates2 = iCombineMeasuredStates;
            iMax2 = 0;
        }
        if (O(this.f730g)) {
            iMax2 = Math.max(iMax2, E(this.f730g, i3, iMax4 + i8, i4, measuredHeight + i7, iArr));
            measuredHeight += this.f730g.getMeasuredHeight() + t(this.f730g);
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates2, this.f730g.getMeasuredState());
        }
        setMeasuredDimension(View.resolveSizeAndState(Math.max(iMax4 + iMax2 + getPaddingLeft() + getPaddingRight(), getSuggestedMinimumWidth()), i3, (-16777216) & iCombineMeasuredStates2), N() ? 0 : View.resolveSizeAndState(Math.max(Math.max(iMax, measuredHeight) + getPaddingTop() + getPaddingBottom(), getSuggestedMinimumHeight()), i4, iCombineMeasuredStates2 << 16));
    }

    @Override // android.view.View
    protected void onRestoreInstanceState(Parcelable parcelable) {
        MenuItem menuItemFindItem;
        if (!(parcelable instanceof g)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        g gVar = (g) parcelable;
        super.onRestoreInstanceState(gVar.j());
        ActionMenuView actionMenuView = this.f728e;
        androidx.appcompat.view.menu.g gVarN = actionMenuView != null ? actionMenuView.N() : null;
        int i3 = gVar.f757g;
        if (i3 != 0 && this.Q != null && gVarN != null && (menuItemFindItem = gVarN.findItem(i3)) != null) {
            menuItemFindItem.expandActionView();
        }
        if (gVar.f758h) {
            H();
        }
    }

    @Override // android.view.View
    public void onRtlPropertiesChanged(int i3) {
        if (Build.VERSION.SDK_INT >= 17) {
            super.onRtlPropertiesChanged(i3);
        }
        h();
        this.f747x.f(i3 == 1);
    }

    @Override // android.view.View
    protected Parcelable onSaveInstanceState() {
        androidx.appcompat.view.menu.i iVar;
        g gVar = new g(super.onSaveInstanceState());
        d dVar = this.Q;
        if (dVar != null && (iVar = dVar.f754f) != null) {
            gVar.f757g = iVar.getItemId();
        }
        gVar.f758h = B();
        return gVar;
    }

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

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

    public void setCollapseIcon(int i3) {
        setCollapseIcon(d.a.b(getContext(), i3));
    }

    public void setCollapsible(boolean z2) {
        this.T = z2;
        requestLayout();
    }

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

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

    public void setLogo(int i3) {
        setLogo(d.a.b(getContext(), i3));
    }

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

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

    public void setNavigationIcon(int i3) {
        setNavigationIcon(d.a.b(getContext(), i3));
    }

    public void setNavigationOnClickListener(View.OnClickListener onClickListener) {
        l();
        this.f731h.setOnClickListener(onClickListener);
    }

    public void setOnMenuItemClickListener(f fVar) {
        this.M = fVar;
    }

    public void setOverflowIcon(Drawable drawable) {
        j();
        this.f728e.setOverflowIcon(drawable);
    }

    public void setPopupTheme(int i3) {
        if (this.f738o != i3) {
            this.f738o = i3;
            if (i3 == 0) {
                this.f737n = getContext();
            } else {
                this.f737n = new ContextThemeWrapper(getContext(), i3);
            }
        }
    }

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

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

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

    public void setTitleMarginBottom(int i3) {
        this.f746w = i3;
        requestLayout();
    }

    public void setTitleMarginEnd(int i3) {
        this.f744u = i3;
        requestLayout();
    }

    public void setTitleMarginStart(int i3) {
        this.f743t = i3;
        requestLayout();
    }

    public void setTitleMarginTop(int i3) {
        this.f745v = i3;
        requestLayout();
    }

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

    public boolean v() {
        d dVar = this.Q;
        return (dVar == null || dVar.f754f == null) ? false : true;
    }

    public boolean w() {
        ActionMenuView actionMenuView = this.f728e;
        return actionMenuView != null && actionMenuView.H();
    }

    public void x(int i3) {
        getMenuInflater().inflate(i3, getMenu());
    }

    public void y() {
        Iterator<MenuItem> it = this.L.iterator();
        while (it.hasNext()) {
            getMenu().removeItem(it.next().getItemId());
        }
        G();
    }

    public static class e extends a.C0002a {

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

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

        void a(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;
        }

        public e(int i3, int i4) {
            super(i3, i4);
            this.f756b = 0;
            this.f163a = 8388627;
        }

        public e(e eVar) {
            super((a.C0002a) eVar);
            this.f756b = 0;
            this.f756b = eVar.f756b;
        }

        public e(a.C0002a c0002a) {
            super(c0002a);
            this.f756b = 0;
        }

        public e(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
            this.f756b = 0;
            a(marginLayoutParams);
        }

        public e(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f756b = 0;
        }
    }

    public Toolbar(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        this.A = 8388627;
        this.H = new ArrayList<>();
        this.I = new ArrayList<>();
        this.J = new int[2];
        this.K = new androidx.core.view.i(new Runnable() { // from class: androidx.appcompat.widget.b1
            @Override // java.lang.Runnable
            public final void run() {
                this.f804e.y();
            }
        });
        this.L = new ArrayList<>();
        this.N = new a();
        this.U = new b();
        Context context2 = getContext();
        int[] iArr = c.j.K2;
        a1 a1VarV = a1.v(context2, attributeSet, iArr, i3, 0);
        androidx.core.view.y.p0(this, context, iArr, attributeSet, a1VarV.r(), i3, 0);
        this.f739p = a1VarV.n(c.j.m3, 0);
        this.f740q = a1VarV.n(c.j.d3, 0);
        this.A = a1VarV.l(c.j.L2, this.A);
        this.f741r = a1VarV.l(c.j.M2, 48);
        int iE = a1VarV.e(c.j.g3, 0);
        int i4 = c.j.l3;
        iE = a1VarV.s(i4) ? a1VarV.e(i4, iE) : iE;
        this.f746w = iE;
        this.f745v = iE;
        this.f744u = iE;
        this.f743t = iE;
        int iE2 = a1VarV.e(c.j.j3, -1);
        if (iE2 >= 0) {
            this.f743t = iE2;
        }
        int iE3 = a1VarV.e(c.j.i3, -1);
        if (iE3 >= 0) {
            this.f744u = iE3;
        }
        int iE4 = a1VarV.e(c.j.k3, -1);
        if (iE4 >= 0) {
            this.f745v = iE4;
        }
        int iE5 = a1VarV.e(c.j.h3, -1);
        if (iE5 >= 0) {
            this.f746w = iE5;
        }
        this.f742s = a1VarV.f(c.j.X2, -1);
        int iE6 = a1VarV.e(c.j.T2, Integer.MIN_VALUE);
        int iE7 = a1VarV.e(c.j.P2, Integer.MIN_VALUE);
        int iF = a1VarV.f(c.j.R2, 0);
        int iF2 = a1VarV.f(c.j.S2, 0);
        h();
        this.f747x.e(iF, iF2);
        if (iE6 != Integer.MIN_VALUE || iE7 != Integer.MIN_VALUE) {
            this.f747x.g(iE6, iE7);
        }
        this.f748y = a1VarV.e(c.j.U2, Integer.MIN_VALUE);
        this.f749z = a1VarV.e(c.j.Q2, Integer.MIN_VALUE);
        this.f733j = a1VarV.g(c.j.O2);
        this.f734k = a1VarV.p(c.j.N2);
        CharSequence charSequenceP = a1VarV.p(c.j.f3);
        if (!TextUtils.isEmpty(charSequenceP)) {
            setTitle(charSequenceP);
        }
        CharSequence charSequenceP2 = a1VarV.p(c.j.c3);
        if (!TextUtils.isEmpty(charSequenceP2)) {
            setSubtitle(charSequenceP2);
        }
        this.f737n = getContext();
        setPopupTheme(a1VarV.n(c.j.b3, 0));
        Drawable drawableG = a1VarV.g(c.j.a3);
        if (drawableG != null) {
            setNavigationIcon(drawableG);
        }
        CharSequence charSequenceP3 = a1VarV.p(c.j.Z2);
        if (!TextUtils.isEmpty(charSequenceP3)) {
            setNavigationContentDescription(charSequenceP3);
        }
        Drawable drawableG2 = a1VarV.g(c.j.V2);
        if (drawableG2 != null) {
            setLogo(drawableG2);
        }
        CharSequence charSequenceP4 = a1VarV.p(c.j.W2);
        if (!TextUtils.isEmpty(charSequenceP4)) {
            setLogoDescription(charSequenceP4);
        }
        int i5 = c.j.n3;
        if (a1VarV.s(i5)) {
            setTitleTextColor(a1VarV.c(i5));
        }
        int i6 = c.j.e3;
        if (a1VarV.s(i6)) {
            setSubtitleTextColor(a1VarV.c(i6));
        }
        int i7 = c.j.Y2;
        if (a1VarV.s(i7)) {
            x(a1VarV.n(i7, 0));
        }
        a1VarV.w();
    }

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

    public void setCollapseIcon(Drawable drawable) {
        if (drawable != null) {
            g();
            this.f735l.setImageDrawable(drawable);
        } else {
            ImageButton imageButton = this.f735l;
            if (imageButton != null) {
                imageButton.setImageDrawable(this.f733j);
            }
        }
    }

    public void setLogo(Drawable drawable) {
        if (drawable != null) {
            i();
            if (!z(this.f732i)) {
                c(this.f732i, true);
            }
        } else {
            ImageView imageView = this.f732i;
            if (imageView != null && z(imageView)) {
                removeView(this.f732i);
                this.I.remove(this.f732i);
            }
        }
        ImageView imageView2 = this.f732i;
        if (imageView2 != null) {
            imageView2.setImageDrawable(drawable);
        }
    }

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

    public void setNavigationContentDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            l();
        }
        ImageButton imageButton = this.f731h;
        if (imageButton != null) {
            imageButton.setContentDescription(charSequence);
            d1.a(this.f731h, charSequence);
        }
    }

    public void setNavigationIcon(Drawable drawable) {
        if (drawable != null) {
            l();
            if (!z(this.f731h)) {
                c(this.f731h, true);
            }
        } else {
            ImageButton imageButton = this.f731h;
            if (imageButton != null && z(imageButton)) {
                removeView(this.f731h);
                this.I.remove(this.f731h);
            }
        }
        ImageButton imageButton2 = this.f731h;
        if (imageButton2 != null) {
            imageButton2.setImageDrawable(drawable);
        }
    }

    public void setSubtitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            TextView textView = this.f730g;
            if (textView != null && z(textView)) {
                removeView(this.f730g);
                this.I.remove(this.f730g);
            }
        } else {
            if (this.f730g == null) {
                Context context = getContext();
                d0 d0Var = new d0(context);
                this.f730g = d0Var;
                d0Var.setSingleLine();
                this.f730g.setEllipsize(TextUtils.TruncateAt.END);
                int i3 = this.f740q;
                if (i3 != 0) {
                    this.f730g.setTextAppearance(context, i3);
                }
                ColorStateList colorStateList = this.E;
                if (colorStateList != null) {
                    this.f730g.setTextColor(colorStateList);
                }
            }
            if (!z(this.f730g)) {
                c(this.f730g, true);
            }
        }
        TextView textView2 = this.f730g;
        if (textView2 != null) {
            textView2.setText(charSequence);
        }
        this.C = charSequence;
    }

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

    public void setTitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            TextView textView = this.f729f;
            if (textView != null && z(textView)) {
                removeView(this.f729f);
                this.I.remove(this.f729f);
            }
        } else {
            if (this.f729f == null) {
                Context context = getContext();
                d0 d0Var = new d0(context);
                this.f729f = d0Var;
                d0Var.setSingleLine();
                this.f729f.setEllipsize(TextUtils.TruncateAt.END);
                int i3 = this.f739p;
                if (i3 != 0) {
                    this.f729f.setTextAppearance(context, i3);
                }
                ColorStateList colorStateList = this.D;
                if (colorStateList != null) {
                    this.f729f.setTextColor(colorStateList);
                }
            }
            if (!z(this.f729f)) {
                c(this.f729f, true);
            }
        }
        TextView textView2 = this.f729f;
        if (textView2 != null) {
            textView2.setText(charSequence);
        }
        this.B = charSequence;
    }

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

    public static class g extends w.a {
        public static final Parcelable.Creator<g> CREATOR = new a();

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        int f757g;

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

        class a implements Parcelable.ClassLoaderCreator<g> {
            a() {
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public g createFromParcel(Parcel parcel) {
                return new g(parcel, null);
            }

            @Override // android.os.Parcelable.ClassLoaderCreator
            /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
            public g createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new g(parcel, classLoader);
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public g[] newArray(int i3) {
                return new g[i3];
            }
        }

        public g(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.f757g = parcel.readInt();
            this.f758h = parcel.readInt() != 0;
        }

        @Override // w.a, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i3) {
            super.writeToParcel(parcel, i3);
            parcel.writeInt(this.f757g);
            parcel.writeInt(this.f758h ? 1 : 0);
        }

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