package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import p037.p041.C1473;
import p037.p041.C1477;
import p037.p041.p051.C1600;
import p037.p041.p051.C1680;
import p037.p065.p078.C1920;

/* JADX INFO: loaded from: classes.dex */
public class ActionBarContainer extends FrameLayout {

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

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

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

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

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

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

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

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

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

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

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

    public ActionBarContainer(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        C1920.m3744(this, new C1600(this));
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C1477.ActionBar);
        this.f231 = typedArrayObtainStyledAttributes.getDrawable(C1477.ActionBar_background);
        this.f232 = typedArrayObtainStyledAttributes.getDrawable(C1477.ActionBar_backgroundStacked);
        this.f236 = typedArrayObtainStyledAttributes.getDimensionPixelSize(C1477.ActionBar_height, -1);
        boolean z = true;
        if (getId() == C1473.split_action_bar) {
            this.f234 = true;
            this.f233 = typedArrayObtainStyledAttributes.getDrawable(C1477.ActionBar_backgroundSplit);
        }
        typedArrayObtainStyledAttributes.recycle();
        if (!this.f234 ? this.f231 != null || this.f232 != null : this.f233 != null) {
            z = false;
        }
        setWillNotDraw(z);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void drawableStateChanged() {
        super.drawableStateChanged();
        Drawable drawable = this.f231;
        if (drawable != null && drawable.isStateful()) {
            this.f231.setState(getDrawableState());
        }
        Drawable drawable2 = this.f232;
        if (drawable2 != null && drawable2.isStateful()) {
            this.f232.setState(getDrawableState());
        }
        Drawable drawable3 = this.f233;
        if (drawable3 == null || !drawable3.isStateful()) {
            return;
        }
        this.f233.setState(getDrawableState());
    }

