package com.discord.views; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.widget.Checkable; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.ColorInt; import androidx.annotation.StringRes; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.res.ResourcesCompat; import androidx.core.view.AccessibilityDelegateCompat; import androidx.core.view.ViewCompat; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import c.a.d.o; import c.a.i.i3; import c.a.i.j3; import c.a.i.k3; import c.a.i.l3; import com.discord.R; import com.google.android.material.checkbox.MaterialCheckBox; import com.google.android.material.radiobutton.MaterialRadioButton; import com.google.android.material.switchmaterial.SwitchMaterial; import d0.z.d.m; import java.util.Objects; import kotlin.NoWhenBranchMatchedException; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.functions.Action0; import rx.functions.Action1; /* compiled from: CheckedSetting.kt */ public final class CheckedSetting extends RelativeLayout implements Checkable { public static final /* synthetic */ int i = 0; public Action1 j; public b k; /* compiled from: CheckedSetting.kt */ public enum ViewType { CHECK, RADIO, SWITCH; public static final a Companion = new a(null); private static final ViewType[] VALUES = values(); /* compiled from: CheckedSetting.kt */ public static final class a { public a(DefaultConstructorMarker defaultConstructorMarker) { } } public static final /* synthetic */ ViewType[] access$getVALUES$cp() { return VALUES; } } /* compiled from: java-style lambda group */ public static final class a implements View.OnClickListener { public final /* synthetic */ int i; public final /* synthetic */ Object j; public a(int i, Object obj) { this.i = i; this.j = obj; } @Override // android.view.View.OnClickListener public final void onClick(View view) { int i = this.i; if (i == 0) { CheckedSetting.a((CheckedSetting) this.j).c().setChecked(true); } else if (i == 1) { CheckedSetting.a((CheckedSetting) this.j).c().setChecked(true ^ CheckedSetting.a((CheckedSetting) this.j).c().isChecked()); } else { throw null; } } } /* compiled from: CheckedSetting.kt */ public interface b { /* compiled from: CheckedSetting.kt */ public static final class a extends c { public final ConstraintLayout e; public final MaterialCheckBox f; /* JADX WARNING: Illegal instructions before constructor call */ public a(i3 i3Var) { super(r0, null, 2); m.checkNotNullParameter(i3Var, "binding"); ConstraintLayout constraintLayout = i3Var.f105c; m.checkNotNullExpressionValue(constraintLayout, "binding.settingContainer"); ConstraintLayout constraintLayout2 = i3Var.f105c; m.checkNotNullExpressionValue(constraintLayout2, "binding.settingContainer"); this.e = constraintLayout2; MaterialCheckBox materialCheckBox = i3Var.b; m.checkNotNullExpressionValue(materialCheckBox, "binding.settingButton"); this.f = materialCheckBox; } @Override // com.discord.views.CheckedSetting.b public View b() { return this.e; } @Override // com.discord.views.CheckedSetting.b public CompoundButton c() { return this.f; } } /* compiled from: CheckedSetting.kt */ /* renamed from: com.discord.views.CheckedSetting$b$b reason: collision with other inner class name */ public static final class C0180b extends c { public final ConstraintLayout e; public final MaterialRadioButton f; /* JADX WARNING: Illegal instructions before constructor call */ public C0180b(j3 j3Var) { super(r0, null, 2); m.checkNotNullParameter(j3Var, "binding"); ConstraintLayout constraintLayout = j3Var.f110c; m.checkNotNullExpressionValue(constraintLayout, "binding.settingContainer"); ConstraintLayout constraintLayout2 = j3Var.f110c; m.checkNotNullExpressionValue(constraintLayout2, "binding.settingContainer"); this.e = constraintLayout2; MaterialRadioButton materialRadioButton = j3Var.b; m.checkNotNullExpressionValue(materialRadioButton, "binding.settingButton"); this.f = materialRadioButton; } @Override // com.discord.views.CheckedSetting.b public View b() { return this.e; } @Override // com.discord.views.CheckedSetting.b public CompoundButton c() { return this.f; } } /* compiled from: CheckedSetting.kt */ public static abstract class c implements b { public final TextView a; public final TextView b; /* renamed from: c reason: collision with root package name */ public final TextView f2135c; public final ImageView d; public c(ViewGroup viewGroup, k3 k3Var, int i) { k3 k3Var2; if ((i & 2) != 0) { int i2 = 2131364867; ImageView imageView = (ImageView) viewGroup.findViewById(2131364867); if (imageView != null) { i2 = 2131364868; TextView textView = (TextView) viewGroup.findViewById(2131364868); if (textView != null) { i2 = 2131364869; TextView textView2 = (TextView) viewGroup.findViewById(2131364869); if (textView2 != null) { i2 = 2131364870; TextView textView3 = (TextView) viewGroup.findViewById(2131364870); if (textView3 != null) { k3Var2 = new k3(viewGroup, imageView, textView, textView2, textView3); m.checkNotNullExpressionValue(k3Var2, "ViewSettingSharedBinding.bind(container)"); } } } } throw new NullPointerException("Missing required view with ID: ".concat(viewGroup.getResources().getResourceName(i2))); } k3Var2 = null; m.checkNotNullParameter(viewGroup, "container"); m.checkNotNullParameter(k3Var2, "binding"); TextView textView4 = k3Var2.f116c; m.checkNotNullExpressionValue(textView4, "binding.settingLabel"); this.a = textView4; TextView textView5 = k3Var2.e; m.checkNotNullExpressionValue(textView5, "binding.settingTag"); this.b = textView5; TextView textView6 = k3Var2.d; m.checkNotNullExpressionValue(textView6, "binding.settingSubtext"); this.f2135c = textView6; ImageView imageView2 = k3Var2.b; m.checkNotNullExpressionValue(imageView2, "binding.settingDrawableLeft"); this.d = imageView2; } @Override // com.discord.views.CheckedSetting.b public TextView a() { return this.a; } @Override // com.discord.views.CheckedSetting.b public ImageView d() { return this.d; } @Override // com.discord.views.CheckedSetting.b public TextView e() { return this.b; } @Override // com.discord.views.CheckedSetting.b public TextView f() { return this.f2135c; } } /* compiled from: CheckedSetting.kt */ public static final class d extends c { public final ConstraintLayout e; public final SwitchMaterial f; /* JADX WARNING: Illegal instructions before constructor call */ public d(l3 l3Var) { super(r0, null, 2); m.checkNotNullParameter(l3Var, "binding"); ConstraintLayout constraintLayout = l3Var.f123c; m.checkNotNullExpressionValue(constraintLayout, "binding.settingContainer"); ConstraintLayout constraintLayout2 = l3Var.f123c; m.checkNotNullExpressionValue(constraintLayout2, "binding.settingContainer"); this.e = constraintLayout2; SwitchMaterial switchMaterial = l3Var.b; m.checkNotNullExpressionValue(switchMaterial, "binding.settingButton"); this.f = switchMaterial; } @Override // com.discord.views.CheckedSetting.b public View b() { return this.e; } @Override // com.discord.views.CheckedSetting.b public CompoundButton c() { return this.f; } } TextView a(); View b(); CompoundButton c(); ImageView d(); TextView e(); TextView f(); } /* compiled from: CheckedSetting.kt */ public static final class c implements View.OnClickListener { public final /* synthetic */ CheckedSetting i; public final /* synthetic */ CharSequence j; public c(CheckedSetting checkedSetting, CharSequence charSequence) { this.i = checkedSetting; this.j = charSequence; } @Override // android.view.View.OnClickListener public final void onClick(View view) { if (this.j != null) { o.h(this.i.getContext(), this.j, 0, null, 12); } } } /* compiled from: CheckedSetting.kt */ public static final class d extends AccessibilityDelegateCompat { public final /* synthetic */ CheckedSetting a; public final /* synthetic */ ViewType b; public d(CheckedSetting checkedSetting, ViewType viewType) { this.a = checkedSetting; this.b = viewType; } @Override // androidx.core.view.AccessibilityDelegateCompat public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) { m.checkNotNullParameter(view, "host"); m.checkNotNullParameter(accessibilityEvent, "event"); super.onInitializeAccessibilityEvent(view, accessibilityEvent); accessibilityEvent.setChecked(this.a.isChecked()); } @Override // androidx.core.view.AccessibilityDelegateCompat public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { int i; m.checkNotNullParameter(view, "host"); m.checkNotNullParameter(accessibilityNodeInfoCompat, "info"); super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); accessibilityNodeInfoCompat.setCheckable(true); accessibilityNodeInfoCompat.setChecked(this.a.isChecked()); Resources resources = view.getResources(); int ordinal = this.b.ordinal(); if (ordinal == 0) { i = 2131886083; } else if (ordinal == 1) { i = 2131886084; } else if (ordinal == 2) { i = 2131886085; } else { throw new NoWhenBranchMatchedException(); } accessibilityNodeInfoCompat.setRoleDescription(resources.getString(i)); } } /* compiled from: CheckedSetting.kt */ public static final class e implements CompoundButton.OnCheckedChangeListener { public final /* synthetic */ Action1 a; public e(Action1 action1) { this.a = action1; } @Override // android.widget.CompoundButton.OnCheckedChangeListener public final void onCheckedChanged(CompoundButton compoundButton, boolean z2) { Action1 action1 = this.a; if (action1 != null) { action1.call(Boolean.valueOf(z2)); } } } /* compiled from: CheckedSetting.kt */ public static final class f implements View.OnClickListener { public final /* synthetic */ Action0 i; public f(Action0 action0) { this.i = action0; } @Override // android.view.View.OnClickListener public final void onClick(View view) { this.i.call(); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public CheckedSetting(Context context, AttributeSet attributeSet) { super(context, attributeSet, 0); CharSequence charSequence = null; m.checkNotNullParameter(context, "context"); if (attributeSet == null) { f(ViewType.CHECK); return; } TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.a.CheckedSetting, 0, 0); m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…ble.CheckedSetting, 0, 0)"); try { int i2 = obtainStyledAttributes.getInt(15, ViewType.CHECK.ordinal()); Objects.requireNonNull(ViewType.Companion); f(ViewType.access$getVALUES$cp()[i2]); b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } int paddingLeft = bVar.b().getPaddingLeft(); b bVar2 = this.k; if (bVar2 == null) { m.throwUninitializedPropertyAccessException("binding"); } int paddingTop = bVar2.b().getPaddingTop(); int dimension = (int) obtainStyledAttributes.getDimension(6, (float) paddingLeft); int dimension2 = (int) obtainStyledAttributes.getDimension(7, (float) paddingTop); b bVar3 = this.k; if (bVar3 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar3.b().setPadding(dimension, dimension2, dimension, dimension2); float dimension3 = obtainStyledAttributes.getDimension(14, -1.0f); float f2 = (float) 0; if (dimension3 > f2) { b bVar4 = this.k; if (bVar4 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar4.a().setTextSize(0, dimension3); } ColorStateList colorStateList = obtainStyledAttributes.getColorStateList(12); if (colorStateList != null) { b bVar5 = this.k; if (bVar5 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar5.a().setTextColor(colorStateList); } b bVar6 = this.k; if (bVar6 == null) { m.throwUninitializedPropertyAccessException("binding"); } TextView a2 = bVar6.a(); String string = obtainStyledAttributes.getString(11); a2.setText(string != null ? c.a.k.b.k(string, new Object[0], null, 2) : null); b bVar7 = this.k; if (bVar7 == null) { m.throwUninitializedPropertyAccessException("binding"); } ImageView d2 = bVar7.d(); Drawable drawable = obtainStyledAttributes.getDrawable(3); d2.setVisibility(drawable != null ? 0 : 8); d2.setImageDrawable(drawable); ColorStateList colorStateList2 = obtainStyledAttributes.getColorStateList(4); if (colorStateList2 != null) { d2.setImageTintList(colorStateList2); } int resourceId = obtainStyledAttributes.getResourceId(13, -1); if (resourceId != -1) { b bVar8 = this.k; if (bVar8 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar8.a().setTypeface(ResourcesCompat.getFont(getContext(), resourceId)); } String string2 = obtainStyledAttributes.getString(8); charSequence = string2 != null ? c.a.k.b.k(string2, new Object[0], null, 2) : charSequence; if (charSequence == null || charSequence.length() == 0) { b bVar9 = this.k; if (bVar9 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar9.f().setVisibility(8); } else { b bVar10 = this.k; if (bVar10 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar10.f().setText(charSequence); b bVar11 = this.k; if (bVar11 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar11.f().setVisibility(0); } float dimension4 = obtainStyledAttributes.getDimension(10, -1.0f); if (dimension4 > f2) { b bVar12 = this.k; if (bVar12 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar12.f().setTextSize(0, dimension4); } ColorStateList colorStateList3 = obtainStyledAttributes.getColorStateList(9); if (colorStateList3 != null) { b bVar13 = this.k; if (bVar13 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar13.f().setTextColor(colorStateList3); } Drawable drawable2 = obtainStyledAttributes.getDrawable(0); if (drawable2 != null) { setBackground(drawable2); } else { setBackgroundResource(2131231043); } ColorStateList colorStateList4 = obtainStyledAttributes.getColorStateList(1); if (colorStateList4 != null) { setBackgroundTintList(colorStateList4); } Drawable drawable3 = obtainStyledAttributes.getDrawable(2); if (drawable3 != null) { b bVar14 = this.k; if (bVar14 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar14.b().setBackground(drawable3); } } finally { obtainStyledAttributes.recycle(); } } public static final /* synthetic */ b a(CheckedSetting checkedSetting) { b bVar = checkedSetting.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } return bVar; } public static /* synthetic */ void d(CheckedSetting checkedSetting, CharSequence charSequence, int i2) { int i3 = i2 & 1; checkedSetting.c(null); } public static /* synthetic */ void i(CheckedSetting checkedSetting, CharSequence charSequence, boolean z2, int i2) { if ((i2 & 2) != 0) { z2 = false; } checkedSetting.h(charSequence, z2); } public final void b(@StringRes int i2) { Context context = getContext(); m.checkNotNullExpressionValue(context, "context"); c(c.a.k.b.g(context, i2, new Object[0], null, 4)); } public final void c(CharSequence charSequence) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.b().setOnClickListener(new c(this, charSequence)); setAlpha(0.3f); } @Override // android.view.View, android.view.ViewGroup public void dispatchRestoreInstanceState(SparseArray sparseArray) { m.checkNotNullParameter(sparseArray, "container"); dispatchThawSelfOnly(sparseArray); } @Override // android.view.View, android.view.ViewGroup public void dispatchSaveInstanceState(SparseArray sparseArray) { m.checkNotNullParameter(sparseArray, "container"); dispatchFreezeSelfOnly(sparseArray); } public final void e(View.OnClickListener onClickListener) { m.checkNotNullParameter(onClickListener, "listener"); b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.b().setOnClickListener(onClickListener); setAlpha(1.0f); } public final void f(ViewType viewType) { b bVar; LayoutInflater from = LayoutInflater.from(getContext()); int ordinal = viewType.ordinal(); int i2 = 2131364864; if (ordinal == 0) { from.inflate(2131558816, this); MaterialCheckBox materialCheckBox = (MaterialCheckBox) findViewById(2131364864); if (materialCheckBox != null) { ConstraintLayout constraintLayout = (ConstraintLayout) findViewById(2131364865); if (constraintLayout != null) { i3 i3Var = new i3(this, materialCheckBox, constraintLayout); m.checkNotNullExpressionValue(i3Var, "ViewSettingCheckBinding.…ate(layoutInflater, this)"); m.checkNotNullParameter(i3Var, "binding"); bVar = new b.a(i3Var); } else { i2 = 2131364865; } } throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i2))); } else if (ordinal == 1) { from.inflate(2131558817, this); MaterialRadioButton materialRadioButton = (MaterialRadioButton) findViewById(2131364864); if (materialRadioButton != null) { ConstraintLayout constraintLayout2 = (ConstraintLayout) findViewById(2131364865); if (constraintLayout2 != null) { j3 j3Var = new j3(this, materialRadioButton, constraintLayout2); m.checkNotNullExpressionValue(j3Var, "ViewSettingRadioBinding.…ate(layoutInflater, this)"); m.checkNotNullParameter(j3Var, "binding"); bVar = new b.C0180b(j3Var); } else { i2 = 2131364865; } } throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i2))); } else if (ordinal == 2) { from.inflate(2131558819, this); SwitchMaterial switchMaterial = (SwitchMaterial) findViewById(2131364864); if (switchMaterial != null) { ConstraintLayout constraintLayout3 = (ConstraintLayout) findViewById(2131364865); if (constraintLayout3 != null) { l3 l3Var = new l3(this, switchMaterial, constraintLayout3); m.checkNotNullExpressionValue(l3Var, "ViewSettingSwitchBinding…ate(layoutInflater, this)"); m.checkNotNullParameter(l3Var, "binding"); bVar = new b.d(l3Var); } else { i2 = 2131364865; } } throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i2))); } else { throw new NoWhenBranchMatchedException(); } this.k = bVar; if (viewType == ViewType.RADIO) { bVar.b().setOnClickListener(new a(0, this)); } else { bVar.b().setOnClickListener(new a(1, this)); } b bVar2 = this.k; if (bVar2 == null) { m.throwUninitializedPropertyAccessException("binding"); } ViewCompat.setAccessibilityDelegate(bVar2.b(), new d(this, viewType)); } public final void g(boolean z2, boolean z3) { if (!z3) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.c().setOnCheckedChangeListener(null); b bVar2 = this.k; if (bVar2 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar2.c().setChecked(z2); setOnCheckedListener(this.j); return; } b bVar3 = this.k; if (bVar3 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar3.c().setChecked(z2); } public final void h(CharSequence charSequence, boolean z2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.f().setText(charSequence); b bVar2 = this.k; if (bVar2 == null) { m.throwUninitializedPropertyAccessException("binding"); } TextView f2 = bVar2.f(); int i2 = 0; if (charSequence == null || charSequence.length() == 0) { i2 = 8; } f2.setVisibility(i2); if (z2) { b bVar3 = this.k; if (bVar3 == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar3.f().setMovementMethod(LinkMovementMethod.getInstance()); } } @Override // android.widget.Checkable public boolean isChecked() { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } return bVar.c().isChecked(); } @Override // android.view.View public void onRestoreInstanceState(Parcelable parcelable) { Parcelable parcelable2; m.checkNotNullParameter(parcelable, "state"); if (parcelable instanceof Bundle) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } Bundle bundle = (Bundle) parcelable; bVar.c().setChecked(bundle.getBoolean("STATE_CHECKED")); parcelable2 = bundle.getParcelable("STATE_SUPER"); } else { parcelable2 = null; } if (parcelable2 != null) { parcelable = parcelable2; } super.onRestoreInstanceState(parcelable); } @Override // android.view.View public Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable("STATE_SUPER", super.onSaveInstanceState()); bundle.putBoolean("STATE_CHECKED", isChecked()); return bundle; } public final void setButtonAlpha(float f2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.c().setAlpha(f2); } public final void setButtonVisibility(boolean z2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.c().setVisibility(z2 ? 0 : 8); } @Override // android.widget.Checkable public void setChecked(boolean z2) { g(z2, false); } public final void setLabelTagText(@StringRes int i2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.e().setText(i2); } public final void setLabelTagVisibility(boolean z2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.e().setVisibility(z2 ? 0 : 8); } public final void setOnCheckedListener(Action1 action1) { this.j = action1; b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.c().setOnCheckedChangeListener(new e(action1)); } public final void setSubtext(CharSequence charSequence) { h(charSequence, false); } public final void setSubtextColor(@ColorInt int i2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.f().setTextColor(i2); } public final void setSubtextOnClickListener(Action0 action0) { m.checkNotNullParameter(action0, "listener"); b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.f().setOnClickListener(new f(action0)); } public final void setText(CharSequence charSequence) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.a().setText(charSequence); } public final void setTextColor(@ColorInt int i2) { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } bVar.a().setTextColor(i2); } @Override // android.widget.Checkable public void toggle() { b bVar = this.k; if (bVar == null) { m.throwUninitializedPropertyAccessException("binding"); } g(!bVar.c().isChecked(), false); } }