package com.google.android.material.snackbar;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import com.google.android.material.internal.w0;
import com.google.android.material.shape.s;
import m7.k;
import x8.e;
import x8.m;

/* JADX INFO: loaded from: classes2.dex */
@RestrictTo({RestrictTo.Scope.f556b})
public class BaseTransientBottomBar$SnackbarBaseLayout extends FrameLayout {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final k f23264h = new k();

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

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

    @Nullable
    private b baseTransientBottomBar;

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public PorterDuff.Mode f23271g;

    @Nullable
    private Rect originalMargins;

    @Nullable
    s shapeAppearanceModel;

    public BaseTransientBottomBar$SnackbarBaseLayout(Context context, AttributeSet attributeSet) {
        Drawable drawable;
        super(x9.a.wrap(context, attributeSet, 0, 0), attributeSet);
        Context context2 = getContext();
        TypedArray typedArrayObtainStyledAttributes = context2.obtainStyledAttributes(attributeSet, m.SnackbarLayout);
        if (typedArrayObtainStyledAttributes.hasValue(m.SnackbarLayout_elevation)) {
            setElevation(typedArrayObtainStyledAttributes.getDimensionPixelSize(r2, 0));
        }
        this.f23265a = typedArrayObtainStyledAttributes.getInt(m.SnackbarLayout_animationMode, 0);
        if (typedArrayObtainStyledAttributes.hasValue(m.SnackbarLayout_shapeAppearance) || typedArrayObtainStyledAttributes.hasValue(m.SnackbarLayout_shapeAppearanceOverlay)) {
            this.shapeAppearanceModel = s.c(context2, attributeSet, 0, 0).a();
        }
        this.f23266b = typedArrayObtainStyledAttributes.getFloat(m.SnackbarLayout_backgroundOverlayColorAlpha, 1.0f);
        setBackgroundTintList(q9.d.getColorStateList(context2, typedArrayObtainStyledAttributes, m.SnackbarLayout_backgroundTint));
        setBackgroundTintMode(w0.f(typedArrayObtainStyledAttributes.getInt(m.SnackbarLayout_backgroundTintMode, -1), PorterDuff.Mode.SRC_IN));
        this.f23267c = typedArrayObtainStyledAttributes.getFloat(m.SnackbarLayout_actionTextColorAlpha, 1.0f);
        this.f23268d = typedArrayObtainStyledAttributes.getDimensionPixelSize(m.SnackbarLayout_android_maxWidth, -1);
        this.f23269e = typedArrayObtainStyledAttributes.getDimensionPixelSize(m.SnackbarLayout_maxActionInlineWidth, -1);
        typedArrayObtainStyledAttributes.recycle();
        setOnTouchListener(f23264h);
        setFocusable(true);
        if (getBackground() == null) {
            int iE = h9.a.e(getBackgroundOverlayColorAlpha(), h9.a.b(x8.c.colorSurface, this), h9.a.b(x8.c.colorOnSurface, this));
            s sVar = this.shapeAppearanceModel;
            if (sVar != null) {
                int i10 = b.f23275a;
                com.google.android.material.shape.k kVar = new com.google.android.material.shape.k(sVar);
                kVar.setFillColor(ColorStateList.valueOf(iE));
                drawable = kVar;
            } else {
                Resources resources = getResources();
                int i11 = b.f23275a;
                float dimension = resources.getDimension(e.mtrl_snackbar_background_corner_radius);
                GradientDrawable gradientDrawable = new GradientDrawable();
                gradientDrawable.setShape(0);
                gradientDrawable.setCornerRadius(dimension);
                gradientDrawable.setColor(iE);
                drawable = gradientDrawable;
            }
            ColorStateList colorStateList = this.f23270f;
            if (colorStateList != null) {
                drawable.setTintList(colorStateList);
            }
            setBackground(drawable);
        }
    }

    private void setBaseTransientBottomBar(b bVar) {
    }

    public float getActionTextColorAlpha() {
        return this.f23267c;
    }

    public int getAnimationMode() {
        return this.f23265a;
    }

    public float getBackgroundOverlayColorAlpha() {
        return this.f23266b;
    }

    public int getMaxInlineActionWidth() {
        return this.f23269e;
    }

    public int getMaxWidth() {
        return this.f23268d;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        requestApplyInsets();
    }

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

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        super.onLayout(z10, i10, i11, i12, i13);
    }

    @Override // android.widget.FrameLayout, android.view.View
    public void onMeasure(int i10, int i11) {
        super.onMeasure(i10, i11);
        int i12 = this.f23268d;
        if (i12 <= 0 || getMeasuredWidth() <= i12) {
            return;
        }
        super.onMeasure(View.MeasureSpec.makeMeasureSpec(i12, 1073741824), i11);
    }

    public void setAnimationMode(int i10) {
        this.f23265a = i10;
    }

    @Override // android.view.View
    public void setBackground(@Nullable Drawable drawable) {
        setBackgroundDrawable(drawable);
    }

    @Override // android.view.View
    public void setBackgroundDrawable(@Nullable Drawable drawable) {
        if (drawable != null && this.f23270f != null) {
            drawable = drawable.mutate();
            drawable.setTintList(this.f23270f);
            drawable.setTintMode(this.f23271g);
        }
        super.setBackgroundDrawable(drawable);
    }

    @Override // android.view.View
    public void setBackgroundTintList(@Nullable ColorStateList colorStateList) {
        this.f23270f = colorStateList;
        if (getBackground() != null) {
            Drawable drawableMutate = getBackground().mutate();
            drawableMutate.setTintList(colorStateList);
            drawableMutate.setTintMode(this.f23271g);
            if (drawableMutate != getBackground()) {
                super.setBackgroundDrawable(drawableMutate);
            }
        }
    }

    @Override // android.view.View
    public void setBackgroundTintMode(@Nullable PorterDuff.Mode mode) {
        this.f23271g = mode;
        if (getBackground() != null) {
            Drawable drawableMutate = getBackground().mutate();
            drawableMutate.setTintMode(mode);
            if (drawableMutate != getBackground()) {
                super.setBackgroundDrawable(drawableMutate);
            }
        }
    }

    @Override // android.view.View
    public void setLayoutParams(ViewGroup.LayoutParams layoutParams) {
        super.setLayoutParams(layoutParams);
        if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
            this.originalMargins = new Rect(marginLayoutParams.leftMargin, marginLayoutParams.topMargin, marginLayoutParams.rightMargin, marginLayoutParams.bottomMargin);
        }
    }

    @Override // android.view.View
    public void setOnClickListener(@Nullable View.OnClickListener onClickListener) {
        setOnTouchListener(onClickListener != null ? null : f23264h);
        super.setOnClickListener(onClickListener);
    }
}
