package c.b.f;

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.widget.ActionMenuPresenter;
import androidx.appcompat.widget.ActionMenuView;
import com.ifpdos.debugmenu.R;

/* JADX INFO: compiled from: AbsActionBarView.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class d extends ViewGroup {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final a f782b;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Context f783e;

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

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

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public c.f.j.i0 f787i;

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

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

    /* JADX INFO: compiled from: AbsActionBarView.java */
    public class a implements c.f.j.j0 {
        public boolean a = false;

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

        public a() {
        }

        @Override // c.f.j.j0
        public void a(View view) {
            this.a = true;
        }

        @Override // c.f.j.j0
        public void b(View view) {
            if (this.a) {
                return;
            }
            d dVar = d.this;
            dVar.f787i = null;
            d.super.setVisibility(this.f790b);
        }

        @Override // c.f.j.j0
        public void c(View view) {
            d.super.setVisibility(0);
            this.a = false;
        }
    }

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

    public int c(View view, int i2, int i3, int i4) {
        view.measure(View.MeasureSpec.makeMeasureSpec(i2, Integer.MIN_VALUE), i3);
        return Math.max(0, (i2 - view.getMeasuredWidth()) - i4);
    }

    public int d(View view, int i2, int i3, int i4, boolean z) {
        int measuredWidth = view.getMeasuredWidth();
        int measuredHeight = view.getMeasuredHeight();
        int i5 = ((i4 - measuredHeight) / 2) + i3;
        if (z) {
            view.layout(i2 - measuredWidth, i5, i2, measuredHeight + i5);
        } else {
            view.layout(i2, i5, i2 + measuredWidth, measuredHeight + i5);
        }
        return z ? -measuredWidth : measuredWidth;
    }

    public c.f.j.i0 e(int i2, long j2) {
        c.f.j.i0 i0Var = this.f787i;
        if (i0Var != null) {
            i0Var.b();
        }
        if (i2 != 0) {
            c.f.j.i0 i0VarA = c.f.j.a0.a(this);
            i0VarA.a(0.0f);
            i0VarA.c(j2);
            a aVar = this.f782b;
            d.this.f787i = i0VarA;
            aVar.f790b = i2;
            View view = i0VarA.a.get();
            if (view != null) {
                i0VarA.e(view, aVar);
            }
            return i0VarA;
        }
        if (getVisibility() != 0) {
            setAlpha(0.0f);
        }
        c.f.j.i0 i0VarA2 = c.f.j.a0.a(this);
        i0VarA2.a(1.0f);
        i0VarA2.c(j2);
        a aVar2 = this.f782b;
        d.this.f787i = i0VarA2;
        aVar2.f790b = i2;
        View view2 = i0VarA2.a.get();
        if (view2 != null) {
            i0VarA2.e(view2, aVar2);
        }
        return i0VarA2;
    }

    public int getAnimatedVisibility() {
        return this.f787i != null ? this.f782b.f790b : getVisibility();
    }

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

    @Override // android.view.View
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, c.b.b.a, R.attr.actionBarStyle, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(13, 0));
        typedArrayObtainStyledAttributes.recycle();
        ActionMenuPresenter actionMenuPresenter = this.f785g;
        if (actionMenuPresenter != null) {
            Configuration configuration2 = actionMenuPresenter.f672e.getResources().getConfiguration();
            int i2 = configuration2.screenWidthDp;
            int i3 = configuration2.screenHeightDp;
            actionMenuPresenter.s = (configuration2.smallestScreenWidthDp > 600 || i2 > 600 || (i2 > 960 && i3 > 720) || (i2 > 720 && i3 > 960)) ? 5 : (i2 >= 500 || (i2 > 640 && i3 > 480) || (i2 > 480 && i3 > 640)) ? 4 : i2 >= 360 ? 3 : 2;
            c.b.e.i.g gVar = actionMenuPresenter.f673f;
            if (gVar != null) {
                gVar.q(true);
            }
        }
    }

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

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

    public abstract void setContentHeight(int i2);

    @Override // android.view.View
    public void setVisibility(int i2) {
        if (i2 != getVisibility()) {
            c.f.j.i0 i0Var = this.f787i;
            if (i0Var != null) {
                i0Var.b();
            }
            super.setVisibility(i2);
        }
    }

    public d(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        this.f782b = new a();
        TypedValue typedValue = new TypedValue();
        if (!context.getTheme().resolveAttribute(R.attr.actionBarPopupTheme, typedValue, true) || typedValue.resourceId == 0) {
            this.f783e = context;
        } else {
            this.f783e = new ContextThemeWrapper(context, typedValue.resourceId);
        }
    }
}
