package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import ar.tvplayer.tv.R;
import defpackage.AbstractC0542;
import defpackage.AbstractC2335;
import defpackage.AbstractC2873;
import defpackage.AbstractC3261;
import defpackage.C1014;
import defpackage.C1065;
import defpackage.C5153;
import defpackage.InterfaceC0913;
import defpackage.InterfaceC1230;
import defpackage.MenuC2418;
import defpackage.ViewOnClickListenerC4018;

/* loaded from: classes3.dex */
public class ActionBarContextView extends ViewGroup {

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public boolean f79;

    /* renamed from: ˀᵗᵩ, reason: contains not printable characters */
    public int f80;

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public TextView f81;

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public int f82;

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public int f83;

    /* renamed from: ˌᵪ, reason: contains not printable characters */
    public int f84;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public CharSequence f85;

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public final int f86;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public CharSequence f87;

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public LinearLayout f88;

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public final int f89;

    /* renamed from: ᵛˈᵤ, reason: contains not printable characters */
    public int f90;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public boolean f91;

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public boolean f92;

    /* renamed from: ᵡᵶᵡ, reason: contains not printable characters */
    public int f93;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public C1014 f94;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final Context f95;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public int f96;

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public View f97;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final ᵳᵹᵺˋ f98;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public View f99;

    /* renamed from: ᵳᵹᵺˋ, reason: contains not printable characters */
    public int f100;

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public TextView f101;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public View f102;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public C1065 f103;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public ActionMenuView f104;

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public final int f105;

    public ActionBarContextView(Context context) {
        this(context, null);
    }