    public View getTabContainer() {
        return this.f228;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void jumpDrawablesToCurrentState() {
        super.jumpDrawablesToCurrentState();
        Drawable drawable = this.f231;
        if (drawable != null) {
            drawable.jumpToCurrentState();
        }
        Drawable drawable2 = this.f232;
        if (drawable2 != null) {
            drawable2.jumpToCurrentState();
        }
        Drawable drawable3 = this.f233;
        if (drawable3 != null) {
            drawable3.jumpToCurrentState();
        }
    }

    @Override // android.view.View
    public void onFinishInflate() {
        super.onFinishInflate();
        this.f229 = findViewById(C1473.action_bar);
        this.f230 = findViewById(C1473.action_context_bar);
    }

    @Override // android.view.View
    public boolean onHoverEvent(MotionEvent motionEvent) {
        super.onHoverEvent(motionEvent);
        return true;
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return this.f227 || super.onInterceptTouchEvent(motionEvent);
    }

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public void onLayout(boolean z, int i, int i2, int i3, int i4) {
        Drawable drawable;
        super.onLayout(z, i, i2, i3, i4);
        View view = this.f228;
        boolean z2 = true;
        boolean z3 = false;
        boolean z4 = (view == null || view.getVisibility() == 8) ? false : true;
        if (view != null && view.getVisibility() != 8) {
            int measuredHeight = getMeasuredHeight();
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
            int measuredHeight2 = measuredHeight - view.getMeasuredHeight();
            int i5 = layoutParams.bottomMargin;
            view.layout(i, measuredHeight2 - i5, i3, measuredHeight - i5);
        }
        if (this.f234) {
            Drawable drawable2 = this.f233;
            if (drawable2 != null) {
                drawable2.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            } else {
                z2 = false;
            }
        } else {
            if (this.f231 != null) {
                if (this.f229.getVisibility() == 0) {
                    this.f231.setBounds(this.f229.getLeft(), this.f229.getTop(), this.f229.getRight(), this.f229.getBottom());
                } else {
                    View view2 = this.f230;
                    if (view2 == null || view2.getVisibility() != 0) {
                        this.f231.setBounds(0, 0, 0, 0);
                    } else {
                        this.f231.setBounds(this.f230.getLeft(), this.f230.getTop(), this.f230.getRight(), this.f230.getBottom());
                    }
                }
                z3 = true;
            }
            this.f235 = z4;
            if (!z4 || (drawable = this.f232) == null) {
                z2 = z3;
            } else {
                drawable.setBounds(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
            }
        }
        if (z2) {
            invalidate();
        }
    }

    @Override // android.widget.FrameLayout, android.view.View
    public void onMeasure(int i, int i2) {
        int i3;
        if (this.f229 == null && View.MeasureSpec.getMode(i2) == Integer.MIN_VALUE && (i3 = this.f236) >= 0) {
            i2 = View.MeasureSpec.makeMeasureSpec(Math.min(i3, View.MeasureSpec.getSize(i2)), Integer.MIN_VALUE);
        }
        super.onMeasure(i, i2);
        if (this.f229 == null) {
            return;
        }
        int mode = View.MeasureSpec.getMode(i2);
        View view = this.f228;
        if (view == null || view.getVisibility() == 8 || mode == 1073741824) {
            return;
        }
        setMeasuredDimension(getMeasuredWidth(), Math.min(m116(this.f228) + (!m117(this.f229) ? m116(this.f229) : !m117(this.f230) ? m116(this.f230) : 0), mode == Integer.MIN_VALUE ? View.MeasureSpec.getSize(i2) : Integer.MAX_VALUE));
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        super.onTouchEvent(motionEvent);
        return true;
    }

    public void setPrimaryBackground(Drawable drawable) {
        Drawable drawable2 = this.f231;
        if (drawable2 != null) {
            drawable2.setCallback(null);
            unscheduleDrawable(this.f231);
        }
        this.f231 = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            View view = this.f229;
            if (view != null) {
                this.f231.setBounds(view.getLeft(), this.f229.getTop(), this.f229.getRight(), this.f229.getBottom());
            }
        }
        boolean z = true;
        if (!this.f234 ? this.f231 != null || this.f232 != null : this.f233 != null) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
        invalidateOutline();
    }

    public void setSplitBackground(Drawable drawable) {
        Drawable drawable2;
        Drawable drawable3 = this.f233;
        if (drawable3 != null) {
            drawable3.setCallback(null);
            unscheduleDrawable(this.f233);
        }
        this.f233 = drawable;
        boolean z = false;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.f234 && (drawable2 = this.f233) != null) {
                drawable2.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
            }
        }
        if (!this.f234 ? !(this.f231 != null || this.f232 != null) : this.f233 == null) {
            z = true;
        }
        setWillNotDraw(z);
        invalidate();
        invalidateOutline();
    }

    public void setStackedBackground(Drawable drawable) {
        Drawable drawable2;
        Drawable drawable3 = this.f232;
        if (drawable3 != null) {
            drawable3.setCallback(null);
            unscheduleDrawable(this.f232);
        }
        this.f232 = drawable;
        if (drawable != null) {
            drawable.setCallback(this);
            if (this.f235 && (drawable2 = this.f232) != null) {
                drawable2.setBounds(this.f228.getLeft(), this.f228.getTop(), this.f228.getRight(), this.f228.getBottom());
            }
        }
        boolean z = true;
        if (!this.f234 ? this.f231 != null || this.f232 != null : this.f233 != null) {
            z = false;
        }
        setWillNotDraw(z);
        invalidate();
        invalidateOutline();
    }

    public void setTabContainer(C1680 c1680) {
        View view = this.f228;
        if (view != null) {
            removeView(view);
        }
        this.f228 = c1680;
        if (c1680 != null) {
            addView(c1680);
            ViewGroup.LayoutParams layoutParams = c1680.getLayoutParams();
            layoutParams.width = -1;
            layoutParams.height = -2;
            c1680.setAllowCollapse(false);
        }
    }

    public void setTransitioning(boolean z) {
        this.f227 = z;
        setDescendantFocusability(z ? 393216 : 262144);
    }

    @Override // android.view.View
    public void setVisibility(int i) {
        super.setVisibility(i);
        boolean z = i == 0;
        Drawable drawable = this.f231;
        if (drawable != null) {
            drawable.setVisible(z, false);
        }
        Drawable drawable2 = this.f232;
        if (drawable2 != null) {
            drawable2.setVisible(z, false);
        }
        Drawable drawable3 = this.f233;
        if (drawable3 != null) {
            drawable3.setVisible(z, false);
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public ActionMode startActionModeForChild(View view, ActionMode.Callback callback) {
        return null;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public ActionMode startActionModeForChild(View view, ActionMode.Callback callback, int i) {
        if (i != 0) {
            return super.startActionModeForChild(view, callback, i);
        }
        return null;
    }

    @Override // android.view.View
    public boolean verifyDrawable(Drawable drawable) {
        return (drawable == this.f231 && !this.f234) || (drawable == this.f232 && this.f235) || ((drawable == this.f233 && this.f234) || super.verifyDrawable(drawable));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int m116(View view) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
        return view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m117(View view) {
        return view == null || view.getVisibility() == 8 || view.getMeasuredHeight() == 0;
    }
}
