package com.google.android.material.floatingactionbutton;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.AnimatorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.gms.measurement.internal.u1;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.internal.q0;
import e.y;
import java.util.Iterator;
import java.util.List;
import l.j3;
import xyz.stream.utils.e0;

/* JADX INFO: loaded from: classes2.dex */
public class ExtendedFloatingActionButton extends MaterialButton implements d0.a {
    public static final j3 A0;
    public static final j3 B0;
    public static final j3 C0;

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public static final int f22528y0 = x8.l.Widget_MaterialComponents_ExtendedFloatingActionButton_Icon;
    public static final j3 z0;

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

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

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

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

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public final h f22533m0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public final f f22534n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public final int f22535o0;

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

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

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public final ExtendedFloatingActionButtonBehavior f22538r0;

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

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

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

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    public ColorStateList f22542v0;

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

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

    public static class ExtendedFloatingActionButtonBehavior<T extends ExtendedFloatingActionButton> extends d0.b {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public Rect f22545a;

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

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

        @Nullable
        private g internalAutoHideCallback;

        @Nullable
        private g internalAutoShrinkCallback;

        public ExtendedFloatingActionButtonBehavior() {
            this.f22546b = false;
            this.f22547c = true;
        }

        @Override // d0.b
        public final /* bridge */ /* synthetic */ boolean e(View view, Rect rect) {
            return false;
        }

        @Override // d0.b
        public final void g(d0.d dVar) {
            if (dVar.f24891h == 0) {
                dVar.f24891h = 80;
            }
        }

        @Override // d0.b
        public final boolean h(CoordinatorLayout coordinatorLayout, View view, View view2) {
            ExtendedFloatingActionButton extendedFloatingActionButton = (ExtendedFloatingActionButton) view;
            if (view2 instanceof AppBarLayout) {
                w(coordinatorLayout, (AppBarLayout) view2, extendedFloatingActionButton);
                return false;
            }
            ViewGroup.LayoutParams layoutParams = view2.getLayoutParams();
            if (!(layoutParams instanceof d0.d) || !(((d0.d) layoutParams).f24884a instanceof BottomSheetBehavior)) {
                return false;
            }
            x(view2, extendedFloatingActionButton);
            return false;
        }

        @Override // d0.b
        public final boolean l(CoordinatorLayout coordinatorLayout, View view, int i10) {
            ExtendedFloatingActionButton extendedFloatingActionButton = (ExtendedFloatingActionButton) view;
            List listI = coordinatorLayout.i(extendedFloatingActionButton);
            int size = listI.size();
            for (int i11 = 0; i11 < size; i11++) {
                View view2 = (View) listI.get(i11);
                if (!(view2 instanceof AppBarLayout)) {
                    ViewGroup.LayoutParams layoutParams = view2.getLayoutParams();
                    if ((layoutParams instanceof d0.d) && (((d0.d) layoutParams).f24884a instanceof BottomSheetBehavior) && x(view2, extendedFloatingActionButton)) {
                        break;
                    }
                } else {
                    if (w(coordinatorLayout, (AppBarLayout) view2, extendedFloatingActionButton)) {
                        break;
                    }
                }
            }
            coordinatorLayout.p(i10, extendedFloatingActionButton);
            return true;
        }

        @VisibleForTesting
        public void setInternalAutoHideCallback(@Nullable g gVar) {
        }

        @VisibleForTesting
        public void setInternalAutoShrinkCallback(@Nullable g gVar) {
        }

        public final boolean w(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, ExtendedFloatingActionButton extendedFloatingActionButton) {
            d0.d dVar = (d0.d) extendedFloatingActionButton.getLayoutParams();
            if ((!this.f22546b && !this.f22547c) || dVar.f24889f != appBarLayout.getId()) {
                return false;
            }
            if (this.f22545a == null) {
                this.f22545a = new Rect();
            }
            Rect rect = this.f22545a;
            com.google.android.material.internal.g.a(coordinatorLayout, appBarLayout, rect);
            if (rect.bottom <= appBarLayout.getMinimumHeightForVisibleOverlappingContent()) {
                extendedFloatingActionButton.performMotion(this.f22547c ? 2 : 1, null);
            } else {
                extendedFloatingActionButton.performMotion(this.f22547c ? 3 : 0, null);
            }
            return true;
        }

        public final boolean x(View view, ExtendedFloatingActionButton extendedFloatingActionButton) {
            d0.d dVar = (d0.d) extendedFloatingActionButton.getLayoutParams();
            if ((!this.f22546b && !this.f22547c) || dVar.f24889f != view.getId()) {
                return false;
            }
            if (view.getTop() < (extendedFloatingActionButton.getHeight() / 2) + ((ViewGroup.MarginLayoutParams) ((d0.d) extendedFloatingActionButton.getLayoutParams())).topMargin) {
                extendedFloatingActionButton.performMotion(this.f22547c ? 2 : 1, null);
            } else {
                extendedFloatingActionButton.performMotion(this.f22547c ? 3 : 0, null);
            }
            return true;
        }