    public ActionBarContextView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, R.attr._11_res_0x7f04001e);
    }

    public ActionBarContextView(Context context, AttributeSet attributeSet, int i) {
        int resourceId;
        super(context, attributeSet, i);
        ᵳᵹᵺˋ r0 = new ᵳᵹᵺˋ();
        r0.ᵿʗᵝʽ = this;
        r0.ᵧᵾˀˈ = false;
        this.f98 = r0;
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(R.attr._11_res_0x7f040004, typedValue, true) || typedValue.resourceId == 0) {
            this.f95 = context;
        } else {
            this.f95 = new ContextThemeWrapper(context, typedValue.resourceId);
        }
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AbstractC0542.f2827, i, 0);
        setBackground((!typedArrayObtainStyledAttributes.hasValue(0) || (resourceId = typedArrayObtainStyledAttributes.getResourceId(0, 0)) == 0) ? typedArrayObtainStyledAttributes.getDrawable(0) : ᵕˏᵛ.ˑᵥˁ(context, resourceId));
        this.f105 = typedArrayObtainStyledAttributes.getResourceId(5, 0);
        this.f89 = typedArrayObtainStyledAttributes.getResourceId(4, 0);
        this.f96 = typedArrayObtainStyledAttributes.getLayoutDimension(3, 0);
        this.f86 = typedArrayObtainStyledAttributes.getResourceId(2, R.layout._11_res_0x7f0e0005);
        typedArrayObtainStyledAttributes.recycle();
        this.f90 = getPaddingLeft();
        this.f84 = getPaddingTop();
        this.f100 = getPaddingRight();
        this.f93 = getPaddingBottom();
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public static int m8(View view, int i, int i2) {
        view.measure(View.MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE), i2);
        return Math.max(0, i - view.getMeasuredWidth());
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public static int m11(View view, int i, int i2, int i3, boolean z) {
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        int i4 = ((i3 - measuredHeight) / 2) + i2;
        if (z) {
            view.layout(i - measuredWidth, i4, i, measuredHeight + i4);
        } else {
            view.layout(i, i4, i + measuredWidth, measuredHeight + i4);
        }
        return z ? -measuredWidth : measuredWidth;
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return new ViewGroup.MarginLayoutParams(-1, -2);
    }

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

    public int getAnimatedVisibility() {
        return this.f94 != null ? this.f98.ᵢˇᵭ : getVisibility();
    }

    public int getContentHeight() {
        return this.f96;
    }

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

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

    @Override // android.view.View
    public final void onConfigurationChanged(Configuration configuration) {
        m13(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, AbstractC0542.f2827, R.attr._11_res_0x7f04001e, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(3, 0));
        typedArrayObtainStyledAttributes.recycle();
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        C1065 c1065 = this.f103;
        if (c1065 != null) {
            c1065.m3446();
            C5153 c5153 = this.f103.f4614;
            if (c5153 == null || !c5153.m8477()) {
                return;
            }
            c5153.f14259.dismiss();
        }
    }

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

    @Override // android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z, int i, int i2, int i3, int i4) {
        boolean z2 = AbstractC2335.f9156;
        boolean z3 = getLayoutDirection() == 1;
        int paddingRight = z3 ? (i3 - i) - getPaddingRight() : getPaddingLeft();
        int paddingTop = getPaddingTop();
        int paddingTop2 = ((i4 - i2) - getPaddingTop()) - getPaddingBottom();
        View view = this.f99;
        if (view != null && view.getVisibility() != 8) {
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.f99.getLayoutParams();
            int i5 = z3 ? marginLayoutParams.rightMargin : marginLayoutParams.leftMargin;
            int i6 = z3 ? marginLayoutParams.leftMargin : marginLayoutParams.rightMargin;
            int i7 = z3 ? paddingRight - i5 : paddingRight + i5;
            int iM11 = m11(this.f99, i7, paddingTop, paddingTop2, z3) + i7;
            paddingRight = z3 ? iM11 - i6 : iM11 + i6;
        }
        LinearLayout linearLayout = this.f88;
        if (linearLayout != null && this.f102 == null && linearLayout.getVisibility() != 8) {
            paddingRight += m11(this.f88, paddingRight, paddingTop, paddingTop2, z3);
        }
        View view2 = this.f102;
        if (view2 != null) {
            m11(view2, paddingRight, paddingTop, paddingTop2, z3);
        }
        int paddingLeft = z3 ? getPaddingLeft() : (i3 - i) - getPaddingRight();
        ActionMenuView actionMenuView = this.f104;
        if (actionMenuView != null) {
            m11(actionMenuView, paddingLeft, paddingTop, paddingTop2, !z3);
        }
    }

    @Override // android.view.View
    public final void onMeasure(int i, int i2) {
        if (View.MeasureSpec.getMode(i) != 1073741824) {
            ᵹˉᵞ.ᵳٴᵶ(getClass().getSimpleName().concat(" can only be used with android:layout_width=\"match_parent\" (or fill_parent)"));
            return;
        }
        if (View.MeasureSpec.getMode(i2) == 0) {
            ᵹˉᵞ.ᵳٴᵶ(getClass().getSimpleName().concat(" can only be used with android:layout_height=\"wrap_content\""));
            return;
        }
        int size = View.MeasureSpec.getSize(i);
        int paddingLeft = (size - getPaddingLeft()) - getPaddingRight();
        int paddingBottom = getPaddingBottom() + getPaddingTop();
        int i3 = this.f96;
        int size2 = i3 > 0 ? i3 + this.f80 : View.MeasureSpec.getSize(i2);
        int iMin = size2 - paddingBottom;
        int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(iMin, Integer.MIN_VALUE);
        View view = this.f99;
        if (view != null) {
            int iM8 = m8(view, paddingLeft, iMakeMeasureSpec);
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.f99.getLayoutParams();
            paddingLeft = iM8 - (marginLayoutParams.leftMargin + marginLayoutParams.rightMargin);
        }
        ActionMenuView actionMenuView = this.f104;
        if (actionMenuView != null && actionMenuView.getParent() == this) {
            paddingLeft = m8(this.f104, paddingLeft, iMakeMeasureSpec);
        }
        LinearLayout linearLayout = this.f88;
        if (linearLayout != null && this.f102 == null) {
            if (this.f92) {
                this.f88.measure(View.MeasureSpec.makeMeasureSpec(0, 0), iMakeMeasureSpec);
                int measuredWidth = this.f88.getMeasuredWidth();
                boolean z = measuredWidth <= paddingLeft;
                if (z) {
                    paddingLeft -= measuredWidth;
                }
                this.f88.setVisibility(z ? 0 : 8);
            } else {
                paddingLeft = m8(linearLayout, paddingLeft, iMakeMeasureSpec);
            }
        }
        View view2 = this.f102;
        if (view2 != null) {
            ViewGroup.LayoutParams layoutParams = view2.getLayoutParams();
            int i4 = layoutParams.width;
            int i5 = i4 != -2 ? 1073741824 : Integer.MIN_VALUE;
            if (i4 >= 0) {
                paddingLeft = Math.min(i4, paddingLeft);
            }
            int i6 = layoutParams.height;
            int i7 = i6 == -2 ? Integer.MIN_VALUE : 1073741824;
            if (i6 >= 0) {
                iMin = Math.min(i6, iMin);
            }
            this.f102.measure(View.MeasureSpec.makeMeasureSpec(paddingLeft, i5), View.MeasureSpec.makeMeasureSpec(iMin, i7));
        }
        if (this.f96 > 0) {
            setMeasuredDimension(size, size2);
            return;
        }
        int childCount = getChildCount();
        int i8 = 0;
        for (int i9 = 0; i9 < childCount; i9++) {
            int measuredHeight = getChildAt(i9).getMeasuredHeight() + paddingBottom;
            if (measuredHeight > i8) {
                i8 = measuredHeight;
            }
        }
        setMeasuredDimension(size, i8);
    }

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

    public void setContentHeight(int i) {
        this.f96 = i;
    }

    public void setCustomView(View view) {
        LinearLayout linearLayout;
        View view2 = this.f102;
        if (view2 != null) {
            removeView(view2);
        }
        this.f102 = view;
        if (view != null && (linearLayout = this.f88) != null) {
            removeView(linearLayout);
            this.f88 = null;
        }
        if (view != null) {
            addView(view);
        }
        requestLayout();
    }

    @Override // android.view.View
    public final void setPadding(int i, int i2, int i3, int i4) {
        this.f90 = i;
        this.f84 = i2;
        this.f100 = i3;
        this.f93 = i4;
        m17();
    }

    @Override // android.view.View
    public final void setPaddingRelative(int i, int i2, int i3, int i4) {
        if (getLayoutDirection() != 1) {
            this.f90 = i;
            this.f100 = i3;
        } else {
            this.f90 = i3;
            this.f100 = i;
        }
        this.f84 = i2;
        this.f93 = i4;
        m17();
    }

    public void setSubtitle(CharSequence charSequence) {
        this.f85 = charSequence;
        m18();
    }

    public void setTitle(CharSequence charSequence) {
        this.f87 = charSequence;
        m18();
        AbstractC2873.m7018(this, charSequence);
    }

    public void setTitleOptional(boolean z) {
        if (z != this.f92) {
            requestLayout();
        }
        this.f92 = z;
    }

    @Override // android.view.ViewGroup
    public final boolean shouldDelayChildPressedState() {
        return false;
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m12() {
        removeAllViews();
        this.f102 = null;
        this.f104 = null;
        this.f103 = null;
        View view = this.f97;
        if (view != null) {
            view.setOnClickListener(null);
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final void m13(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, AbstractC0542.f2816, R.attr._11_res_0x7f040007, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(13, 0));
        typedArrayObtainStyledAttributes.recycle();
        C1065 c1065 = this.f103;
        if (c1065 != null) {
            Configuration configuration2 = c1065.f4621.getResources().getConfiguration();
            int i = configuration2.screenWidthDp;
            int i2 = configuration2.screenHeightDp;
            c1065.f4610 = (configuration2.smallestScreenWidthDp > 600 || i > 600 || (i > 960 && i2 > 720) || (i > 720 && i2 > 960)) ? 5 : (i >= 500 || (i > 640 && i2 > 480) || (i > 480 && i2 > 640)) ? 4 : i >= 360 ? 3 : 2;
            MenuC2418 menuC2418 = c1065.f4629;
            if (menuC2418 != null) {
                menuC2418.m6182(true);
            }
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m14(AbstractC3261 abstractC3261) {
        View view = this.f99;
        int i = 0;
        if (view == null) {
            View viewInflate = LayoutInflater.from(getContext()).inflate(this.f86, (ViewGroup) this, false);
            this.f99 = viewInflate;
            addView(viewInflate);
        } else if (view.getParent() == null) {
            addView(this.f99);
        }
        View viewFindViewById = this.f99.findViewById(R.id._11_res_0x7f0b004d);
        this.f97 = viewFindViewById;
        viewFindViewById.setOnClickListener(new ViewOnClickListenerC4018(i, abstractC3261));
        MenuC2418 menuC2418Mo3241 = abstractC3261.mo3241();
        C1065 c1065 = this.f103;
        if (c1065 != null) {
            c1065.m3446();
            C5153 c5153 = c1065.f4614;
            if (c5153 != null && c5153.m8477()) {
                c5153.f14259.dismiss();
            }
        }
        C1065 c10652 = new C1065(getContext());
        this.f103 = c10652;
        c10652.f4623 = true;
        c10652.f4627 = true;
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-2, -1);
        menuC2418Mo3241.m6194(this.f103, this.f95);
        C1065 c10653 = this.f103;
        InterfaceC1230 interfaceC1230 = c10653.f4618;
        if (interfaceC1230 == null) {
            InterfaceC1230 interfaceC12302 = (InterfaceC1230) c10653.f4628.inflate(c10653.f4620, (ViewGroup) this, false);
            c10653.f4618 = interfaceC12302;
            interfaceC12302.mo7(c10653.f4629);
            c10653.mo3448();
        }
        InterfaceC1230 interfaceC12303 = c10653.f4618;
        if (interfaceC1230 != interfaceC12303) {
            ((ActionMenuView) interfaceC12303).setPresenter(c10653);
        }
        ActionMenuView actionMenuView = (ActionMenuView) interfaceC12303;
        this.f104 = actionMenuView;
        actionMenuView.setBackground(null);
        addView(this.f104, layoutParams);
    }

    @Override // android.view.View
    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters and merged with bridge method [inline-methods] */
    public final void setVisibility(int i) {
        if (i != getVisibility()) {
            C1014 c1014 = this.f94;
            if (c1014 != null) {
                c1014.m3381();
            }
            super.setVisibility(i);
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final C1014 m16(long j, int i) {
        C1014 c1014 = this.f94;
        if (c1014 != null) {
            c1014.m3381();
        }
        InterfaceC0913 interfaceC0913 = this.f98;
        if (i != 0) {
            C1014 c1014M7024 = AbstractC2873.m7024(this);
            c1014M7024.m3380(0.0f);
            c1014M7024.m3379(j);
            ((ActionBarContextView) ((ᵳᵹᵺˋ) interfaceC0913).ᵿʗᵝʽ).f94 = c1014M7024;
            ((ᵳᵹᵺˋ) interfaceC0913).ᵢˇᵭ = i;
            c1014M7024.m3382(interfaceC0913);
            return c1014M7024;
        }
        if (getVisibility() != 0) {
            setAlpha(0.0f);
        }
        C1014 c1014M70242 = AbstractC2873.m7024(this);
        c1014M70242.m3380(1.0f);
        c1014M70242.m3379(j);
        ((ActionBarContextView) ((ᵳᵹᵺˋ) interfaceC0913).ᵿʗᵝʽ).f94 = c1014M70242;
        ((ᵳᵹᵺˋ) interfaceC0913).ᵢˇᵭ = i;
        c1014M70242.m3382(interfaceC0913);
        return c1014M70242;
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m17() {
        super.setPadding(this.f83 + this.f90, this.f80 + this.f84, this.f82 + this.f100, this.f93);
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m18() {
        if (this.f88 == null) {
            LayoutInflater.from(getContext()).inflate(R.layout._11_res_0x7f0e0000, this);
            LinearLayout linearLayout = (LinearLayout) getChildAt(getChildCount() - 1);
            this.f88 = linearLayout;
            this.f101 = (TextView) linearLayout.findViewById(R.id._11_res_0x7f0b0041);
            this.f81 = (TextView) this.f88.findViewById(R.id._11_res_0x7f0b0040);
            int i = this.f105;
            if (i != 0) {
                this.f101.setTextAppearance(getContext(), i);
            }
            int i2 = this.f89;
            if (i2 != 0) {
                this.f81.setTextAppearance(getContext(), i2);
            }
        }
        this.f101.setText(this.f87);
        this.f81.setText(this.f85);
        boolean zIsEmpty = TextUtils.isEmpty(this.f87);
        boolean zIsEmpty2 = TextUtils.isEmpty(this.f85);
        this.f81.setVisibility(!zIsEmpty2 ? 0 : 8);
        this.f88.setVisibility((zIsEmpty && zIsEmpty2) ? 8 : 0);
        if (this.f88.getParent() == null) {
            addView(this.f88);
        }
    }
}
