package androidx.appcompat.widget;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.Window;
import android.view.WindowInsets;
import android.widget.OverScroller;
import com.ifpdos.udi.service.core.pc.R;
import d.b.c.s;
import d.b.f.g;
import d.b.f.i.m;
import d.b.g.e0;
import d.b.g.f0;
import d.h.j.h0;
import d.h.j.n;
import d.h.j.o;
import d.h.j.p;
import d.h.j.y;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"UnknownNullness"})
public class ActionBarOverlayLayout extends ViewGroup implements e0, n, o {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final int[] f478f = {R.attr.actionBarSize, android.R.attr.windowContentOverlay};
    public final Rect A;
    public final Rect B;
    public final Rect C;
    public final Rect D;
    public final Rect E;
    public final Rect F;
    public h0 G;
    public h0 H;
    public h0 I;
    public h0 J;
    public d K;
    public OverScroller L;
    public ViewPropertyAnimator M;
    public final AnimatorListenerAdapter N;
    public final Runnable O;
    public final Runnable P;
    public final p Q;

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

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ContentFrameLayout f481o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public ActionBarContainer f482p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public f0 f483q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public Drawable f484r;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final Rect f492z;

    public class a extends AnimatorListenerAdapter {
        public a() {
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationCancel(Animator animator) {
            ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
            actionBarOverlayLayout.M = null;
            actionBarOverlayLayout.f489w = false;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
            actionBarOverlayLayout.M = null;
            actionBarOverlayLayout.f489w = false;
        }
    }

    public class b implements Runnable {
        public b() {
        }

        @Override // java.lang.Runnable
        public void run() {
            ActionBarOverlayLayout.this.q();
            ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
            actionBarOverlayLayout.M = actionBarOverlayLayout.f482p.animate().translationY(0.0f).setListener(ActionBarOverlayLayout.this.N);
        }
    }

    public class c implements Runnable {
        public c() {
        }

        @Override // java.lang.Runnable
        public void run() {
            ActionBarOverlayLayout.this.q();
            ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
            actionBarOverlayLayout.M = actionBarOverlayLayout.f482p.animate().translationY(-ActionBarOverlayLayout.this.f482p.getHeight()).setListener(ActionBarOverlayLayout.this.N);
        }
    }

    public interface d {
    }

    public static class e extends ViewGroup.MarginLayoutParams {
        public e(int i2, int i3) {
            super(i2, i3);
        }

        public e(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public e(ViewGroup.LayoutParams layoutParams) {
            super(layoutParams);
        }
    }

    public ActionBarOverlayLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f480n = 0;
        this.f492z = new Rect();
        this.A = new Rect();
        this.B = new Rect();
        this.C = new Rect();
        this.D = new Rect();
        this.E = new Rect();
        this.F = new Rect();
        h0 h0Var = h0.a;
        this.G = h0Var;
        this.H = h0Var;
        this.I = h0Var;
        this.J = h0Var;
        this.N = new a();
        this.O = new b();
        this.P = new c();
        r(context);
        this.Q = new p();
    }

    @Override // d.b.g.e0
    public void a(Menu menu, m.a aVar) {
        s();
        this.f483q.a(menu, aVar);
    }

    @Override // d.b.g.e0
    public boolean b() {
        s();
        return this.f483q.b();
    }

    @Override // d.b.g.e0
    public void c() {
        s();
        this.f483q.c();
    }

    @Override // android.view.ViewGroup
    public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof e;
    }

    @Override // d.b.g.e0
    public boolean d() {
        s();
        return this.f483q.d();
    }

    @Override // android.view.View
    public void draw(Canvas canvas) {
        int translationY;
        super.draw(canvas);
        if (this.f484r == null || this.f485s) {
            return;
        }
        if (this.f482p.getVisibility() == 0) {
            translationY = (int) (this.f482p.getTranslationY() + this.f482p.getBottom() + 0.5f);
        } else {
            translationY = 0;
        }
        this.f484r.setBounds(0, translationY, getWidth(), this.f484r.getIntrinsicHeight() + translationY);
        this.f484r.draw(canvas);
    }