        public ExtendedFloatingActionButtonBehavior(@NonNull Context context, @Nullable AttributeSet attributeSet) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, x8.m.ExtendedFloatingActionButton_Behavior_Layout);
            this.f22546b = typedArrayObtainStyledAttributes.getBoolean(x8.m.ExtendedFloatingActionButton_Behavior_Layout_behavior_autoHide, false);
            this.f22547c = typedArrayObtainStyledAttributes.getBoolean(x8.m.ExtendedFloatingActionButton_Behavior_Layout_behavior_autoShrink, true);
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    static {
        Class<Float> cls = Float.class;
        z0 = new j3(8, cls, "width");
        A0 = new j3(9, cls, "height");
        B0 = new j3(10, cls, "paddingStart");
        C0 = new j3(11, cls, "paddingEnd");
    }

    public ExtendedFloatingActionButton(@NonNull Context context) {
        this(context, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0047  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void performMotion(int i10, @Nullable g gVar) {
        b bVar;
        if (i10 == 0) {
            bVar = this.f22533m0;
        } else if (i10 == 1) {
            bVar = this.f22534n0;
        } else if (i10 == 2) {
            bVar = this.f22531k0;
        } else {
            if (i10 != 3) {
                throw new IllegalStateException(u1.g("Unknown strategy type: ", i10));
            }
            bVar = this.f22532l0;
        }
        if (bVar.e()) {
            return;
        }
        if (this.f22530j0) {
            if (isLaidOut()) {
                if (!isInEditMode()) {
                    if (i10 == 2) {
                        ViewGroup.LayoutParams layoutParams = getLayoutParams();
                        if (layoutParams != null) {
                            this.f22543w0 = layoutParams.width;
                            this.f22544x0 = layoutParams.height;
                        } else {
                            this.f22543w0 = getWidth();
                            this.f22544x0 = getHeight();
                        }
                    }
                    measure(0, 0);
                    AnimatorSet animatorSetF = bVar.f();
                    animatorSetF.addListener(new d(bVar));
                    Iterator it = bVar.f22563c.iterator();
                    while (it.hasNext()) {
                        animatorSetF.addListener((Animator.AnimatorListener) it.next());
                    }
                    animatorSetF.start();
                    return;
                }
            } else if (getVisibility() != 0) {
                if (this.f22541u0) {
                }
            } else if (this.f22541u0) {
            }
        }
        bVar.d();
        bVar.onChange(gVar);
    }

    @Override // android.widget.Button, android.widget.TextView, android.view.View
    public CharSequence getAccessibilityClassName() {
        return "com.google.android.material.floatingactionbutton.FloatingActionButton";
    }

    @Override // d0.a
    @NonNull
    public d0.b getBehavior() {
        return this.f22538r0;
    }

    public int getCollapsedPadding() {
        return (getCollapsedSize() - getIconSize()) / 2;
    }

    @VisibleForTesting
    public int getCollapsedSize() {
        int i10 = this.f22535o0;
        return i10 < 0 ? (Math.min(getPaddingStart(), getPaddingEnd()) * 2) + getIconSize() : i10;
    }

    @Nullable
    public y8.g getExtendMotionSpec() {
        return this.f22532l0.getMotionSpec();
    }

    @Nullable
    public y8.g getHideMotionSpec() {
        return this.f22534n0.getMotionSpec();
    }

    @Nullable
    public y8.g getShowMotionSpec() {
        return this.f22533m0.getMotionSpec();
    }

    @Nullable
    public y8.g getShrinkMotionSpec() {
        return this.f22531k0.getMotionSpec();
    }

    public final void n(ColorStateList colorStateList) {
        super.setTextColor(colorStateList);
    }

    @Override // com.google.android.material.button.MaterialButton, android.widget.TextView, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (this.f22539s0 && TextUtils.isEmpty(getText()) && getIcon() != null) {
            this.f22539s0 = false;
            this.f22531k0.d();
        }
    }

    public void setAnimateShowBeforeLayout(boolean z10) {
        this.f22541u0 = z10;
    }

    public void setAnimationEnabled(boolean z10) {
        this.f22530j0 = z10;
    }

    public void setExtendMotionSpec(@Nullable y8.g gVar) {
        this.f22532l0.setMotionSpec(gVar);
    }

    public void setExtendMotionSpecResource(@AnimatorRes int i10) {
        setExtendMotionSpec(y8.g.createFromResource(getContext(), i10));
    }

    public void setExtended(boolean z10) {
        if (this.f22539s0 == z10) {
            return;
        }
        e eVar = z10 ? this.f22532l0 : this.f22531k0;
        if (eVar.e()) {
            return;
        }
        eVar.d();
    }

