package ῲ.ῲ.㴹;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.R$attr;
import androidx.appcompat.R$styleable;
import androidx.appcompat.widget.ActionMenuPresenter;
import androidx.appcompat.widget.ActionMenuView;
import ῲ.ᨨ.ᨨ.AbstractC1738;
import ῲ.ᨨ.ᨨ.C1729;
import ῲ.ᨨ.ᨨ.C1768;
import ῲ.ῲ.ඓ.㳳.C1912;

/* renamed from: ῲ.ῲ.㴹.K  reason: contains not printable characters */
/* compiled from: AbsActionBarView */
public abstract class AbstractC2027 extends ViewGroup {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Context f6863;

    /* renamed from: ඓ  reason: contains not printable characters */
    public ActionMenuPresenter f6864;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public boolean f6865;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C2028 f6866;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public C1768 f6867;

    /* renamed from: 㴹  reason: contains not printable characters */
    public int f6868;

    /* renamed from: 㸾  reason: contains not printable characters */
    public ActionMenuView f6869;

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean f6870;

    /* renamed from: ῲ.ῲ.㴹.K$K  reason: contains not printable characters */
    /* compiled from: AbsActionBarView */
    public class C2028 implements AbstractC1738 {

        /* renamed from: ῲ  reason: contains not printable characters */
        public int f6872;

        /* renamed from: K  reason: contains not printable characters */
        public boolean f6873 = false;

        public C2028() {
        }

        @Override // ῲ.ᨨ.ᨨ.AbstractC1738
        /* renamed from: ʬ  reason: contains not printable characters */
        public void m5258(View view) {
            this.f6873 = true;
        }

        @Override // ῲ.ᨨ.ᨨ.AbstractC1738
        /* renamed from: ῲ  reason: contains not printable characters */
        public void m5259(View view) {
            AbstractC2027.super.setVisibility(0);
            this.f6873 = false;
        }

        @Override // ῲ.ᨨ.ᨨ.AbstractC1738
        /* renamed from: K  reason: contains not printable characters */
        public void m5260(View view) {
            if (!this.f6873) {
                AbstractC2027 k = AbstractC2027.this;
                k.f6867 = null;
                AbstractC2027.super.setVisibility(this.f6872);
            }
        }
    }

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

    public int getAnimatedVisibility() {
        if (this.f6867 != null) {
            return this.f6866.f6872;
        }
        return getVisibility();
    }

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

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(null, R$styleable.ActionBar, R$attr.actionBarStyle, 0);
        setContentHeight(obtainStyledAttributes.getLayoutDimension(R$styleable.ActionBar_height, 0));
        obtainStyledAttributes.recycle();
        ActionMenuPresenter actionMenuPresenter = this.f6864;
        if (actionMenuPresenter != null) {
            if (!actionMenuPresenter.f419) {
                Configuration configuration2 = actionMenuPresenter.f6462.getResources().getConfiguration();
                int i = configuration2.screenWidthDp;
                int i2 = configuration2.screenHeightDp;
                actionMenuPresenter.f429 = (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;
            }
            C1912 r5 = actionMenuPresenter.f6469;
            if (r5 != null) {
                r5.onItemsChanged(true);
            }
        }
    }

    public boolean onHoverEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 9) {
            this.f6865 = false;
        }
        if (!this.f6865) {
            boolean onHoverEvent = super.onHoverEvent(motionEvent);
            if (actionMasked == 9 && !onHoverEvent) {
                this.f6865 = true;
            }
        }
        if (actionMasked == 10 || actionMasked == 3) {
            this.f6865 = false;
        }
        return true;
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f6870 = false;
        }
        if (!this.f6870) {
            boolean onTouchEvent = super.onTouchEvent(motionEvent);
            if (actionMasked == 0 && !onTouchEvent) {
                this.f6870 = true;
            }
        }
        if (actionMasked == 1 || actionMasked == 3) {
            this.f6870 = false;
        }
        return true;
    }

    public abstract void setContentHeight(int i);

    public void setVisibility(int i) {
        if (i != getVisibility()) {
            C1768 r0 = this.f6867;
            if (r0 != null) {
                r0.m4621();
            }
            super.setVisibility(i);
        }
    }

    public AbstractC2027(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    /* renamed from: K  reason: contains not printable characters */
    public C1768 m5257(int i, long j) {
        C1768 r0 = this.f6867;
        if (r0 != null) {
            r0.m4621();
        }
        if (i == 0) {
            if (getVisibility() != 0) {
                setAlpha(0.0f);
            }
            C1768 r02 = C1729.m4470(this);
            r02.m4617(1.0f);
            r02.m4618(j);
            C2028 k = this.f6866;
            AbstractC2027.this.f6867 = r02;
            k.f6872 = i;
            r02.m4619(k);
            return r02;
        }
        C1768 r1 = C1729.m4470(this);
        r1.m4617(0.0f);
        r1.m4618(j);
        C2028 k2 = this.f6866;
        AbstractC2027.this.f6867 = r1;
        k2.f6872 = i;
        r1.m4619(k2);
        return r1;
    }

    public AbstractC2027(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        int i2;
        this.f6866 = new C2028();
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(R$attr.actionBarPopupTheme, typedValue, true) || (i2 = typedValue.resourceId) == 0) {
            this.f6863 = context;
        } else {
            this.f6863 = new ContextThemeWrapper(context, i2);
        }
    }

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

    /* renamed from: K  reason: contains not printable characters */
    public int m5256(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;
    }
}