    @Override // d.b.g.e0
    public boolean e() {
        s();
        return this.f483q.e();
    }

    @Override // d.b.g.e0
    public boolean f() {
        s();
        return this.f483q.f();
    }

    @Override // android.view.View
    public boolean fitSystemWindows(Rect rect) {
        return super.fitSystemWindows(rect);
    }

    @Override // d.b.g.e0
    public boolean g() {
        s();
        return this.f483q.g();
    }

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

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

    @Override // android.view.ViewGroup
    public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return new e(layoutParams);
    }

    public int getActionBarHideOffset() {
        ActionBarContainer actionBarContainer = this.f482p;
        if (actionBarContainer != null) {
            return -((int) actionBarContainer.getTranslationY());
        }
        return 0;
    }

    @Override // android.view.ViewGroup
    public int getNestedScrollAxes() {
        return this.Q.a();
    }

    public CharSequence getTitle() {
        s();
        return this.f483q.getTitle();
    }

    @Override // d.b.g.e0
    public void h(int i2) {
        s();
        if (i2 == 2) {
            this.f483q.u();
        } else if (i2 == 5) {
            this.f483q.v();
        } else {
            if (i2 != 109) {
                return;
            }
            setOverlayMode(true);
        }
    }

    @Override // d.b.g.e0
    public void i() {
        s();
        this.f483q.h();
    }

    @Override // d.h.j.o
    public void j(View view, int i2, int i3, int i4, int i5, int i6, int[] iArr) {
        if (i6 == 0) {
            onNestedScroll(view, i2, i3, i4, i5);
        }
    }

    @Override // d.h.j.n
    public void k(View view, int i2, int i3, int i4, int i5, int i6) {
        if (i6 == 0) {
            onNestedScroll(view, i2, i3, i4, i5);
        }
    }

    @Override // d.h.j.n
    public boolean l(View view, View view2, int i2, int i3) {
        return i3 == 0 && onStartNestedScroll(view, view2, i2);
    }

    @Override // d.h.j.n
    public void m(View view, View view2, int i2, int i3) {
        if (i3 == 0) {
            onNestedScrollAccepted(view, view2, i2);
        }
    }

    @Override // d.h.j.n
    public void n(View view, int i2) {
        if (i2 == 0) {
            onStopNestedScroll(view);
        }
    }

    @Override // d.h.j.n
    public void o(View view, int i2, int i3, int[] iArr, int i4) {
        if (i4 == 0) {
            onNestedPreScroll(view, i2, i3, iArr);
        }
    }

    @Override // android.view.View
    public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) {
        s();
        h0 h0VarI = h0.i(windowInsets, this);
        boolean zP = p(this.f482p, new Rect(h0VarI.b(), h0VarI.d(), h0VarI.c(), h0VarI.a()), true, true, false, true);
        Rect rect = this.f492z;
        AtomicInteger atomicInteger = y.a;
        y.h.b(this, h0VarI, rect);
        Rect rect2 = this.f492z;
        h0 h0VarI2 = h0VarI.f2736b.i(rect2.left, rect2.top, rect2.right, rect2.bottom);
        this.G = h0VarI2;
        boolean z2 = true;
        if (!this.H.equals(h0VarI2)) {
            this.H = this.G;
            zP = true;
        }
        if (this.A.equals(this.f492z)) {
            z2 = zP;
        } else {
            this.A.set(this.f492z);
        }
        if (z2) {
            requestLayout();
        }
        return h0VarI.f2736b.a().f2736b.c().f2736b.b().g();
    }

    @Override // android.view.View
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        r(getContext());
        AtomicInteger atomicInteger = y.a;
        y.g.c(this);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        q();
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onLayout(boolean z2, int i2, int i3, int i4, int i5) {
        int childCount = getChildCount();
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        for (int i6 = 0; i6 < childCount; i6++) {
            View childAt = getChildAt(i6);
            if (childAt.getVisibility() != 8) {
                e eVar = (e) childAt.getLayoutParams();
                int measuredWidth = childAt.getMeasuredWidth();
                int measuredHeight = childAt.getMeasuredHeight();
                int i7 = ((ViewGroup.MarginLayoutParams) eVar).leftMargin + paddingLeft;
                int i8 = ((ViewGroup.MarginLayoutParams) eVar).topMargin + paddingTop;
                childAt.layout(i7, i8, measuredWidth + i7, measuredHeight + i8);
            }
        }
    }

    @Override // android.view.View
    public void onMeasure(int i2, int i3) {
        int measuredHeight;
        h0 h0VarB;
        s();
        measureChildWithMargins(this.f482p, i2, 0, i3, 0);
        e eVar = (e) this.f482p.getLayoutParams();
        int iMax = Math.max(0, this.f482p.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) eVar).leftMargin + ((ViewGroup.MarginLayoutParams) eVar).rightMargin);
        int iMax2 = Math.max(0, this.f482p.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) eVar).topMargin + ((ViewGroup.MarginLayoutParams) eVar).bottomMargin);
        int iCombineMeasuredStates = View.combineMeasuredStates(0, this.f482p.getMeasuredState());
        AtomicInteger atomicInteger = y.a;
        boolean z2 = (y.c.g(this) & 256) != 0;
        if (z2) {
            measuredHeight = this.f479m;
            if (this.f487u && this.f482p.getTabContainer() != null) {
                measuredHeight += this.f479m;
            }
        } else {
            measuredHeight = this.f482p.getVisibility() != 8 ? this.f482p.getMeasuredHeight() : 0;
        }
        this.B.set(this.f492z);
        h0 h0Var = this.G;
        this.I = h0Var;
        if (this.f486t || z2) {
            d.h.d.b bVarA = d.h.d.b.a(h0Var.b(), this.I.d() + measuredHeight, this.I.c(), this.I.a() + 0);
            h0 h0Var2 = this.I;
            int i4 = Build.VERSION.SDK_INT;
            h0.e dVar = i4 >= 30 ? new h0.d(h0Var2) : i4 >= 29 ? new h0.c(h0Var2) : new h0.b(h0Var2);
            dVar.d(bVarA);
            h0VarB = dVar.b();
        } else {
            Rect rect = this.B;
            rect.top += measuredHeight;
            rect.bottom += 0;
            h0VarB = h0Var.f2736b.i(0, measuredHeight, 0, 0);
        }
        this.I = h0VarB;
        p(this.f481o, this.B, true, true, true, true);
        if (!this.J.equals(this.I)) {
            h0 h0Var3 = this.I;
            this.J = h0Var3;
            y.c(this.f481o, h0Var3);
        }
        measureChildWithMargins(this.f481o, i2, 0, i3, 0);
        e eVar2 = (e) this.f481o.getLayoutParams();
        int iMax3 = Math.max(iMax, this.f481o.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) eVar2).leftMargin + ((ViewGroup.MarginLayoutParams) eVar2).rightMargin);
        int iMax4 = Math.max(iMax2, this.f481o.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) eVar2).topMargin + ((ViewGroup.MarginLayoutParams) eVar2).bottomMargin);
        int iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates, this.f481o.getMeasuredState());
        setMeasuredDimension(View.resolveSizeAndState(Math.max(getPaddingRight() + getPaddingLeft() + iMax3, getSuggestedMinimumWidth()), i2, iCombineMeasuredStates2), View.resolveSizeAndState(Math.max(getPaddingBottom() + getPaddingTop() + iMax4, getSuggestedMinimumHeight()), i3, iCombineMeasuredStates2 << 16));
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public boolean onNestedFling(View view, float f2, float f3, boolean z2) {
        if (!this.f488v || !z2) {
            return false;
        }
        this.L.fling(0, 0, 0, (int) f3, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
        if (this.L.getFinalY() > this.f482p.getHeight()) {
            q();
            this.P.run();
        } else {
            q();
            this.O.run();
        }
        this.f489w = true;
        return true;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public boolean onNestedPreFling(View view, float f2, float f3) {
        return false;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public void onNestedPreScroll(View view, int i2, int i3, int[] iArr) {
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public void onNestedScroll(View view, int i2, int i3, int i4, int i5) {
        int i6 = this.f490x + i3;
        this.f490x = i6;
        setActionBarHideOffset(i6);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public void onNestedScrollAccepted(View view, View view2, int i2) {
        s sVar;
        g gVar;
        this.Q.a = i2;
        this.f490x = getActionBarHideOffset();
        q();
        d dVar = this.K;
        if (dVar == null || (gVar = (sVar = (s) dVar).f1656v) == null) {
            return;
        }
        gVar.a();
        sVar.f1656v = null;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public boolean onStartNestedScroll(View view, View view2, int i2) {
        if ((i2 & 2) == 0 || this.f482p.getVisibility() != 0) {
            return false;
        }
        return this.f488v;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public void onStopNestedScroll(View view) {
        if (this.f488v && !this.f489w) {
            if (this.f490x <= this.f482p.getHeight()) {
                q();
                postDelayed(this.O, 600L);
            } else {
                q();
                postDelayed(this.P, 600L);
            }
        }
        d dVar = this.K;
        if (dVar != null) {
            Objects.requireNonNull((s) dVar);
        }
    }

    @Override // android.view.View
    @Deprecated
    public void onWindowSystemUiVisibilityChanged(int i2) {
        super.onWindowSystemUiVisibilityChanged(i2);
        s();
        int i3 = this.f491y ^ i2;
        this.f491y = i2;
        boolean z2 = (i2 & 4) == 0;
        boolean z3 = (i2 & 256) != 0;
        d dVar = this.K;
        if (dVar != null) {
            ((s) dVar).f1652r = !z3;
            if (z2 || !z3) {
                s sVar = (s) dVar;
                if (sVar.f1653s) {
                    sVar.f1653s = false;
                    sVar.s(true);
                }
            } else {
                s sVar2 = (s) dVar;
                if (!sVar2.f1653s) {
                    sVar2.f1653s = true;
                    sVar2.s(true);
                }
            }
        }
        if ((i3 & 256) == 0 || this.K == null) {
            return;
        }
        AtomicInteger atomicInteger = y.a;
        y.g.c(this);
    }

    @Override // android.view.View
    public void onWindowVisibilityChanged(int i2) {
        super.onWindowVisibilityChanged(i2);
        this.f480n = i2;
        d dVar = this.K;
        if (dVar != null) {
            ((s) dVar).f1651q = i2;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean p(android.view.View r3, android.graphics.Rect r4, boolean r5, boolean r6, boolean r7, boolean r8) {
        /*
            r2 = this;
            android.view.ViewGroup$LayoutParams r3 = r3.getLayoutParams()
            androidx.appcompat.widget.ActionBarOverlayLayout$e r3 = (androidx.appcompat.widget.ActionBarOverlayLayout.e) r3
            r0 = 1
            if (r5 == 0) goto L13
            int r5 = r3.leftMargin
            int r1 = r4.left
            if (r5 == r1) goto L13
            r3.leftMargin = r1
            r5 = r0
            goto L14
        L13:
            r5 = 0
        L14:
            if (r6 == 0) goto L1f
            int r6 = r3.topMargin
            int r1 = r4.top
            if (r6 == r1) goto L1f
            r3.topMargin = r1
            r5 = r0
        L1f:
            if (r8 == 0) goto L2a
            int r6 = r3.rightMargin
            int r8 = r4.right
            if (r6 == r8) goto L2a
            r3.rightMargin = r8
            r5 = r0
        L2a:
            if (r7 == 0) goto L35
            int r6 = r3.bottomMargin
            int r4 = r4.bottom
            if (r6 == r4) goto L35
            r3.bottomMargin = r4
            goto L36
        L35:
            r0 = r5
        L36:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.ActionBarOverlayLayout.p(android.view.View, android.graphics.Rect, boolean, boolean, boolean, boolean):boolean");
    }

    public void q() {
        removeCallbacks(this.O);
        removeCallbacks(this.P);
        ViewPropertyAnimator viewPropertyAnimator = this.M;
        if (viewPropertyAnimator != null) {
            viewPropertyAnimator.cancel();
        }
    }

    public final void r(Context context) {
        TypedArray typedArrayObtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(f478f);
        this.f479m = typedArrayObtainStyledAttributes.getDimensionPixelSize(0, 0);
        Drawable drawable = typedArrayObtainStyledAttributes.getDrawable(1);
        this.f484r = drawable;
        setWillNotDraw(drawable == null);
        typedArrayObtainStyledAttributes.recycle();
        this.f485s = context.getApplicationInfo().targetSdkVersion < 19;
        this.L = new OverScroller(context);
    }

    public void s() {
        f0 wrapper;
        if (this.f481o == null) {
            this.f481o = (ContentFrameLayout) findViewById(R.id.action_bar_activity_content);
            this.f482p = (ActionBarContainer) findViewById(R.id.action_bar_container);
            KeyEvent.Callback callbackFindViewById = findViewById(R.id.action_bar);
            if (callbackFindViewById instanceof f0) {
                wrapper = (f0) callbackFindViewById;
            } else {
                if (!(callbackFindViewById instanceof Toolbar)) {
                    StringBuilder sbF = g.a.a.a.a.F("Can't make a decor toolbar out of ");
                    sbF.append(callbackFindViewById.getClass().getSimpleName());
                    throw new IllegalStateException(sbF.toString());
                }
                wrapper = ((Toolbar) callbackFindViewById).getWrapper();
            }
            this.f483q = wrapper;
        }
    }

    public void setActionBarHideOffset(int i2) {
        q();
        this.f482p.setTranslationY(-Math.max(0, Math.min(i2, this.f482p.getHeight())));
    }

    public void setActionBarVisibilityCallback(d dVar) {
        this.K = dVar;
        if (getWindowToken() != null) {
            ((s) this.K).f1651q = this.f480n;
            int i2 = this.f491y;
            if (i2 != 0) {
                onWindowSystemUiVisibilityChanged(i2);
                AtomicInteger atomicInteger = y.a;
                y.g.c(this);
            }
        }
    }

    public void setHasNonEmbeddedTabs(boolean z2) {
        this.f487u = z2;
    }

    public void setHideOnContentScrollEnabled(boolean z2) {
        if (z2 != this.f488v) {
            this.f488v = z2;
            if (z2) {
                return;
            }
            q();
            setActionBarHideOffset(0);
        }
    }

    public void setIcon(int i2) {
        s();
        this.f483q.setIcon(i2);
    }

    public void setIcon(Drawable drawable) {
        s();
        this.f483q.setIcon(drawable);
    }

    public void setLogo(int i2) {
        s();
        this.f483q.m(i2);
    }

    public void setOverlayMode(boolean z2) {
        this.f486t = z2;
        this.f485s = z2 && getContext().getApplicationInfo().targetSdkVersion < 19;
    }

    public void setShowingForActionMode(boolean z2) {
    }

    public void setUiOptions(int i2) {
    }

    @Override // d.b.g.e0
    public void setWindowCallback(Window.Callback callback) {
        s();
        this.f483q.setWindowCallback(callback);
    }

    @Override // d.b.g.e0
    public void setWindowTitle(CharSequence charSequence) {
        s();
        this.f483q.setWindowTitle(charSequence);
    }

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