package c.a.g;

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.ActionMenuView;
import com.ifpdos.multiuser.R;

/* JADX INFO: loaded from: classes.dex */
public abstract class a extends ViewGroup {

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: c.a.g.a$a, reason: collision with other inner class name */
    public class C0066a implements c.c.i.r {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public boolean f4918a = false;

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

        public C0066a() {
        }

        @Override // c.c.i.r
        public void a(View view) {
            this.f4918a = true;
        }

        @Override // c.c.i.r
        public void b(View view) {
            if (this.f4918a) {
                return;
            }
            a aVar = a.this;
            aVar.f4915g = null;
            a.super.setVisibility(this.f4919b);
        }

        @Override // c.c.i.r
        public void c(View view) {
            a.super.setVisibility(0);
            this.f4918a = false;
        }
    }

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

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

    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 int getAnimatedVisibility() {
        return this.f4915g != null ? this.f4910b.f4919b : getVisibility();
    }

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

    @Override // android.view.View
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(null, c.a.b.f4748a, R.attr.actionBarStyle, 0);
        setContentHeight(typedArrayObtainStyledAttributes.getLayoutDimension(13, 0));
        typedArrayObtainStyledAttributes.recycle();
        c cVar = this.f4913e;
        if (cVar != null) {
            Configuration configuration2 = cVar.f4821c.getResources().getConfiguration();
            int i2 = configuration2.screenWidthDp;
            int i3 = configuration2.screenHeightDp;
            cVar.q = (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.a.f.d.f fVar = cVar.f4822d;
            if (fVar != null) {
                fVar.p(true);
            }
        }
    }

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

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

    public abstract void setContentHeight(int i2);

    @Override // android.view.View
    public void setVisibility(int i2) {
        if (i2 != getVisibility()) {
            c.c.i.q qVar = this.f4915g;
            if (qVar != null) {
                qVar.a();
            }
            super.setVisibility(i2);
        }
    }
}
