package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
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 android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.appcompat.widget.ActionMenuView;
import androidx.customview.view.AbsSavedState;
import c.b.c.e;
import c.b.e.i.g;
import c.b.e.i.i;
import c.b.e.i.m;
import c.b.e.i.r;
import c.b.f.d1;
import c.b.f.f0;
import c.b.f.f1;
import c.b.f.g1;
import c.b.f.i1;
import c.b.f.j0;
import c.b.f.q;
import c.b.f.s;
import c.b.f.v0;
import c.f.j.a0;
import c.f.j.i0;
import c.f.j.k;
import c.f.j.l;
import com.ifpdos.debugmenu.R;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public class Toolbar extends ViewGroup {
    public CharSequence A;
    public CharSequence B;
    public ColorStateList C;
    public ColorStateList D;
    public boolean E;
    public boolean F;
    public final ArrayList<View> G;
    public final ArrayList<View> H;
    public final int[] I;
    public final l J;
    public ArrayList<MenuItem> K;
    public h L;
    public final ActionMenuView.e M;
    public f1 N;
    public ActionMenuPresenter O;
    public f P;
    public m.a Q;
    public g.a R;
    public boolean S;
    public OnBackInvokedCallback T;
    public OnBackInvokedDispatcher U;
    public boolean V;
    public final Runnable W;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public View f210l;
    public Context m;
    public int n;
    public int o;
    public int p;
    public int q;
    public int r;
    public int s;
    public int t;
    public int u;
    public int v;
    public v0 w;
    public int x;
    public int y;
    public int z;

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

    public class b implements Runnable {
        public b() {
        }

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

    public class c implements g.a {
        public c() {
        }

        @Override // c.b.e.i.g.a
        public boolean a(c.b.e.i.g gVar, MenuItem menuItem) {
            g.a aVar = Toolbar.this.R;
            return aVar != null && aVar.a(gVar, menuItem);
        }

        @Override // c.b.e.i.g.a
        public void b(c.b.e.i.g gVar) {
            ActionMenuPresenter actionMenuPresenter = Toolbar.this.f202b.w;
            if (!(actionMenuPresenter != null && actionMenuPresenter.m())) {
                Toolbar.this.J.c(gVar);
            }
            g.a aVar = Toolbar.this.R;
            if (aVar != null) {
                aVar.b(gVar);
            }
        }
    }

    public class d implements View.OnClickListener {
        public d() {
        }

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

    public static class e {
        public static OnBackInvokedDispatcher a(View view) {
            return view.findOnBackInvokedDispatcher();
        }

        public static OnBackInvokedCallback b(final Runnable runnable) {
            Objects.requireNonNull(runnable);
            return new OnBackInvokedCallback() { // from class: c.b.f.a
                @Override // android.window.OnBackInvokedCallback
                public final void onBackInvoked() {
                    runnable.run();
                }
            };
        }

        public static void c(Object obj, Object obj2) {
            ((OnBackInvokedDispatcher) obj).registerOnBackInvokedCallback(1000000, (OnBackInvokedCallback) obj2);
        }

        public static void d(Object obj, Object obj2) {
            ((OnBackInvokedDispatcher) obj).unregisterOnBackInvokedCallback((OnBackInvokedCallback) obj2);
        }
    }

    public class f implements m {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public c.b.e.i.g f216b;

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

        public f() {
        }

        @Override // c.b.e.i.m
        public void b(c.b.e.i.g gVar, boolean z) {
        }

        @Override // c.b.e.i.m
        public void c(boolean z) {
            if (this.f217e != null) {
                c.b.e.i.g gVar = this.f216b;
                boolean z2 = false;
                if (gVar != null) {
                    int size = gVar.size();
                    int i2 = 0;
                    while (true) {
                        if (i2 >= size) {
                            break;
                        }
                        if (this.f216b.getItem(i2) == this.f217e) {
                            z2 = true;
                            break;
                        }
                        i2++;
                    }
                }
                if (z2) {
                    return;
                }
                e(this.f216b, this.f217e);
            }
        }

        @Override // c.b.e.i.m
        public boolean d() {
            return false;
        }

        @Override // c.b.e.i.m
        public boolean e(c.b.e.i.g gVar, i iVar) {
            KeyEvent.Callback callback = Toolbar.this.f210l;
            if (callback instanceof c.b.e.b) {
                ((c.b.e.b) callback).d();
            }
            Toolbar toolbar = Toolbar.this;
            toolbar.removeView(toolbar.f210l);
            Toolbar toolbar2 = Toolbar.this;
            toolbar2.removeView(toolbar2.f209k);
            Toolbar toolbar3 = Toolbar.this;
            toolbar3.f210l = null;
            int size = toolbar3.H.size();
            while (true) {
                size--;
                if (size < 0) {
                    toolbar3.H.clear();
                    this.f217e = null;
                    Toolbar.this.requestLayout();
                    iVar.C = false;
                    iVar.n.q(false);
                    Toolbar.this.x();
                    return true;
                }
                toolbar3.addView(toolbar3.H.get(size));
            }
        }

        @Override // c.b.e.i.m
        public boolean f(c.b.e.i.g gVar, i iVar) {
            Toolbar.this.d();
            ViewParent parent = Toolbar.this.f209k.getParent();
            Toolbar toolbar = Toolbar.this;
            if (parent != toolbar) {
                if (parent instanceof ViewGroup) {
                    ((ViewGroup) parent).removeView(toolbar.f209k);
                }
                Toolbar toolbar2 = Toolbar.this;
                toolbar2.addView(toolbar2.f209k);
            }
            Toolbar.this.f210l = iVar.getActionView();
            this.f217e = iVar;
            ViewParent parent2 = Toolbar.this.f210l.getParent();
            Toolbar toolbar3 = Toolbar.this;
            if (parent2 != toolbar3) {
                if (parent2 instanceof ViewGroup) {
                    ((ViewGroup) parent2).removeView(toolbar3.f210l);
                }
                g gVarGenerateDefaultLayoutParams = Toolbar.this.generateDefaultLayoutParams();
                Toolbar toolbar4 = Toolbar.this;
                gVarGenerateDefaultLayoutParams.a = 8388611 | (toolbar4.q & 112);
                gVarGenerateDefaultLayoutParams.f219b = 2;
                toolbar4.f210l.setLayoutParams(gVarGenerateDefaultLayoutParams);
                Toolbar toolbar5 = Toolbar.this;
                toolbar5.addView(toolbar5.f210l);
            }
            Toolbar toolbar6 = Toolbar.this;
            int childCount = toolbar6.getChildCount();
            while (true) {
                childCount--;
                if (childCount < 0) {
                    break;
                }
                View childAt = toolbar6.getChildAt(childCount);
                if (((g) childAt.getLayoutParams()).f219b != 2 && childAt != toolbar6.f202b) {
                    toolbar6.removeViewAt(childCount);
                    toolbar6.H.add(childAt);
                }
            }
            Toolbar.this.requestLayout();
            iVar.C = true;
            iVar.n.q(false);
            KeyEvent.Callback callback = Toolbar.this.f210l;
            if (callback instanceof c.b.e.b) {
                ((c.b.e.b) callback).c();
            }
            Toolbar.this.x();
            return true;
        }

        @Override // c.b.e.i.m
        public void i(Context context, c.b.e.i.g gVar) {
            i iVar;
            c.b.e.i.g gVar2 = this.f216b;
            if (gVar2 != null && (iVar = this.f217e) != null) {
                gVar2.d(iVar);
            }
            this.f216b = gVar;
        }

        @Override // c.b.e.i.m
        public boolean k(r rVar) {
            return false;
        }
    }

    public interface h {
    }

    public Toolbar(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, R.attr.toolbarStyle);
        this.z = 8388627;
        this.G = new ArrayList<>();
        this.H = new ArrayList<>();
        this.I = new int[2];
        this.J = new l(new Runnable() { // from class: c.b.f.b
            @Override // java.lang.Runnable
            public final void run() {
                this.f776b.o();
            }
        });
        this.K = new ArrayList<>();
        this.M = new a();
        this.W = new b();
        Context context2 = getContext();
        int[] iArr = c.b.b.x;
        d1 d1VarO = d1.o(context2, attributeSet, iArr, R.attr.toolbarStyle, 0);
        a0.k(this, context, iArr, attributeSet, d1VarO.f806b, R.attr.toolbarStyle, 0);
        this.o = d1VarO.j(28, 0);
        this.p = d1VarO.j(19, 0);
        this.z = d1VarO.f806b.getInteger(0, this.z);
        this.q = d1VarO.f806b.getInteger(2, 48);
        int iC = d1VarO.c(22, 0);
        iC = d1VarO.m(27) ? d1VarO.c(27, iC) : iC;
        this.v = iC;
        this.u = iC;
        this.t = iC;
        this.s = iC;
        int iC2 = d1VarO.c(25, -1);
        if (iC2 >= 0) {
            this.s = iC2;
        }
        int iC3 = d1VarO.c(24, -1);
        if (iC3 >= 0) {
            this.t = iC3;
        }
        int iC4 = d1VarO.c(26, -1);
        if (iC4 >= 0) {
            this.u = iC4;
        }
        int iC5 = d1VarO.c(23, -1);
        if (iC5 >= 0) {
            this.v = iC5;
        }
        this.r = d1VarO.d(13, -1);
        int iC6 = d1VarO.c(9, Integer.MIN_VALUE);
        int iC7 = d1VarO.c(5, Integer.MIN_VALUE);
        int iD = d1VarO.d(7, 0);
        int iD2 = d1VarO.d(8, 0);
        e();
        v0 v0Var = this.w;
        v0Var.f971h = false;
        if (iD != Integer.MIN_VALUE) {
            v0Var.f968e = iD;
            v0Var.a = iD;
        }
        if (iD2 != Integer.MIN_VALUE) {
            v0Var.f969f = iD2;
            v0Var.f965b = iD2;
        }
        if (iC6 != Integer.MIN_VALUE || iC7 != Integer.MIN_VALUE) {
            v0Var.a(iC6, iC7);
        }
        this.x = d1VarO.c(10, Integer.MIN_VALUE);
        this.y = d1VarO.c(6, Integer.MIN_VALUE);
        this.f207i = d1VarO.e(4);
        this.f208j = d1VarO.l(3);
        CharSequence charSequenceL = d1VarO.l(21);
        if (!TextUtils.isEmpty(charSequenceL)) {
            setTitle(charSequenceL);
        }
        CharSequence charSequenceL2 = d1VarO.l(18);
        if (!TextUtils.isEmpty(charSequenceL2)) {
            setSubtitle(charSequenceL2);
        }
        this.m = getContext();
        setPopupTheme(d1VarO.j(17, 0));
        Drawable drawableE = d1VarO.e(16);
        if (drawableE != null) {
            setNavigationIcon(drawableE);
        }
        CharSequence charSequenceL3 = d1VarO.l(15);
        if (!TextUtils.isEmpty(charSequenceL3)) {
            setNavigationContentDescription(charSequenceL3);
        }
        Drawable drawableE2 = d1VarO.e(11);
        if (drawableE2 != null) {
            setLogo(drawableE2);
        }
        CharSequence charSequenceL4 = d1VarO.l(12);
        if (!TextUtils.isEmpty(charSequenceL4)) {
            setLogoDescription(charSequenceL4);
        }
        if (d1VarO.m(29)) {
            setTitleTextColor(d1VarO.b(29));
        }
        if (d1VarO.m(20)) {
            setSubtitleTextColor(d1VarO.b(20));
        }
        if (d1VarO.m(14)) {
            getMenuInflater().inflate(d1VarO.j(14, 0), getMenu());
        }
        d1VarO.f806b.recycle();
    }

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

    private MenuInflater getMenuInflater() {
        return new c.b.e.f(getContext());
    }

    public final void a(List<View> list, int i2) {
        WeakHashMap<View, i0> weakHashMap = a0.a;
        boolean z = a0.e.d(this) == 1;
        int childCount = getChildCount();
        int absoluteGravity = Gravity.getAbsoluteGravity(i2, a0.e.d(this));
        list.clear();
        if (!z) {
            for (int i3 = 0; i3 < childCount; i3++) {
                View childAt = getChildAt(i3);
                g gVar = (g) childAt.getLayoutParams();
                if (gVar.f219b == 0 && v(childAt) && k(gVar.a) == absoluteGravity) {
                    list.add(childAt);
                }
            }
            return;
        }
        for (int i4 = childCount - 1; i4 >= 0; i4--) {
            View childAt2 = getChildAt(i4);
            g gVar2 = (g) childAt2.getLayoutParams();
            if (gVar2.f219b == 0 && v(childAt2) && k(gVar2.a) == absoluteGravity) {
                list.add(childAt2);
            }
        }
    }

    public final void b(View view, boolean z) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        g gVarGenerateDefaultLayoutParams = layoutParams == null ? generateDefaultLayoutParams() : !checkLayoutParams(layoutParams) ? generateLayoutParams(layoutParams) : (g) layoutParams;
        gVarGenerateDefaultLayoutParams.f219b = 1;
        if (!z || this.f210l == null) {
            addView(view, gVarGenerateDefaultLayoutParams);
        } else {
            view.setLayoutParams(gVarGenerateDefaultLayoutParams);
            this.H.add(view);
        }
    }

    public void c() {
        f fVar = this.P;
        i iVar = fVar == null ? null : fVar.f217e;
        if (iVar != null) {
            iVar.collapseActionView();
        }
    }

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

    public void d() {
        if (this.f209k == null) {
            q qVar = new q(getContext(), null, R.attr.toolbarNavigationButtonStyle);
            this.f209k = qVar;
            qVar.setImageDrawable(this.f207i);
            this.f209k.setContentDescription(this.f208j);
            g gVarGenerateDefaultLayoutParams = generateDefaultLayoutParams();
            gVarGenerateDefaultLayoutParams.a = 8388611 | (this.q & 112);
            gVarGenerateDefaultLayoutParams.f219b = 2;
            this.f209k.setLayoutParams(gVarGenerateDefaultLayoutParams);
            this.f209k.setOnClickListener(new d());
        }
    }

    public final void e() {
        if (this.w == null) {
            this.w = new v0();
        }
    }

    public final void f() {
        g();
        ActionMenuView actionMenuView = this.f202b;
        if (actionMenuView.s == null) {
            c.b.e.i.g gVar = (c.b.e.i.g) actionMenuView.getMenu();
            if (this.P == null) {
                this.P = new f();
            }
            this.f202b.setExpandedActionViewsExclusive(true);
            gVar.b(this.P, this.m);
            x();
        }
    }

    public final void g() {
        if (this.f202b == null) {
            ActionMenuView actionMenuView = new ActionMenuView(getContext(), null);
            this.f202b = actionMenuView;
            actionMenuView.setPopupTheme(this.n);
            this.f202b.setOnMenuItemClickListener(this.M);
            ActionMenuView actionMenuView2 = this.f202b;
            m.a aVar = this.Q;
            c cVar = new c();
            actionMenuView2.x = aVar;
            actionMenuView2.y = cVar;
            g gVarGenerateDefaultLayoutParams = generateDefaultLayoutParams();
            gVarGenerateDefaultLayoutParams.a = 8388613 | (this.q & 112);
            this.f202b.setLayoutParams(gVarGenerateDefaultLayoutParams);
            b(this.f202b, false);
        }
    }

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

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

    public int getContentInsetEnd() {
        v0 v0Var = this.w;
        if (v0Var != null) {
            return v0Var.f970g ? v0Var.a : v0Var.f965b;
        }
        return 0;
    }

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

    public int getContentInsetLeft() {
        v0 v0Var = this.w;
        if (v0Var != null) {
            return v0Var.a;
        }
        return 0;
    }

    public int getContentInsetRight() {
        v0 v0Var = this.w;
        if (v0Var != null) {
            return v0Var.f965b;
        }
        return 0;
    }

    public int getContentInsetStart() {
        v0 v0Var = this.w;
        if (v0Var != null) {
            return v0Var.f970g ? v0Var.f965b : v0Var.a;
        }
        return 0;
    }

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

    public int getCurrentContentInsetEnd() {
        c.b.e.i.g gVar;
        ActionMenuView actionMenuView = this.f202b;
        return actionMenuView != null && (gVar = actionMenuView.s) != null && gVar.hasVisibleItems() ? Math.max(getContentInsetEnd(), Math.max(this.y, 0)) : getContentInsetEnd();
    }

    public int getCurrentContentInsetLeft() {
        WeakHashMap<View, i0> weakHashMap = a0.a;
        return a0.e.d(this) == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart();
    }

    public int getCurrentContentInsetRight() {
        WeakHashMap<View, i0> weakHashMap = a0.a;
        return a0.e.d(this) == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd();
    }

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

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

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

    public Menu getMenu() {
        f();
        return this.f202b.getMenu();
    }

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

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

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

    public ActionMenuPresenter getOuterActionMenuPresenter() {
        return this.O;
    }

    public Drawable getOverflowIcon() {
        f();
        return this.f202b.getOverflowIcon();
    }

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

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

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

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

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

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

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

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

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

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

    public j0 getWrapper() {
        if (this.N == null) {
            this.N = new f1(this, true);
        }
        return this.N;
    }

    public final void h() {
        if (this.f205g == null) {
            this.f205g = new q(getContext(), null, R.attr.toolbarNavigationButtonStyle);
            g gVarGenerateDefaultLayoutParams = generateDefaultLayoutParams();
            gVarGenerateDefaultLayoutParams.a = 8388611 | (this.q & 112);
            this.f205g.setLayoutParams(gVarGenerateDefaultLayoutParams);
        }
    }

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

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

    public final int k(int i2) {
        WeakHashMap<View, i0> weakHashMap = a0.a;
        int iD = a0.e.d(this);
        int absoluteGravity = Gravity.getAbsoluteGravity(i2, iD) & 7;
        return (absoluteGravity == 1 || absoluteGravity == 3 || absoluteGravity == 5) ? absoluteGravity : iD == 1 ? 5 : 3;
    }

    public final int l(View view, int i2) {
        g gVar = (g) view.getLayoutParams();
        int measuredHeight = view.getMeasuredHeight();
        int i3 = i2 > 0 ? (measuredHeight - i2) / 2 : 0;
        int i4 = gVar.a & 112;
        if (i4 != 16 && i4 != 48 && i4 != 80) {
            i4 = this.z & 112;
        }
        if (i4 == 48) {
            return getPaddingTop() - i3;
        }
        if (i4 == 80) {
            return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) gVar).bottomMargin) - i3;
        }
        int paddingTop = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int height = getHeight();
        int iMax = (((height - paddingTop) - paddingBottom) - measuredHeight) / 2;
        int i5 = ((ViewGroup.MarginLayoutParams) gVar).topMargin;
        if (iMax < i5) {
            iMax = i5;
        } else {
            int i6 = (((height - paddingBottom) - measuredHeight) - iMax) - paddingTop;
            int i7 = ((ViewGroup.MarginLayoutParams) gVar).bottomMargin;
            if (i6 < i7) {
                iMax = Math.max(0, iMax - (i7 - i6));
            }
        }
        return paddingTop + iMax;
    }

    public final int m(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return k.c(marginLayoutParams) + k.b(marginLayoutParams);
    }

    public final int n(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
    }

    public void o() {
        Iterator<MenuItem> it = this.K.iterator();
        while (it.hasNext()) {
            getMenu().removeItem(it.next().getItemId());
        }
        Menu menu = getMenu();
        ArrayList<MenuItem> currentMenuItems = getCurrentMenuItems();
        this.J.a(menu, getMenuInflater());
        ArrayList<MenuItem> currentMenuItems2 = getCurrentMenuItems();
        currentMenuItems2.removeAll(currentMenuItems);
        this.K = currentMenuItems2;
    }

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

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

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

    /* JADX WARN: Removed duplicated region for block: B:105:0x02a1 A[LOOP:0: B:104:0x029f->B:105:0x02a1, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:108:0x02c3 A[LOOP:1: B:107:0x02c1->B:108:0x02c3, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:111:0x02e8 A[LOOP:2: B:110:0x02e6->B:111:0x02e8, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:115:0x0329  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x033d A[LOOP:3: B:119:0x033b->B:120:0x033d, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0061  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0078  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00b5  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00cc  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00e9  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0102  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0107  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x011f  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x012c  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x012e  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0131  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0135  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0138  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0169  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x01a7  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x01b8  */
    /* JADX WARN: Removed duplicated region for block: B:90: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
    */
    public void onLayout(boolean r21, int r22, int r23, int r24, int r25) {
        /*
            Method dump skipped, instruction units count: 850
            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
    public void onMeasure(int i2, int i3) {
        char c2;
        char c3;
        int iM;
        int iMax;
        int iCombineMeasuredStates;
        int iM2;
        int iN;
        int iCombineMeasuredStates2;
        int iMax2;
        int[] iArr = this.I;
        boolean z = true;
        if (i1.b(this)) {
            c3 = 1;
            c2 = 0;
        } else {
            c2 = 1;
            c3 = 0;
        }
        if (v(this.f205g)) {
            u(this.f205g, i2, 0, i3, 0, this.r);
            iM = m(this.f205g) + this.f205g.getMeasuredWidth();
            iMax = Math.max(0, n(this.f205g) + this.f205g.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(0, this.f205g.getMeasuredState());
        } else {
            iM = 0;
            iMax = 0;
            iCombineMeasuredStates = 0;
        }
        if (v(this.f209k)) {
            u(this.f209k, i2, 0, i3, 0, this.r);
            iM = m(this.f209k) + this.f209k.getMeasuredWidth();
            iMax = Math.max(iMax, n(this.f209k) + this.f209k.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f209k.getMeasuredState());
        }
        int currentContentInsetStart = getCurrentContentInsetStart();
        int iMax3 = Math.max(currentContentInsetStart, iM) + 0;
        iArr[c3] = Math.max(0, currentContentInsetStart - iM);
        if (v(this.f202b)) {
            u(this.f202b, i2, iMax3, i3, 0, this.r);
            iM2 = m(this.f202b) + this.f202b.getMeasuredWidth();
            iMax = Math.max(iMax, n(this.f202b) + this.f202b.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f202b.getMeasuredState());
        } else {
            iM2 = 0;
        }
        int currentContentInsetEnd = getCurrentContentInsetEnd();
        int iMax4 = Math.max(currentContentInsetEnd, iM2) + iMax3;
        iArr[c2] = Math.max(0, currentContentInsetEnd - iM2);
        if (v(this.f210l)) {
            iMax4 += t(this.f210l, i2, iMax4, i3, 0, iArr);
            iMax = Math.max(iMax, n(this.f210l) + this.f210l.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f210l.getMeasuredState());
        }
        if (v(this.f206h)) {
            iMax4 += t(this.f206h, i2, iMax4, i3, 0, iArr);
            iMax = Math.max(iMax, n(this.f206h) + this.f206h.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f206h.getMeasuredState());
        }
        int childCount = getChildCount();
        for (int i4 = 0; i4 < childCount; i4++) {
            View childAt = getChildAt(i4);
            if (((g) childAt.getLayoutParams()).f219b == 0 && v(childAt)) {
                iMax4 += t(childAt, i2, iMax4, i3, 0, iArr);
                iMax = Math.max(iMax, n(childAt) + childAt.getMeasuredHeight());
                iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, childAt.getMeasuredState());
            }
        }
        int i5 = this.u + this.v;
        int i6 = this.s + this.t;
        if (v(this.f203e)) {
            t(this.f203e, i2, iMax4 + i6, i3, i5, iArr);
            int iM3 = m(this.f203e) + this.f203e.getMeasuredWidth();
            iN = n(this.f203e) + this.f203e.getMeasuredHeight();
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates, this.f203e.getMeasuredState());
            iMax2 = iM3;
        } else {
            iN = 0;
            iCombineMeasuredStates2 = iCombineMeasuredStates;
            iMax2 = 0;
        }
        if (v(this.f204f)) {
            iMax2 = Math.max(iMax2, t(this.f204f, i2, iMax4 + i6, i3, iN + i5, iArr));
            iN = n(this.f204f) + this.f204f.getMeasuredHeight() + iN;
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates2, this.f204f.getMeasuredState());
        }
        int iMax5 = Math.max(iMax, iN);
        int paddingRight = getPaddingRight() + getPaddingLeft();
        int paddingBottom = getPaddingBottom() + getPaddingTop() + iMax5;
        int iResolveSizeAndState = View.resolveSizeAndState(Math.max(paddingRight + iMax4 + iMax2, getSuggestedMinimumWidth()), i2, (-16777216) & iCombineMeasuredStates2);
        int iResolveSizeAndState2 = View.resolveSizeAndState(Math.max(paddingBottom, getSuggestedMinimumHeight()), i3, iCombineMeasuredStates2 << 16);
        if (!this.S) {
            z = false;
            break;
        }
        int childCount2 = getChildCount();
        for (int i7 = 0; i7 < childCount2; i7++) {
            View childAt2 = getChildAt(i7);
            if (v(childAt2) && childAt2.getMeasuredWidth() > 0 && childAt2.getMeasuredHeight() > 0) {
                z = false;
                break;
            }
        }
        setMeasuredDimension(iResolveSizeAndState, z ? 0 : iResolveSizeAndState2);
    }

    @Override // android.view.View
    public void onRestoreInstanceState(Parcelable parcelable) {
        MenuItem menuItemFindItem;
        if (!(parcelable instanceof SavedState)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        SavedState savedState = (SavedState) parcelable;
        super.onRestoreInstanceState(savedState.f278e);
        ActionMenuView actionMenuView = this.f202b;
        c.b.e.i.g gVar = actionMenuView != null ? actionMenuView.s : null;
        int i2 = savedState.f211f;
        if (i2 != 0 && this.P != null && gVar != null && (menuItemFindItem = gVar.findItem(i2)) != null) {
            menuItemFindItem.expandActionView();
        }
        if (savedState.f212g) {
            removeCallbacks(this.W);
            post(this.W);
        }
    }

    @Override // android.view.View
    public void onRtlPropertiesChanged(int i2) {
        super.onRtlPropertiesChanged(i2);
        e();
        v0 v0Var = this.w;
        boolean z = i2 == 1;
        if (z == v0Var.f970g) {
            return;
        }
        v0Var.f970g = z;
        if (!v0Var.f971h) {
            v0Var.a = v0Var.f968e;
            v0Var.f965b = v0Var.f969f;
            return;
        }
        if (z) {
            int i3 = v0Var.f967d;
            if (i3 == Integer.MIN_VALUE) {
                i3 = v0Var.f968e;
            }
            v0Var.a = i3;
            int i4 = v0Var.f966c;
            if (i4 == Integer.MIN_VALUE) {
                i4 = v0Var.f969f;
            }
            v0Var.f965b = i4;
            return;
        }
        int i5 = v0Var.f966c;
        if (i5 == Integer.MIN_VALUE) {
            i5 = v0Var.f968e;
        }
        v0Var.a = i5;
        int i6 = v0Var.f967d;
        if (i6 == Integer.MIN_VALUE) {
            i6 = v0Var.f969f;
        }
        v0Var.f965b = i6;
    }

    @Override // android.view.View
    public Parcelable onSaveInstanceState() {
        i iVar;
        SavedState savedState = new SavedState(super.onSaveInstanceState());
        f fVar = this.P;
        if (fVar != null && (iVar = fVar.f217e) != null) {
            savedState.f211f = iVar.a;
        }
        savedState.f212g = q();
        return savedState;
    }

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

    public final boolean p(View view) {
        return view.getParent() == this || this.H.contains(view);
    }

    public boolean q() {
        ActionMenuView actionMenuView = this.f202b;
        if (actionMenuView != null) {
            ActionMenuPresenter actionMenuPresenter = actionMenuView.w;
            if (actionMenuPresenter != null && actionMenuPresenter.m()) {
                return true;
            }
        }
        return false;
    }

    public final int r(View view, int i2, int[] iArr, int i3) {
        g gVar = (g) view.getLayoutParams();
        int i4 = ((ViewGroup.MarginLayoutParams) gVar).leftMargin - iArr[0];
        int iMax = Math.max(0, i4) + i2;
        iArr[0] = Math.max(0, -i4);
        int iL = l(view, i3);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax, iL, iMax + measuredWidth, view.getMeasuredHeight() + iL);
        return measuredWidth + ((ViewGroup.MarginLayoutParams) gVar).rightMargin + iMax;
    }

    public final int s(View view, int i2, int[] iArr, int i3) {
        g gVar = (g) view.getLayoutParams();
        int i4 = ((ViewGroup.MarginLayoutParams) gVar).rightMargin - iArr[1];
        int iMax = i2 - Math.max(0, i4);
        iArr[1] = Math.max(0, -i4);
        int iL = l(view, i3);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax - measuredWidth, iL, iMax, view.getMeasuredHeight() + iL);
        return iMax - (measuredWidth + ((ViewGroup.MarginLayoutParams) gVar).leftMargin);
    }

    public void setBackInvokedCallbackEnabled(boolean z) {
        if (this.V != z) {
            this.V = z;
            x();
        }
    }

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

    public void setCollapseIcon(int i2) {
        setCollapseIcon(c.b.a.e(getContext(), i2));
    }

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

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

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

    public void setLogo(int i2) {
        setLogo(c.b.a.e(getContext(), i2));
    }

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

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

    public void setNavigationIcon(int i2) {
        setNavigationIcon(c.b.a.e(getContext(), i2));
    }

    public void setNavigationOnClickListener(View.OnClickListener onClickListener) {
        h();
        this.f205g.setOnClickListener(onClickListener);
    }

    public void setOnMenuItemClickListener(h hVar) {
        this.L = hVar;
    }

    public void setOverflowIcon(Drawable drawable) {
        f();
        this.f202b.setOverflowIcon(drawable);
    }

    public void setPopupTheme(int i2) {
        if (this.n != i2) {
            this.n = i2;
            if (i2 == 0) {
                this.m = getContext();
            } else {
                this.m = new ContextThemeWrapper(getContext(), i2);
            }
        }
    }

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

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

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

    public void setTitleMarginBottom(int i2) {
        this.v = i2;
        requestLayout();
    }

    public void setTitleMarginEnd(int i2) {
        this.t = i2;
        requestLayout();
    }

    public void setTitleMarginStart(int i2) {
        this.s = i2;
        requestLayout();
    }

    public void setTitleMarginTop(int i2) {
        this.u = i2;
        requestLayout();
    }

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

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

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

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

    public boolean w() {
        ActionMenuView actionMenuView = this.f202b;
        if (actionMenuView != null) {
            ActionMenuPresenter actionMenuPresenter = actionMenuView.w;
            if (actionMenuPresenter != null && actionMenuPresenter.n()) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0028  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void x() {
        /*
            r4 = this;
            int r0 = android.os.Build.VERSION.SDK_INT
            r1 = 33
            if (r0 < r1) goto L54
            android.window.OnBackInvokedDispatcher r0 = androidx.appcompat.widget.Toolbar.e.a(r4)
            androidx.appcompat.widget.Toolbar$f r1 = r4.P
            r2 = 1
            r3 = 0
            if (r1 == 0) goto L16
            c.b.e.i.i r1 = r1.f217e
            if (r1 == 0) goto L16
            r1 = r2
            goto L17
        L16:
            r1 = r3
        L17:
            if (r1 == 0) goto L28
            if (r0 == 0) goto L28
            java.util.WeakHashMap<android.view.View, c.f.j.i0> r1 = c.f.j.a0.a
            boolean r1 = c.f.j.a0.f.b(r4)
            if (r1 == 0) goto L28
            boolean r1 = r4.V
            if (r1 == 0) goto L28
            goto L29
        L28:
            r2 = r3
        L29:
            if (r2 == 0) goto L46
            android.window.OnBackInvokedDispatcher r1 = r4.U
            if (r1 != 0) goto L46
            android.window.OnBackInvokedCallback r1 = r4.T
            if (r1 != 0) goto L3e
            c.b.f.c r1 = new c.b.f.c
            r1.<init>()
            android.window.OnBackInvokedCallback r1 = androidx.appcompat.widget.Toolbar.e.b(r1)
            r4.T = r1
        L3e:
            android.window.OnBackInvokedCallback r1 = r4.T
            androidx.appcompat.widget.Toolbar.e.c(r0, r1)
            r4.U = r0
            goto L54
        L46:
            if (r2 != 0) goto L54
            android.window.OnBackInvokedDispatcher r0 = r4.U
            if (r0 == 0) goto L54
            android.window.OnBackInvokedCallback r1 = r4.T
            androidx.appcompat.widget.Toolbar.e.d(r0, r1)
            r0 = 0
            r4.U = r0
        L54:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.Toolbar.x():void");
    }

    public static class g extends e.a {

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

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

        public g(int i2, int i3) {
            super(i2, i3);
            this.f219b = 0;
            this.a = 8388627;
        }

        public g(g gVar) {
            super((e.a) gVar);
            this.f219b = 0;
            this.f219b = gVar.f219b;
        }

        public g(e.a aVar) {
            super(aVar);
            this.f219b = 0;
        }

        public g(ViewGroup.MarginLayoutParams marginLayoutParams) {
            super(marginLayoutParams);
            this.f219b = 0;
            ((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 g(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
            this.f219b = 0;
        }
    }

    @Override // android.view.ViewGroup
    public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return new g(getContext(), attributeSet);
    }

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

    public void setCollapseIcon(Drawable drawable) {
        if (drawable != null) {
            d();
            this.f209k.setImageDrawable(drawable);
        } else {
            ImageButton imageButton = this.f209k;
            if (imageButton != null) {
                imageButton.setImageDrawable(this.f207i);
            }
        }
    }

    public void setLogo(Drawable drawable) {
        if (drawable != null) {
            if (this.f206h == null) {
                this.f206h = new s(getContext(), null, 0);
            }
            if (!p(this.f206h)) {
                b(this.f206h, true);
            }
        } else {
            ImageView imageView = this.f206h;
            if (imageView != null && p(imageView)) {
                removeView(this.f206h);
                this.H.remove(this.f206h);
            }
        }
        ImageView imageView2 = this.f206h;
        if (imageView2 != null) {
            imageView2.setImageDrawable(drawable);
        }
    }

    public void setLogoDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence) && this.f206h == null) {
            this.f206h = new s(getContext(), null, 0);
        }
        ImageView imageView = this.f206h;
        if (imageView != null) {
            imageView.setContentDescription(charSequence);
        }
    }

    public void setNavigationContentDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            h();
        }
        ImageButton imageButton = this.f205g;
        if (imageButton != null) {
            imageButton.setContentDescription(charSequence);
            g1.a(this.f205g, charSequence);
        }
    }

    public void setNavigationIcon(Drawable drawable) {
        if (drawable != null) {
            h();
            if (!p(this.f205g)) {
                b(this.f205g, true);
            }
        } else {
            ImageButton imageButton = this.f205g;
            if (imageButton != null && p(imageButton)) {
                removeView(this.f205g);
                this.H.remove(this.f205g);
            }
        }
        ImageButton imageButton2 = this.f205g;
        if (imageButton2 != null) {
            imageButton2.setImageDrawable(drawable);
        }
    }

    public void setSubtitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            TextView textView = this.f204f;
            if (textView != null && p(textView)) {
                removeView(this.f204f);
                this.H.remove(this.f204f);
            }
        } else {
            if (this.f204f == null) {
                Context context = getContext();
                f0 f0Var = new f0(context, null);
                this.f204f = f0Var;
                f0Var.setSingleLine();
                this.f204f.setEllipsize(TextUtils.TruncateAt.END);
                int i2 = this.p;
                if (i2 != 0) {
                    this.f204f.setTextAppearance(context, i2);
                }
                ColorStateList colorStateList = this.D;
                if (colorStateList != null) {
                    this.f204f.setTextColor(colorStateList);
                }
            }
            if (!p(this.f204f)) {
                b(this.f204f, true);
            }
        }
        TextView textView2 = this.f204f;
        if (textView2 != null) {
            textView2.setText(charSequence);
        }
        this.B = charSequence;
    }

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

    public void setTitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            TextView textView = this.f203e;
            if (textView != null && p(textView)) {
                removeView(this.f203e);
                this.H.remove(this.f203e);
            }
        } else {
            if (this.f203e == null) {
                Context context = getContext();
                f0 f0Var = new f0(context, null);
                this.f203e = f0Var;
                f0Var.setSingleLine();
                this.f203e.setEllipsize(TextUtils.TruncateAt.END);
                int i2 = this.o;
                if (i2 != 0) {
                    this.f203e.setTextAppearance(context, i2);
                }
                ColorStateList colorStateList = this.C;
                if (colorStateList != null) {
                    this.f203e.setTextColor(colorStateList);
                }
            }
            if (!p(this.f203e)) {
                b(this.f203e, true);
            }
        }
        TextView textView2 = this.f203e;
        if (textView2 != null) {
            textView2.setText(charSequence);
        }
        this.A = charSequence;
    }

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

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

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

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

        public class a implements Parcelable.ClassLoaderCreator<SavedState> {
            @Override // android.os.Parcelable.ClassLoaderCreator
            public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new SavedState(parcel, classLoader);
            }

            @Override // android.os.Parcelable.Creator
            public Object[] newArray(int i2) {
                return new SavedState[i2];
            }

            @Override // android.os.Parcelable.Creator
            public Object createFromParcel(Parcel parcel) {
                return new SavedState(parcel, null);
            }
        }

        public SavedState(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.f211f = parcel.readInt();
            this.f212g = parcel.readInt() != 0;
        }

        @Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i2) {
            parcel.writeParcelable(this.f278e, i2);
            parcel.writeInt(this.f211f);
            parcel.writeInt(this.f212g ? 1 : 0);
        }

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