package com.google.android.material.chip; import android.R; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Outline; import android.graphics.PorterDuff; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.RippleDrawable; import android.os.Build; import android.os.Bundle; import android.text.TextPaint; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.PointerIcon; import android.view.View; import android.view.ViewOutlineProvider; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.CompoundButton; import android.widget.TextView; import androidx.appcompat.widget.g; import androidx.core.view.n0; import androidx.recyclerview.widget.RecyclerView; import c3.h; import c3.i; import c3.j; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.material.chip.b; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.List; import m3.d; import m3.f; import p3.k; import p3.n; import z.a0; /* loaded from: classes2.dex */ public class Chip extends g implements b.a, n { /* renamed from: t, reason: collision with root package name */ private static final Rect f4399t = new Rect(); /* renamed from: u, reason: collision with root package name */ private static final int[] f4400u = {R.attr.state_selected}; /* renamed from: v, reason: collision with root package name */ private static final int[] f4401v = {R.attr.state_checkable}; /* renamed from: d, reason: collision with root package name */ private com.google.android.material.chip.b f4402d; /* renamed from: e, reason: collision with root package name */ private InsetDrawable f4403e; /* renamed from: f, reason: collision with root package name */ private RippleDrawable f4404f; /* renamed from: g, reason: collision with root package name */ private View.OnClickListener f4405g; /* renamed from: h, reason: collision with root package name */ private CompoundButton.OnCheckedChangeListener f4406h; /* renamed from: i, reason: collision with root package name */ private boolean f4407i; /* renamed from: j, reason: collision with root package name */ private boolean f4408j; /* renamed from: k, reason: collision with root package name */ private boolean f4409k; /* renamed from: l, reason: collision with root package name */ private boolean f4410l; /* renamed from: m, reason: collision with root package name */ private boolean f4411m; /* renamed from: n, reason: collision with root package name */ private int f4412n; /* renamed from: o, reason: collision with root package name */ private int f4413o; /* renamed from: p, reason: collision with root package name */ private final c f4414p; /* renamed from: q, reason: collision with root package name */ private final Rect f4415q; /* renamed from: r, reason: collision with root package name */ private final RectF f4416r; /* renamed from: s, reason: collision with root package name */ private final f f4417s; class a extends f { a() { } @Override // m3.f public void a(int i10) { } @Override // m3.f public void b(Typeface typeface, boolean z10) { Chip chip = Chip.this; chip.setText(chip.f4402d.y2() ? Chip.this.f4402d.W0() : Chip.this.getText()); Chip.this.requestLayout(); Chip.this.invalidate(); } } class b extends ViewOutlineProvider { b() { } @Override // android.view.ViewOutlineProvider public void getOutline(View view, Outline outline) { if (Chip.this.f4402d != null) { Chip.this.f4402d.getOutline(outline); } else { outline.setAlpha(0.0f); } } } private class c extends d0.a { c(Chip chip) { super(chip); } @Override // d0.a protected int B(float f10, float f11) { return (Chip.this.m() && Chip.this.getCloseIconTouchBounds().contains(f10, f11)) ? 1 : 0; } @Override // d0.a protected void C(List list) { list.add(0); if (Chip.this.m() && Chip.this.r()) { list.add(1); } } @Override // d0.a protected boolean J(int i10, int i11, Bundle bundle) { if (i11 != 16) { return false; } if (i10 == 0) { return Chip.this.performClick(); } if (i10 == 1) { return Chip.this.s(); } return false; } @Override // d0.a protected void M(a0 a0Var) { a0Var.U(Chip.this.q()); a0Var.X(Chip.this.isClickable()); if (Chip.this.q() || Chip.this.isClickable()) { a0Var.W(Chip.this.q() ? "android.widget.CompoundButton" : "android.widget.Button"); } else { a0Var.W("android.view.View"); } CharSequence text = Chip.this.getText(); if (Build.VERSION.SDK_INT >= 23) { a0Var.r0(text); } else { a0Var.a0(text); } } @Override // d0.a protected void N(int i10, a0 a0Var) { CharSequence charSequence = RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; if (i10 != 1) { a0Var.a0(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED); a0Var.S(Chip.f4399t); return; } CharSequence closeIconContentDescription = Chip.this.getCloseIconContentDescription(); if (closeIconContentDescription != null) { a0Var.a0(closeIconContentDescription); } else { CharSequence text = Chip.this.getText(); Context context = Chip.this.getContext(); int i11 = h.f3542g; Object[] objArr = new Object[1]; if (!TextUtils.isEmpty(text)) { charSequence = text; } objArr[0] = charSequence; a0Var.a0(context.getString(i11, objArr).trim()); } a0Var.S(Chip.this.getCloseIconTouchBoundsInt()); a0Var.b(a0.a.f15679i); a0Var.c0(Chip.this.isEnabled()); } @Override // d0.a protected void O(int i10, boolean z10) { if (i10 == 1) { Chip.this.f4410l = z10; Chip.this.refreshDrawableState(); } } } public Chip(Context context, AttributeSet attributeSet) { this(context, attributeSet, c3.a.f3448d); } private void A() { TextPaint paint = getPaint(); com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { paint.drawableState = bVar.getState(); } d textAppearance = getTextAppearance(); if (textAppearance != null) { textAppearance.i(getContext(), paint, this.f4417s); } } private void B(AttributeSet attributeSet) { if (attributeSet == null) { return; } if (attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "background") != null) { Log.w("Chip", "Do not set the background; Chip manages its own background drawable."); } if (attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "drawableLeft") != null) { throw new UnsupportedOperationException("Please set left drawable using R.attr#chipIcon."); } if (attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "drawableStart") != null) { throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon."); } if (attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "drawableEnd") != null) { throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } if (attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "drawableRight") != null) { throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } if (!attributeSet.getAttributeBooleanValue("http://schemas.android.com/apk/res/android", "singleLine", true) || attributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "lines", 1) != 1 || attributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "minLines", 1) != 1 || attributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "maxLines", 1) != 1) { throw new UnsupportedOperationException("Chip does not support multi-line text"); } if (attributeSet.getAttributeIntValue("http://schemas.android.com/apk/res/android", "gravity", 8388627) != 8388627) { Log.w("Chip", "Chip text must be vertically center and start aligned"); } } /* JADX INFO: Access modifiers changed from: private */ public RectF getCloseIconTouchBounds() { this.f4416r.setEmpty(); if (m()) { this.f4402d.P0(this.f4416r); } return this.f4416r; } /* JADX INFO: Access modifiers changed from: private */ public Rect getCloseIconTouchBoundsInt() { RectF closeIconTouchBounds = getCloseIconTouchBounds(); this.f4415q.set((int) closeIconTouchBounds.left, (int) closeIconTouchBounds.top, (int) closeIconTouchBounds.right, (int) closeIconTouchBounds.bottom); return this.f4415q; } private d getTextAppearance() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.X0(); } return null; } private void h(com.google.android.material.chip.b bVar) { bVar.c2(this); } /* JADX WARN: Type inference failed for: r0v0, types: [boolean, int] */ private int[] i() { ?? isEnabled = isEnabled(); int i10 = isEnabled; if (this.f4410l) { i10 = isEnabled + 1; } int i11 = i10; if (this.f4409k) { i11 = i10 + 1; } int i12 = i11; if (this.f4408j) { i12 = i11 + 1; } int i13 = i12; if (isChecked()) { i13 = i12 + 1; } int[] iArr = new int[i13]; int i14 = 0; if (isEnabled()) { iArr[0] = 16842910; i14 = 1; } if (this.f4410l) { iArr[i14] = 16842908; i14++; } if (this.f4409k) { iArr[i14] = 16843623; i14++; } if (this.f4408j) { iArr[i14] = 16842919; i14++; } if (isChecked()) { iArr[i14] = 16842913; } return iArr; } private void k() { if (getBackgroundDrawable() == this.f4403e && this.f4402d.getCallback() == null) { this.f4402d.setCallback(this.f4403e); } } private boolean l(MotionEvent motionEvent) { if (motionEvent.getAction() == 10) { try { Field declaredField = d0.a.class.getDeclaredField("m"); declaredField.setAccessible(true); if (((Integer) declaredField.get(this.f4414p)).intValue() != Integer.MIN_VALUE) { Method declaredMethod = d0.a.class.getDeclaredMethod("V", Integer.TYPE); declaredMethod.setAccessible(true); declaredMethod.invoke(this.f4414p, Integer.valueOf(RecyclerView.UNDEFINED_DURATION)); return true; } } catch (IllegalAccessException e10) { Log.e("Chip", "Unable to send Accessibility Exit event", e10); } catch (NoSuchFieldException e11) { Log.e("Chip", "Unable to send Accessibility Exit event", e11); } catch (NoSuchMethodException e12) { Log.e("Chip", "Unable to send Accessibility Exit event", e12); } catch (InvocationTargetException e13) { Log.e("Chip", "Unable to send Accessibility Exit event", e13); } } return false; } /* JADX INFO: Access modifiers changed from: private */ public boolean m() { com.google.android.material.chip.b bVar = this.f4402d; return (bVar == null || bVar.I0() == null) ? false : true; } private void n(Context context, AttributeSet attributeSet, int i10) { TypedArray k10 = com.google.android.material.internal.f.k(context, attributeSet, j.I, i10, i.f3557g, new int[0]); this.f4411m = k10.getBoolean(j.f3642n0, false); this.f4413o = (int) Math.ceil(k10.getDimension(j.f3570b0, (float) Math.ceil(com.google.android.material.internal.g.a(getContext(), 48)))); k10.recycle(); } private void o() { setOutlineProvider(new b()); } private void p(int i10, int i11, int i12, int i13) { this.f4403e = new InsetDrawable((Drawable) this.f4402d, i10, i11, i12, i13); } private void setCloseIconHovered(boolean z10) { if (this.f4409k != z10) { this.f4409k = z10; refreshDrawableState(); } } private void setCloseIconPressed(boolean z10) { if (this.f4408j != z10) { this.f4408j = z10; refreshDrawableState(); } } private void t() { if (this.f4403e != null) { this.f4403e = null; setMinWidth(0); setMinHeight((int) getChipMinHeight()); x(); } } private void v(com.google.android.material.chip.b bVar) { if (bVar != null) { bVar.c2(null); } } private void w() { if (Build.VERSION.SDK_INT >= 24) { return; } if (m() && r()) { n0.n0(this, this.f4414p); } else { n0.n0(this, null); } } private void x() { if (n3.b.f11961a) { y(); return; } this.f4402d.x2(true); n0.q0(this, getBackgroundDrawable()); k(); } private void y() { this.f4404f = new RippleDrawable(n3.b.a(this.f4402d.U0()), getBackgroundDrawable(), null); this.f4402d.x2(false); n0.q0(this, this.f4404f); } private void z() { com.google.android.material.chip.b bVar; if (TextUtils.isEmpty(getText()) || (bVar = this.f4402d) == null) { return; } n0.z0(this, (int) (this.f4402d.F0() + this.f4402d.Z0() + this.f4402d.e0()), getPaddingTop(), (int) (bVar.A0() + this.f4402d.Y0() + this.f4402d.i0()), getPaddingBottom()); } @Override // com.google.android.material.chip.b.a public void a() { j(this.f4413o); x(); z(); requestLayout(); invalidateOutline(); } @Override // android.view.View protected boolean dispatchHoverEvent(MotionEvent motionEvent) { return l(motionEvent) || this.f4414p.v(motionEvent) || super.dispatchHoverEvent(motionEvent); } @Override // android.view.View public boolean dispatchKeyEvent(KeyEvent keyEvent) { if (!this.f4414p.w(keyEvent) || this.f4414p.A() == Integer.MIN_VALUE) { return super.dispatchKeyEvent(keyEvent); } return true; } @Override // androidx.appcompat.widget.g, android.widget.CompoundButton, android.widget.TextView, android.view.View protected void drawableStateChanged() { super.drawableStateChanged(); com.google.android.material.chip.b bVar = this.f4402d; if ((bVar == null || !bVar.e1()) ? false : this.f4402d.Y1(i())) { invalidate(); } } public Drawable getBackgroundDrawable() { InsetDrawable insetDrawable = this.f4403e; return insetDrawable == null ? this.f4402d : insetDrawable; } public Drawable getCheckedIcon() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.x0(); } return null; } public ColorStateList getChipBackgroundColor() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.y0(); } return null; } public float getChipCornerRadius() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.z0(); } return 0.0f; } public Drawable getChipDrawable() { return this.f4402d; } public float getChipEndPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.A0(); } return 0.0f; } public Drawable getChipIcon() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.B0(); } return null; } public float getChipIconSize() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.C0(); } return 0.0f; } public ColorStateList getChipIconTint() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.D0(); } return null; } public float getChipMinHeight() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.E0(); } return 0.0f; } public float getChipStartPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.F0(); } return 0.0f; } public ColorStateList getChipStrokeColor() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.G0(); } return null; } public float getChipStrokeWidth() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.H0(); } return 0.0f; } @Deprecated public CharSequence getChipText() { return getText(); } public Drawable getCloseIcon() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.I0(); } return null; } public CharSequence getCloseIconContentDescription() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.J0(); } return null; } public float getCloseIconEndPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.K0(); } return 0.0f; } public float getCloseIconSize() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.L0(); } return 0.0f; } public float getCloseIconStartPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.M0(); } return 0.0f; } public ColorStateList getCloseIconTint() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.O0(); } return null; } @Override // android.widget.TextView public TextUtils.TruncateAt getEllipsize() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.Q0(); } return null; } @Override // android.widget.TextView, android.view.View public void getFocusedRect(Rect rect) { if (this.f4414p.A() == 1 || this.f4414p.x() == 1) { rect.set(getCloseIconTouchBoundsInt()); } else { super.getFocusedRect(rect); } } public d3.c getHideMotionSpec() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.R0(); } return null; } public float getIconEndPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.S0(); } return 0.0f; } public float getIconStartPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.T0(); } return 0.0f; } public ColorStateList getRippleColor() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.U0(); } return null; } public k getShapeAppearanceModel() { return this.f4402d.A(); } public d3.c getShowMotionSpec() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.V0(); } return null; } public float getTextEndPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.Y0(); } return 0.0f; } public float getTextStartPadding() { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { return bVar.Z0(); } return 0.0f; } public boolean j(int i10) { this.f4413o = i10; if (!u()) { t(); return false; } int max = Math.max(0, i10 - this.f4402d.getIntrinsicHeight()); int max2 = Math.max(0, i10 - this.f4402d.getIntrinsicWidth()); if (max2 <= 0 && max <= 0) { t(); return false; } int i11 = max2 > 0 ? max2 / 2 : 0; int i12 = max > 0 ? max / 2 : 0; if (this.f4403e != null) { Rect rect = new Rect(); this.f4403e.getPadding(rect); if (rect.top == i12 && rect.bottom == i12 && rect.left == i11 && rect.right == i11) { return true; } } if (getMinHeight() != i10) { setMinHeight(i10); } if (getMinWidth() != i10) { setMinWidth(i10); } p(i11, i12, i11, i12); return true; } @Override // android.widget.TextView, android.view.View protected void onAttachedToWindow() { super.onAttachedToWindow(); p3.h.f(this, this.f4402d); } @Override // android.widget.CompoundButton, android.widget.TextView, android.view.View protected int[] onCreateDrawableState(int i10) { int[] onCreateDrawableState = super.onCreateDrawableState(i10 + 2); if (isChecked()) { View.mergeDrawableStates(onCreateDrawableState, f4400u); } if (q()) { View.mergeDrawableStates(onCreateDrawableState, f4401v); } return onCreateDrawableState; } @Override // android.widget.TextView, android.view.View protected void onFocusChanged(boolean z10, int i10, Rect rect) { super.onFocusChanged(z10, i10, rect); this.f4414p.I(z10, i10, rect); } @Override // android.view.View public boolean onHoverEvent(MotionEvent motionEvent) { int actionMasked = motionEvent.getActionMasked(); if (actionMasked == 7) { setCloseIconHovered(getCloseIconTouchBounds().contains(motionEvent.getX(), motionEvent.getY())); } else if (actionMasked == 10) { setCloseIconHovered(false); } return super.onHoverEvent(motionEvent); } @Override // android.view.View public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo); if (q() || isClickable()) { accessibilityNodeInfo.setClassName(q() ? "android.widget.CompoundButton" : "android.widget.Button"); } else { accessibilityNodeInfo.setClassName("android.view.View"); } accessibilityNodeInfo.setCheckable(q()); accessibilityNodeInfo.setClickable(isClickable()); } @Override // android.widget.Button, android.widget.TextView, android.view.View public PointerIcon onResolvePointerIcon(MotionEvent motionEvent, int i10) { PointerIcon systemIcon; if (!getCloseIconTouchBounds().contains(motionEvent.getX(), motionEvent.getY()) || !isEnabled()) { return null; } systemIcon = PointerIcon.getSystemIcon(getContext(), 1002); return systemIcon; } @Override // android.widget.TextView, android.view.View public void onRtlPropertiesChanged(int i10) { super.onRtlPropertiesChanged(i10); if (this.f4412n != i10) { this.f4412n = i10; z(); } } /* JADX WARN: Code restructure failed: missing block: B:7:0x001e, code lost: if (r0 != 3) goto L22; */ @Override // android.widget.TextView, android.view.View /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public boolean onTouchEvent(android.view.MotionEvent r6) { /* r5 = this; int r0 = r6.getActionMasked() android.graphics.RectF r1 = r5.getCloseIconTouchBounds() float r2 = r6.getX() float r3 = r6.getY() boolean r1 = r1.contains(r2, r3) r2 = 1 r3 = 0 if (r0 == 0) goto L39 if (r0 == r2) goto L2b r4 = 2 if (r0 == r4) goto L21 r1 = 3 if (r0 == r1) goto L34 goto L40 L21: boolean r0 = r5.f4408j if (r0 == 0) goto L40 if (r1 != 0) goto L3e r5.setCloseIconPressed(r3) goto L3e L2b: boolean r0 = r5.f4408j if (r0 == 0) goto L34 r5.s() r0 = 1 goto L35 L34: r0 = 0 L35: r5.setCloseIconPressed(r3) goto L41 L39: if (r1 == 0) goto L40 r5.setCloseIconPressed(r2) L3e: r0 = 1 goto L41 L40: r0 = 0 L41: if (r0 != 0) goto L4b boolean r6 = super.onTouchEvent(r6) if (r6 == 0) goto L4a goto L4b L4a: r2 = 0 L4b: return r2 */ throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.chip.Chip.onTouchEvent(android.view.MotionEvent):boolean"); } public boolean q() { com.google.android.material.chip.b bVar = this.f4402d; return bVar != null && bVar.d1(); } public boolean r() { com.google.android.material.chip.b bVar = this.f4402d; return bVar != null && bVar.f1(); } public boolean s() { boolean z10 = false; playSoundEffect(0); View.OnClickListener onClickListener = this.f4405g; if (onClickListener != null) { onClickListener.onClick(this); z10 = true; } this.f4414p.U(1, 1); return z10; } @Override // android.view.View public void setBackground(Drawable drawable) { if (drawable == getBackgroundDrawable() || drawable == this.f4404f) { super.setBackground(drawable); } else { Log.w("Chip", "Do not set the background; Chip manages its own background drawable."); } } @Override // android.view.View public void setBackgroundColor(int i10) { Log.w("Chip", "Do not set the background color; Chip manages its own background drawable."); } @Override // androidx.appcompat.widget.g, android.view.View public void setBackgroundDrawable(Drawable drawable) { if (drawable == getBackgroundDrawable() || drawable == this.f4404f) { super.setBackgroundDrawable(drawable); } else { Log.w("Chip", "Do not set the background drawable; Chip manages its own background drawable."); } } @Override // androidx.appcompat.widget.g, android.view.View public void setBackgroundResource(int i10) { Log.w("Chip", "Do not set the background resource; Chip manages its own background drawable."); } @Override // android.view.View public void setBackgroundTintList(ColorStateList colorStateList) { Log.w("Chip", "Do not set the background tint list; Chip manages its own background drawable."); } @Override // android.view.View public void setBackgroundTintMode(PorterDuff.Mode mode) { Log.w("Chip", "Do not set the background tint mode; Chip manages its own background drawable."); } public void setCheckable(boolean z10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.m1(z10); } } public void setCheckableResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.n1(i10); } } @Override // android.widget.CompoundButton, android.widget.Checkable public void setChecked(boolean z10) { CompoundButton.OnCheckedChangeListener onCheckedChangeListener; com.google.android.material.chip.b bVar = this.f4402d; if (bVar == null) { this.f4407i = z10; return; } if (bVar.d1()) { boolean isChecked = isChecked(); super.setChecked(z10); if (isChecked == z10 || (onCheckedChangeListener = this.f4406h) == null) { return; } onCheckedChangeListener.onCheckedChanged(this, z10); } } public void setCheckedIcon(Drawable drawable) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.o1(drawable); } } @Deprecated public void setCheckedIconEnabled(boolean z10) { setCheckedIconVisible(z10); } @Deprecated public void setCheckedIconEnabledResource(int i10) { setCheckedIconVisible(i10); } public void setCheckedIconResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.p1(i10); } } public void setCheckedIconVisible(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.q1(i10); } } public void setChipBackgroundColor(ColorStateList colorStateList) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.s1(colorStateList); } } public void setChipBackgroundColorResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.t1(i10); } } @Deprecated public void setChipCornerRadius(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.u1(f10); } } @Deprecated public void setChipCornerRadiusResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.v1(i10); } } public void setChipDrawable(com.google.android.material.chip.b bVar) { com.google.android.material.chip.b bVar2 = this.f4402d; if (bVar2 != bVar) { v(bVar2); this.f4402d = bVar; bVar.n2(false); h(this.f4402d); j(this.f4413o); x(); } } public void setChipEndPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.w1(f10); } } public void setChipEndPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.x1(i10); } } public void setChipIcon(Drawable drawable) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.y1(drawable); } } @Deprecated public void setChipIconEnabled(boolean z10) { setChipIconVisible(z10); } @Deprecated public void setChipIconEnabledResource(int i10) { setChipIconVisible(i10); } public void setChipIconResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.z1(i10); } } public void setChipIconSize(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.A1(f10); } } public void setChipIconSizeResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.B1(i10); } } public void setChipIconTint(ColorStateList colorStateList) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.C1(colorStateList); } } public void setChipIconTintResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.D1(i10); } } public void setChipIconVisible(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.E1(i10); } } public void setChipMinHeight(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.G1(f10); } } public void setChipMinHeightResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.H1(i10); } } public void setChipStartPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.I1(f10); } } public void setChipStartPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.J1(i10); } } public void setChipStrokeColor(ColorStateList colorStateList) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.K1(colorStateList); } } public void setChipStrokeColorResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.L1(i10); } } public void setChipStrokeWidth(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.M1(f10); } } public void setChipStrokeWidthResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.N1(i10); } } @Deprecated public void setChipText(CharSequence charSequence) { setText(charSequence); } @Deprecated public void setChipTextResource(int i10) { setText(getResources().getString(i10)); } public void setCloseIcon(Drawable drawable) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.P1(drawable); } w(); } public void setCloseIconContentDescription(CharSequence charSequence) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.Q1(charSequence); } } @Deprecated public void setCloseIconEnabled(boolean z10) { setCloseIconVisible(z10); } @Deprecated public void setCloseIconEnabledResource(int i10) { setCloseIconVisible(i10); } public void setCloseIconEndPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.R1(f10); } } public void setCloseIconEndPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.S1(i10); } } public void setCloseIconResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.T1(i10); } w(); } public void setCloseIconSize(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.U1(f10); } } public void setCloseIconSizeResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.V1(i10); } } public void setCloseIconStartPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.W1(f10); } } public void setCloseIconStartPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.X1(i10); } } public void setCloseIconTint(ColorStateList colorStateList) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.Z1(colorStateList); } } public void setCloseIconTintResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.a2(i10); } } public void setCloseIconVisible(int i10) { setCloseIconVisible(getResources().getBoolean(i10)); } @Override // android.widget.TextView public void setCompoundDrawables(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { if (drawable != null) { throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon."); } if (drawable3 != null) { throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } super.setCompoundDrawables(drawable, drawable2, drawable3, drawable4); } @Override // android.widget.TextView public void setCompoundDrawablesRelative(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { if (drawable != null) { throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon."); } if (drawable3 != null) { throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } super.setCompoundDrawablesRelative(drawable, drawable2, drawable3, drawable4); } @Override // android.widget.TextView public void setCompoundDrawablesRelativeWithIntrinsicBounds(int i10, int i11, int i12, int i13) { if (i10 != 0) { throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon."); } if (i12 != 0) { throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } super.setCompoundDrawablesRelativeWithIntrinsicBounds(i10, i11, i12, i13); } @Override // android.widget.TextView public void setCompoundDrawablesWithIntrinsicBounds(int i10, int i11, int i12, int i13) { if (i10 != 0) { throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon."); } if (i12 != 0) { throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } super.setCompoundDrawablesWithIntrinsicBounds(i10, i11, i12, i13); } @Override // android.view.View public void setElevation(float f10) { super.setElevation(f10); com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.Q(f10); } } @Override // android.widget.TextView public void setEllipsize(TextUtils.TruncateAt truncateAt) { if (this.f4402d == null) { return; } if (truncateAt == TextUtils.TruncateAt.MARQUEE) { throw new UnsupportedOperationException("Text within a chip are not allowed to scroll."); } super.setEllipsize(truncateAt); com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.d2(truncateAt); } } public void setEnsureMinTouchTargetSize(boolean z10) { this.f4411m = z10; j(this.f4413o); } @Override // android.widget.TextView public void setGravity(int i10) { if (i10 != 8388627) { Log.w("Chip", "Chip text must be vertically center and start aligned"); } else { super.setGravity(i10); } } public void setHideMotionSpec(d3.c cVar) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.e2(cVar); } } public void setHideMotionSpecResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.f2(i10); } } public void setIconEndPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.g2(f10); } } public void setIconEndPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.h2(i10); } } public void setIconStartPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.i2(f10); } } public void setIconStartPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.j2(i10); } } @Override // android.view.View public void setLayoutDirection(int i10) { if (this.f4402d == null) { return; } super.setLayoutDirection(i10); } @Override // android.widget.TextView public void setLines(int i10) { if (i10 > 1) { throw new UnsupportedOperationException("Chip does not support multi-line text"); } super.setLines(i10); } @Override // android.widget.TextView public void setMaxLines(int i10) { if (i10 > 1) { throw new UnsupportedOperationException("Chip does not support multi-line text"); } super.setMaxLines(i10); } @Override // android.widget.TextView public void setMaxWidth(int i10) { super.setMaxWidth(i10); com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.k2(i10); } } @Override // android.widget.TextView public void setMinLines(int i10) { if (i10 > 1) { throw new UnsupportedOperationException("Chip does not support multi-line text"); } super.setMinLines(i10); } void setOnCheckedChangeListenerInternal(CompoundButton.OnCheckedChangeListener onCheckedChangeListener) { this.f4406h = onCheckedChangeListener; } public void setOnCloseIconClickListener(View.OnClickListener onClickListener) { this.f4405g = onClickListener; } public void setRippleColor(ColorStateList colorStateList) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.l2(colorStateList); } if (this.f4402d.b1()) { return; } y(); } public void setRippleColorResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.m2(i10); if (this.f4402d.b1()) { return; } y(); } } @Override // p3.n public void setShapeAppearanceModel(k kVar) { this.f4402d.setShapeAppearanceModel(kVar); } public void setShowMotionSpec(d3.c cVar) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.o2(cVar); } } public void setShowMotionSpecResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.p2(i10); } } @Override // android.widget.TextView public void setSingleLine(boolean z10) { if (!z10) { throw new UnsupportedOperationException("Chip does not support multi-line text"); } super.setSingleLine(z10); } @Override // android.widget.TextView public void setText(CharSequence charSequence, TextView.BufferType bufferType) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar == null) { return; } if (charSequence == null) { charSequence = RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED; } super.setText(bVar.y2() ? null : charSequence, bufferType); com.google.android.material.chip.b bVar2 = this.f4402d; if (bVar2 != null) { bVar2.q2(charSequence); } } public void setTextAppearance(d dVar) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.r2(dVar); } A(); } public void setTextAppearanceResource(int i10) { setTextAppearance(getContext(), i10); } public void setTextEndPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.t2(f10); } } public void setTextEndPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.u2(i10); } } public void setTextStartPadding(float f10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.v2(f10); } } public void setTextStartPaddingResource(int i10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.w2(i10); } } public boolean u() { return this.f4411m; } public Chip(Context context, AttributeSet attributeSet, int i10) { super(context, attributeSet, i10); this.f4415q = new Rect(); this.f4416r = new RectF(); this.f4417s = new a(); B(attributeSet); int i11 = i.f3557g; com.google.android.material.chip.b n02 = com.google.android.material.chip.b.n0(context, attributeSet, i10, i11); n(context, attributeSet, i10); setChipDrawable(n02); n02.Q(n0.v(this)); TypedArray k10 = com.google.android.material.internal.f.k(context, attributeSet, j.I, i10, i11, new int[0]); int i12 = Build.VERSION.SDK_INT; if (i12 < 23) { setTextColor(m3.c.a(context, k10, j.K)); } boolean hasValue = k10.hasValue(j.f3671s0); k10.recycle(); c cVar = new c(this); this.f4414p = cVar; if (i12 >= 24) { n0.n0(this, cVar); } else { w(); } if (!hasValue) { o(); } setChecked(this.f4407i); setText(n02.W0()); setEllipsize(n02.Q0()); setIncludeFontPadding(false); A(); if (!this.f4402d.y2()) { setSingleLine(); } setGravity(8388627); z(); if (u()) { setMinHeight(this.f4413o); } this.f4412n = n0.B(this); } public void setCloseIconVisible(boolean z10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.b2(z10); } w(); } public void setCheckedIconVisible(boolean z10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.r1(z10); } } public void setChipIconVisible(boolean z10) { com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.F1(z10); } } @Override // android.widget.TextView public void setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { if (drawable != null) { throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon."); } if (drawable3 == null) { super.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4); return; } throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon."); } @Override // android.widget.TextView public void setCompoundDrawablesWithIntrinsicBounds(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) { if (drawable != null) { throw new UnsupportedOperationException("Please set left drawable using R.attr#chipIcon."); } if (drawable3 == null) { super.setCompoundDrawablesWithIntrinsicBounds(drawable, drawable2, drawable3, drawable4); return; } throw new UnsupportedOperationException("Please set right drawable using R.attr#closeIcon."); } @Override // android.widget.TextView public void setTextAppearance(Context context, int i10) { super.setTextAppearance(context, i10); com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.s2(i10); } A(); } @Override // android.widget.TextView public void setTextAppearance(int i10) { super.setTextAppearance(i10); com.google.android.material.chip.b bVar = this.f4402d; if (bVar != null) { bVar.s2(i10); } A(); } }