    public void setHideMotionSpec(@Nullable y8.g gVar) {
        this.f22534n0.setMotionSpec(gVar);
    }

    public void setHideMotionSpecResource(@AnimatorRes int i10) {
        setHideMotionSpec(y8.g.createFromResource(getContext(), i10));
    }

    @Override // android.widget.TextView, android.view.View
    public void setPadding(int i10, int i11, int i12, int i13) {
        super.setPadding(i10, i11, i12, i13);
        if (!this.f22539s0 || this.f22540t0) {
            return;
        }
        this.f22536p0 = getPaddingStart();
        this.f22537q0 = getPaddingEnd();
    }

    @Override // android.widget.TextView, android.view.View
    public void setPaddingRelative(int i10, int i11, int i12, int i13) {
        super.setPaddingRelative(i10, i11, i12, i13);
        if (!this.f22539s0 || this.f22540t0) {
            return;
        }
        this.f22536p0 = i10;
        this.f22537q0 = i12;
    }

    public void setShowMotionSpec(@Nullable y8.g gVar) {
        this.f22533m0.setMotionSpec(gVar);
    }

    public void setShowMotionSpecResource(@AnimatorRes int i10) {
        setShowMotionSpec(y8.g.createFromResource(getContext(), i10));
    }

    public void setShrinkMotionSpec(@Nullable y8.g gVar) {
        this.f22531k0.setMotionSpec(gVar);
    }

    public void setShrinkMotionSpecResource(@AnimatorRes int i10) {
        setShrinkMotionSpec(y8.g.createFromResource(getContext(), i10));
    }

    @Override // android.widget.TextView
    public void setTextColor(int i10) {
        super.setTextColor(i10);
        this.f22542v0 = getTextColors();
    }

    public ExtendedFloatingActionButton(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, x8.c.extendedFloatingActionButtonStyle);
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public ExtendedFloatingActionButton(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        int i11 = f22528y0;
        super(x9.a.wrap(context, attributeSet, i10, i11), attributeSet, i10);
        this.f22529i0 = 0;
        this.f22530j0 = true;
        a aVar = new a();
        h hVar = new h(this, aVar);
        this.f22533m0 = hVar;
        f fVar = new f(this, aVar);
        this.f22534n0 = fVar;
        this.f22539s0 = true;
        this.f22540t0 = false;
        this.f22541u0 = false;
        Context context2 = getContext();
        this.f22538r0 = new ExtendedFloatingActionButtonBehavior(context2, attributeSet);
        TypedArray typedArrayC = q0.c(context2, attributeSet, x8.m.ExtendedFloatingActionButton, i10, i11, new int[0]);
        y8.g gVarCreateFromAttribute = y8.g.createFromAttribute(context2, typedArrayC, x8.m.ExtendedFloatingActionButton_showMotionSpec);
        y8.g gVarCreateFromAttribute2 = y8.g.createFromAttribute(context2, typedArrayC, x8.m.ExtendedFloatingActionButton_hideMotionSpec);
        y8.g gVarCreateFromAttribute3 = y8.g.createFromAttribute(context2, typedArrayC, x8.m.ExtendedFloatingActionButton_extendMotionSpec);
        y8.g gVarCreateFromAttribute4 = y8.g.createFromAttribute(context2, typedArrayC, x8.m.ExtendedFloatingActionButton_shrinkMotionSpec);
        this.f22535o0 = typedArrayC.getDimensionPixelSize(x8.m.ExtendedFloatingActionButton_collapsedSize, -1);
        int i12 = typedArrayC.getInt(x8.m.ExtendedFloatingActionButton_extendStrategy, 1);
        this.f22536p0 = getPaddingStart();
        this.f22537q0 = getPaddingEnd();
        a aVar2 = new a();
        y yVar = new y(this);
        e0 e0Var = new e0(this, yVar, 13);
        e eVar = new e(this, aVar2, i12 != 1 ? i12 != 2 ? new xyz.stream.utils.t((Object) this, (Object) e0Var, (x6.b) yVar, 17) : e0Var : yVar, true);
        this.f22532l0 = eVar;
        e eVar2 = new e(this, aVar2, new nb.c(this, 19), false);
        this.f22531k0 = eVar2;
        hVar.setMotionSpec(gVarCreateFromAttribute);
        fVar.setMotionSpec(gVarCreateFromAttribute2);
        eVar.setMotionSpec(gVarCreateFromAttribute3);
        eVar2.setMotionSpec(gVarCreateFromAttribute4);
        typedArrayC.recycle();
        setShapeAppearanceModel(com.google.android.material.shape.s.d(context2, attributeSet, i10, i11, com.google.android.material.shape.s.f23150m).a());
        this.f22542v0 = getTextColors();
    }

    @Override // android.widget.TextView
    public void setTextColor(@NonNull ColorStateList colorStateList) {
        super.setTextColor(colorStateList);
        this.f22542v0 = getTextColors();
    }
}
