package com.google.android.gms.common;

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.Typeface;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import c8.b;
import c8.c;
import c8.d;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.common.internal.o0;
import com.google.android.gms.common.internal.w;
import com.google.android.gms.common.internal.zaaa;
import com.google.android.gms.dynamic.RemoteCreator$RemoteCreatorException;
import com.google.android.gms.measurement.internal.u1;
import com.google.errorprone.annotations.InlineMe;
import i8.e;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import k0.a;

/* JADX INFO: loaded from: classes2.dex */
public final class SignInButton extends FrameLayout implements View.OnClickListener {

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

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

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

    @Nullable
    private View.OnClickListener zad;

    @Retention(RetentionPolicy.SOURCE)
    public @interface ButtonSize {
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface ColorScheme {
    }

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

    @Override // android.view.View.OnClickListener
    public final void onClick(View view) {
        View.OnClickListener onClickListener = this.zad;
        if (onClickListener == null || view != this.f8184c) {
            return;
        }
        onClickListener.onClick(this);
    }

    public void setColorScheme(int i10) {
        setStyle(this.f8182a, i10);
    }

    @Override // android.view.View
    public void setEnabled(boolean z10) {
        super.setEnabled(z10);
        this.f8184c.setEnabled(z10);
    }

    @Override // android.view.View
    public void setOnClickListener(@Nullable View.OnClickListener onClickListener) {
        this.zad = onClickListener;
        View view = this.f8184c;
        if (view != null) {
            view.setOnClickListener(this);
        }
    }

    @Deprecated
    public void setScopes(@NonNull Scope[] scopeArr) {
        setStyle(this.f8182a, this.f8183b);
    }

    public void setSize(int i10) {
        setStyle(i10, this.f8183b);
    }

    public void setStyle(int i10, int i11) {
        this.f8182a = i10;
        this.f8183b = i11;
        Context context = getContext();
        View view = this.f8184c;
        if (view != null) {
            removeView(view);
        }
        try {
            this.f8184c = o0.a(context, this.f8182a, this.f8183b);
        } catch (RemoteCreator$RemoteCreatorException unused) {
            int i12 = this.f8182a;
            int i13 = this.f8183b;
            zaaa zaaaVar = new zaaa(context, null);
            Resources resources = context.getResources();
            zaaaVar.setTypeface(Typeface.DEFAULT_BOLD);
            zaaaVar.setTextSize(14.0f);
            int i14 = (int) ((resources.getDisplayMetrics().density * 48.0f) + 0.5f);
            zaaaVar.setMinHeight(i14);
            zaaaVar.setMinWidth(i14);
            int i15 = b.common_google_signin_btn_icon_dark;
            int i16 = b.common_google_signin_btn_icon_light;
            int iA = zaaa.a(i13, i15, i16, i16);
            int i17 = b.common_google_signin_btn_text_dark;
            int i18 = b.common_google_signin_btn_text_light;
            int iA2 = zaaa.a(i13, i17, i18, i18);
            if (i12 == 0 || i12 == 1) {
                iA = iA2;
            } else if (i12 != 2) {
                throw new IllegalStateException(u1.g("Unknown button size: ", i12));
            }
            Drawable drawable = resources.getDrawable(iA);
            a.setTintList(drawable, resources.getColorStateList(c8.a.common_google_signin_btn_tint));
            a.setTintMode(drawable, PorterDuff.Mode.SRC_ATOP);
            zaaaVar.setBackgroundDrawable(drawable);
            int i19 = c8.a.common_google_signin_btn_text_dark;
            int i20 = c8.a.common_google_signin_btn_text_light;
            zaaaVar.setTextColor((ColorStateList) w.checkNotNull(resources.getColorStateList(zaaa.a(i13, i19, i20, i20))));
            if (i12 == 0) {
                zaaaVar.setText(resources.getString(c.common_signin_button_text));
            } else if (i12 == 1) {
                zaaaVar.setText(resources.getString(c.common_signin_button_text_long));
            } else {
                if (i12 != 2) {
                    throw new IllegalStateException(u1.g("Unknown button size: ", i12));
                }
                zaaaVar.setText((CharSequence) null);
            }
            zaaaVar.setTransformationMethod(null);
            if (e.d(zaaaVar.getContext())) {
                zaaaVar.setGravity(19);
            }
            this.f8184c = zaaaVar;
        }
        addView(this.f8184c);
        this.f8184c.setEnabled(isEnabled());
        this.f8184c.setOnClickListener(this);
    }

    public SignInButton(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public SignInButton(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.zad = null;
        TypedArray typedArrayObtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, d.SignInButton, 0, 0);
        try {
            this.f8182a = typedArrayObtainStyledAttributes.getInt(d.SignInButton_buttonSize, 0);
            this.f8183b = typedArrayObtainStyledAttributes.getInt(d.SignInButton_colorScheme, 2);
            typedArrayObtainStyledAttributes.recycle();
            setStyle(this.f8182a, this.f8183b);
        } catch (Throwable th) {
            typedArrayObtainStyledAttributes.recycle();
            throw th;
        }
    }

    @InlineMe(replacement = "this.setStyle(buttonSize, colorScheme)")
    @Deprecated
    public void setStyle(int i10, int i11, @NonNull Scope[] scopeArr) {
        setStyle(i10, i11);
    }
}
