Rabbit-R1/android (non root)/java/sources/com/google/android/material/textfield/TextInputLayout.java
2024-05-21 17:08:36 -04:00

2492 lines
98 KiB
Java

package com.google.android.material.textfield;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStructure;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatDrawableManager;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.DrawableUtils;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.text.BidiFormatter;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.MarginLayoutParamsCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.widget.TextViewCompat;
import androidx.customview.view.AbsSavedState;
import androidx.transition.Fade;
import androidx.transition.TransitionManager;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.internal.CheckableImageButton;
import com.google.android.material.internal.CollapsingTextHelper;
import com.google.android.material.internal.DescendantOffsetUtils;
import com.google.android.material.internal.ViewUtils;
import com.google.android.material.motion.MotionUtils;
import com.google.android.material.resources.MaterialResources;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Iterator;
import java.util.LinkedHashSet;
/* loaded from: classes2.dex */
public class TextInputLayout extends LinearLayout implements ViewTreeObserver.OnGlobalLayoutListener {
public static final int BOX_BACKGROUND_FILLED = 1;
public static final int BOX_BACKGROUND_NONE = 0;
public static final int BOX_BACKGROUND_OUTLINE = 2;
private static final int DEFAULT_PLACEHOLDER_FADE_DURATION = 87;
private static final int DEF_STYLE_RES = R.style.Widget_Design_TextInputLayout;
private static final int[][] EDIT_TEXT_BACKGROUND_RIPPLE_STATE = {new int[]{android.R.attr.state_pressed}, new int[0]};
public static final int END_ICON_CLEAR_TEXT = 2;
public static final int END_ICON_CUSTOM = -1;
public static final int END_ICON_DROPDOWN_MENU = 3;
public static final int END_ICON_NONE = 0;
public static final int END_ICON_PASSWORD_TOGGLE = 1;
private static final int INVALID_MAX_LENGTH = -1;
private static final int LABEL_SCALE_ANIMATION_DURATION = 167;
private static final String LOG_TAG = "TextInputLayout";
private static final int NO_WIDTH = -1;
private static final int PLACEHOLDER_START_DELAY = 67;
private ValueAnimator animator;
private boolean areCornerRadiiRtl;
private MaterialShapeDrawable boxBackground;
private boolean boxBackgroundApplied;
private int boxBackgroundColor;
private int boxBackgroundMode;
private int boxCollapsedPaddingTopPx;
private final int boxLabelCutoutPaddingPx;
private int boxStrokeColor;
private int boxStrokeWidthDefaultPx;
private int boxStrokeWidthFocusedPx;
private int boxStrokeWidthPx;
private MaterialShapeDrawable boxUnderlineDefault;
private MaterialShapeDrawable boxUnderlineFocused;
final CollapsingTextHelper collapsingTextHelper;
boolean counterEnabled;
private int counterMaxLength;
private int counterOverflowTextAppearance;
private ColorStateList counterOverflowTextColor;
private boolean counterOverflowed;
private int counterTextAppearance;
private ColorStateList counterTextColor;
private TextView counterView;
private ColorStateList cursorColor;
private ColorStateList cursorErrorColor;
private int defaultFilledBackgroundColor;
private ColorStateList defaultHintTextColor;
private int defaultStrokeColor;
private int disabledColor;
private int disabledFilledBackgroundColor;
EditText editText;
private final LinkedHashSet<OnEditTextAttachedListener> editTextAttachedListeners;
private Drawable endDummyDrawable;
private int endDummyDrawableWidth;
private final EndCompoundLayout endLayout;
private boolean expandedHintEnabled;
private StateListDrawable filledDropDownMenuBackground;
private int focusedFilledBackgroundColor;
private int focusedStrokeColor;
private ColorStateList focusedTextColor;
private boolean globalLayoutListenerAdded;
private CharSequence hint;
private boolean hintAnimationEnabled;
private boolean hintEnabled;
private boolean hintExpanded;
private int hoveredFilledBackgroundColor;
private int hoveredStrokeColor;
private boolean inDrawableStateChanged;
private final IndicatorViewController indicatorViewController;
private final FrameLayout inputFrame;
private boolean isProvidingHint;
private LengthCounter lengthCounter;
private int maxEms;
private int maxWidth;
private int minEms;
private int minWidth;
private Drawable originalEditTextEndDrawable;
private CharSequence originalHint;
private MaterialShapeDrawable outlinedDropDownMenuBackground;
private boolean placeholderEnabled;
private Fade placeholderFadeIn;
private Fade placeholderFadeOut;
private CharSequence placeholderText;
private int placeholderTextAppearance;
private ColorStateList placeholderTextColor;
private TextView placeholderTextView;
private boolean restoringSavedState;
private ShapeAppearanceModel shapeAppearanceModel;
private Drawable startDummyDrawable;
private int startDummyDrawableWidth;
private final StartCompoundLayout startLayout;
private ColorStateList strokeErrorColor;
private final Rect tmpBoundsRect;
private final Rect tmpRect;
private final RectF tmpRectF;
private Typeface typeface;
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes2.dex */
public @interface BoxBackgroundMode {
}
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes2.dex */
public @interface EndIconMode {
}
/* loaded from: classes2.dex */
public interface LengthCounter {
int countLength(Editable editable);
}
/* loaded from: classes2.dex */
public interface OnEditTextAttachedListener {
void onEditTextAttached(TextInputLayout textInputLayout);
}
/* loaded from: classes2.dex */
public interface OnEndIconChangedListener {
void onEndIconChanged(TextInputLayout textInputLayout, int i);
}
private boolean canDrawStroke() {
return this.boxStrokeWidthPx > -1 && this.boxStrokeColor != 0;
}
public int getBoxBackgroundColor() {
return this.boxBackgroundColor;
}
public int getBoxBackgroundMode() {
return this.boxBackgroundMode;
}
public int getBoxCollapsedPaddingTop() {
return this.boxCollapsedPaddingTopPx;
}
public int getBoxStrokeColor() {
return this.focusedStrokeColor;
}
public ColorStateList getBoxStrokeErrorColor() {
return this.strokeErrorColor;
}
public int getBoxStrokeWidth() {
return this.boxStrokeWidthDefaultPx;
}
public int getBoxStrokeWidthFocused() {
return this.boxStrokeWidthFocusedPx;
}
public int getCounterMaxLength() {
return this.counterMaxLength;
}
public ColorStateList getCounterOverflowTextColor() {
return this.counterOverflowTextColor;
}
public ColorStateList getCounterTextColor() {
return this.counterTextColor;
}
public ColorStateList getCursorColor() {
return this.cursorColor;
}
public ColorStateList getCursorErrorColor() {
return this.cursorErrorColor;
}
public ColorStateList getDefaultHintTextColor() {
return this.defaultHintTextColor;
}
public EditText getEditText() {
return this.editText;
}
public CharSequence getHint() {
if (this.hintEnabled) {
return this.hint;
}
return null;
}
public ColorStateList getHintTextColor() {
return this.focusedTextColor;
}
public LengthCounter getLengthCounter() {
return this.lengthCounter;
}
public int getMaxEms() {
return this.maxEms;
}
public int getMaxWidth() {
return this.maxWidth;
}
public int getMinEms() {
return this.minEms;
}
public int getMinWidth() {
return this.minWidth;
}
public CharSequence getPlaceholderText() {
if (this.placeholderEnabled) {
return this.placeholderText;
}
return null;
}
public int getPlaceholderTextAppearance() {
return this.placeholderTextAppearance;
}
public ColorStateList getPlaceholderTextColor() {
return this.placeholderTextColor;
}
public ShapeAppearanceModel getShapeAppearanceModel() {
return this.shapeAppearanceModel;
}
public Typeface getTypeface() {
return this.typeface;
}
public boolean isCounterEnabled() {
return this.counterEnabled;
}
public boolean isExpandedHintEnabled() {
return this.expandedHintEnabled;
}
public boolean isHintAnimationEnabled() {
return this.hintAnimationEnabled;
}
public boolean isHintEnabled() {
return this.hintEnabled;
}
final boolean isHintExpanded() {
return this.hintExpanded;
}
public boolean isProvidingHint() {
return this.isProvidingHint;
}
public void setBoxCollapsedPaddingTop(int i) {
this.boxCollapsedPaddingTopPx = i;
}
public void setHintAnimationEnabled(boolean z) {
this.hintAnimationEnabled = z;
}
public void setLengthCounter(LengthCounter lengthCounter) {
this.lengthCounter = lengthCounter;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ int lambda$new$0(Editable editable) {
if (editable != null) {
return editable.length();
}
return 0;
}
public TextInputLayout(Context context) {
this(context, null);
}
public TextInputLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.textInputStyle);
}
/* JADX WARN: Illegal instructions before constructor call */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public TextInputLayout(android.content.Context r17, android.util.AttributeSet r18, int r19) {
/*
Method dump skipped, instructions count: 882
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.textfield.TextInputLayout.<init>(android.content.Context, android.util.AttributeSet, int):void");
}
@Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
public void onGlobalLayout() {
this.endLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
this.globalLayoutListenerAdded = false;
boolean updateEditTextHeightBasedOnIcon = updateEditTextHeightBasedOnIcon();
boolean updateDummyDrawables = updateDummyDrawables();
if (updateEditTextHeightBasedOnIcon || updateDummyDrawables) {
this.editText.post(new Runnable() { // from class: com.google.android.material.textfield.TextInputLayout$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
TextInputLayout.this.m5569xa47602b9();
}
});
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: lambda$onGlobalLayout$1$com-google-android-material-textfield-TextInputLayout, reason: not valid java name */
public /* synthetic */ void m5569xa47602b9() {
this.editText.requestLayout();
}
@Override // android.view.ViewGroup
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
if (view instanceof EditText) {
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(layoutParams);
layoutParams2.gravity = (layoutParams2.gravity & (-113)) | 16;
this.inputFrame.addView(view, layoutParams2);
this.inputFrame.setLayoutParams(layoutParams);
updateInputLayoutMargins();
setEditText((EditText) view);
return;
}
super.addView(view, i, layoutParams);
}
MaterialShapeDrawable getBoxBackground() {
int i = this.boxBackgroundMode;
if (i == 1 || i == 2) {
return this.boxBackground;
}
throw new IllegalStateException();
}
public void setBoxBackgroundMode(int i) {
if (i == this.boxBackgroundMode) {
return;
}
this.boxBackgroundMode = i;
if (this.editText != null) {
onApplyBoxBackgroundMode();
}
}
private void onApplyBoxBackgroundMode() {
assignBoxBackgroundByMode();
updateEditTextBoxBackgroundIfNeeded();
updateTextInputBoxState();
updateBoxCollapsedPaddingTop();
adjustFilledEditTextPaddingForLargeFont();
if (this.boxBackgroundMode != 0) {
updateInputLayoutMargins();
}
setDropDownMenuBackgroundIfNeeded();
}
private void assignBoxBackgroundByMode() {
int i = this.boxBackgroundMode;
if (i == 0) {
this.boxBackground = null;
this.boxUnderlineDefault = null;
this.boxUnderlineFocused = null;
} else if (i == 1) {
this.boxBackground = new MaterialShapeDrawable(this.shapeAppearanceModel);
this.boxUnderlineDefault = new MaterialShapeDrawable();
this.boxUnderlineFocused = new MaterialShapeDrawable();
} else {
if (i == 2) {
if (this.hintEnabled && !(this.boxBackground instanceof CutoutDrawable)) {
this.boxBackground = CutoutDrawable.create(this.shapeAppearanceModel);
} else {
this.boxBackground = new MaterialShapeDrawable(this.shapeAppearanceModel);
}
this.boxUnderlineDefault = null;
this.boxUnderlineFocused = null;
return;
}
throw new IllegalArgumentException(this.boxBackgroundMode + " is illegal; only @BoxBackgroundMode constants are supported.");
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void updateEditTextBoxBackgroundIfNeeded() {
EditText editText = this.editText;
if (editText == null || this.boxBackground == null) {
return;
}
if ((this.boxBackgroundApplied || editText.getBackground() == null) && this.boxBackgroundMode != 0) {
updateEditTextBoxBackground();
this.boxBackgroundApplied = true;
}
}
private void updateEditTextBoxBackground() {
ViewCompat.setBackground(this.editText, getEditTextBoxBackground());
}
private Drawable getEditTextBoxBackground() {
EditText editText = this.editText;
if (!(editText instanceof AutoCompleteTextView) || EditTextUtils.isEditable(editText)) {
return this.boxBackground;
}
int color = MaterialColors.getColor(this.editText, R.attr.colorControlHighlight);
int i = this.boxBackgroundMode;
if (i == 2) {
return getOutlinedBoxBackgroundWithRipple(getContext(), this.boxBackground, color, EDIT_TEXT_BACKGROUND_RIPPLE_STATE);
}
if (i == 1) {
return getFilledBoxBackgroundWithRipple(this.boxBackground, this.boxBackgroundColor, color, EDIT_TEXT_BACKGROUND_RIPPLE_STATE);
}
return null;
}
private static Drawable getOutlinedBoxBackgroundWithRipple(Context context, MaterialShapeDrawable materialShapeDrawable, int i, int[][] iArr) {
int color = MaterialColors.getColor(context, R.attr.colorSurface, LOG_TAG);
MaterialShapeDrawable materialShapeDrawable2 = new MaterialShapeDrawable(materialShapeDrawable.getShapeAppearanceModel());
int layer = MaterialColors.layer(i, color, 0.1f);
materialShapeDrawable2.setFillColor(new ColorStateList(iArr, new int[]{layer, 0}));
materialShapeDrawable2.setTint(color);
ColorStateList colorStateList = new ColorStateList(iArr, new int[]{layer, color});
MaterialShapeDrawable materialShapeDrawable3 = new MaterialShapeDrawable(materialShapeDrawable.getShapeAppearanceModel());
materialShapeDrawable3.setTint(-1);
return new LayerDrawable(new Drawable[]{new RippleDrawable(colorStateList, materialShapeDrawable2, materialShapeDrawable3), materialShapeDrawable});
}
private static Drawable getFilledBoxBackgroundWithRipple(MaterialShapeDrawable materialShapeDrawable, int i, int i2, int[][] iArr) {
return new RippleDrawable(new ColorStateList(iArr, new int[]{MaterialColors.layer(i2, i, 0.1f), i}), materialShapeDrawable, materialShapeDrawable);
}
private void setDropDownMenuBackgroundIfNeeded() {
EditText editText = this.editText;
if (editText instanceof AutoCompleteTextView) {
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) editText;
if (autoCompleteTextView.getDropDownBackground() == null) {
int i = this.boxBackgroundMode;
if (i == 2) {
autoCompleteTextView.setDropDownBackgroundDrawable(getOrCreateOutlinedDropDownMenuBackground());
} else if (i == 1) {
autoCompleteTextView.setDropDownBackgroundDrawable(getOrCreateFilledDropDownMenuBackground());
}
}
}
}
private Drawable getOrCreateOutlinedDropDownMenuBackground() {
if (this.outlinedDropDownMenuBackground == null) {
this.outlinedDropDownMenuBackground = getDropDownMaterialShapeDrawable(true);
}
return this.outlinedDropDownMenuBackground;
}
private Drawable getOrCreateFilledDropDownMenuBackground() {
if (this.filledDropDownMenuBackground == null) {
StateListDrawable stateListDrawable = new StateListDrawable();
this.filledDropDownMenuBackground = stateListDrawable;
stateListDrawable.addState(new int[]{android.R.attr.state_above_anchor}, getOrCreateOutlinedDropDownMenuBackground());
this.filledDropDownMenuBackground.addState(new int[0], getDropDownMaterialShapeDrawable(false));
}
return this.filledDropDownMenuBackground;
}
private MaterialShapeDrawable getDropDownMaterialShapeDrawable(boolean z) {
float dimensionPixelOffset;
float dimensionPixelOffset2 = getResources().getDimensionPixelOffset(R.dimen.mtrl_shape_corner_size_small_component);
float f = z ? dimensionPixelOffset2 : 0.0f;
EditText editText = this.editText;
if (editText instanceof MaterialAutoCompleteTextView) {
dimensionPixelOffset = ((MaterialAutoCompleteTextView) editText).getPopupElevation();
} else {
dimensionPixelOffset = getResources().getDimensionPixelOffset(R.dimen.m3_comp_outlined_autocomplete_menu_container_elevation);
}
int dimensionPixelOffset3 = getResources().getDimensionPixelOffset(R.dimen.mtrl_exposed_dropdown_menu_popup_vertical_padding);
ShapeAppearanceModel build = ShapeAppearanceModel.builder().setTopLeftCornerSize(f).setTopRightCornerSize(f).setBottomLeftCornerSize(dimensionPixelOffset2).setBottomRightCornerSize(dimensionPixelOffset2).build();
EditText editText2 = this.editText;
MaterialShapeDrawable createWithElevationOverlay = MaterialShapeDrawable.createWithElevationOverlay(getContext(), dimensionPixelOffset, editText2 instanceof MaterialAutoCompleteTextView ? ((MaterialAutoCompleteTextView) editText2).getDropDownBackgroundTintList() : null);
createWithElevationOverlay.setShapeAppearanceModel(build);
createWithElevationOverlay.setPadding(0, dimensionPixelOffset3, 0, dimensionPixelOffset3);
return createWithElevationOverlay;
}
private void updateBoxCollapsedPaddingTop() {
if (this.boxBackgroundMode == 1) {
if (MaterialResources.isFontScaleAtLeast2_0(getContext())) {
this.boxCollapsedPaddingTopPx = getResources().getDimensionPixelSize(R.dimen.material_font_2_0_box_collapsed_padding_top);
} else if (MaterialResources.isFontScaleAtLeast1_3(getContext())) {
this.boxCollapsedPaddingTopPx = getResources().getDimensionPixelSize(R.dimen.material_font_1_3_box_collapsed_padding_top);
}
}
}
private void adjustFilledEditTextPaddingForLargeFont() {
if (this.editText == null || this.boxBackgroundMode != 1) {
return;
}
if (MaterialResources.isFontScaleAtLeast2_0(getContext())) {
EditText editText = this.editText;
ViewCompat.setPaddingRelative(editText, ViewCompat.getPaddingStart(editText), getResources().getDimensionPixelSize(R.dimen.material_filled_edittext_font_2_0_padding_top), ViewCompat.getPaddingEnd(this.editText), getResources().getDimensionPixelSize(R.dimen.material_filled_edittext_font_2_0_padding_bottom));
} else if (MaterialResources.isFontScaleAtLeast1_3(getContext())) {
EditText editText2 = this.editText;
ViewCompat.setPaddingRelative(editText2, ViewCompat.getPaddingStart(editText2), getResources().getDimensionPixelSize(R.dimen.material_filled_edittext_font_1_3_padding_top), ViewCompat.getPaddingEnd(this.editText), getResources().getDimensionPixelSize(R.dimen.material_filled_edittext_font_1_3_padding_bottom));
}
}
public void setBoxStrokeWidthResource(int i) {
setBoxStrokeWidth(getResources().getDimensionPixelSize(i));
}
public void setBoxStrokeWidth(int i) {
this.boxStrokeWidthDefaultPx = i;
updateTextInputBoxState();
}
public void setBoxStrokeWidthFocusedResource(int i) {
setBoxStrokeWidthFocused(getResources().getDimensionPixelSize(i));
}
public void setBoxStrokeWidthFocused(int i) {
this.boxStrokeWidthFocusedPx = i;
updateTextInputBoxState();
}
public void setBoxStrokeColor(int i) {
if (this.focusedStrokeColor != i) {
this.focusedStrokeColor = i;
updateTextInputBoxState();
}
}
public void setBoxStrokeColorStateList(ColorStateList colorStateList) {
if (colorStateList.isStateful()) {
this.defaultStrokeColor = colorStateList.getDefaultColor();
this.disabledColor = colorStateList.getColorForState(new int[]{-16842910}, -1);
this.hoveredStrokeColor = colorStateList.getColorForState(new int[]{android.R.attr.state_hovered, android.R.attr.state_enabled}, -1);
this.focusedStrokeColor = colorStateList.getColorForState(new int[]{android.R.attr.state_focused, android.R.attr.state_enabled}, -1);
} else if (this.focusedStrokeColor != colorStateList.getDefaultColor()) {
this.focusedStrokeColor = colorStateList.getDefaultColor();
}
updateTextInputBoxState();
}
public void setBoxStrokeErrorColor(ColorStateList colorStateList) {
if (this.strokeErrorColor != colorStateList) {
this.strokeErrorColor = colorStateList;
updateTextInputBoxState();
}
}
public void setBoxBackgroundColorResource(int i) {
setBoxBackgroundColor(ContextCompat.getColor(getContext(), i));
}
public void setBoxBackgroundColor(int i) {
if (this.boxBackgroundColor != i) {
this.boxBackgroundColor = i;
this.defaultFilledBackgroundColor = i;
this.focusedFilledBackgroundColor = i;
this.hoveredFilledBackgroundColor = i;
applyBoxAttributes();
}
}
public void setBoxBackgroundColorStateList(ColorStateList colorStateList) {
int defaultColor = colorStateList.getDefaultColor();
this.defaultFilledBackgroundColor = defaultColor;
this.boxBackgroundColor = defaultColor;
this.disabledFilledBackgroundColor = colorStateList.getColorForState(new int[]{-16842910}, -1);
this.focusedFilledBackgroundColor = colorStateList.getColorForState(new int[]{android.R.attr.state_focused, android.R.attr.state_enabled}, -1);
this.hoveredFilledBackgroundColor = colorStateList.getColorForState(new int[]{android.R.attr.state_hovered, android.R.attr.state_enabled}, -1);
applyBoxAttributes();
}
public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel) {
MaterialShapeDrawable materialShapeDrawable = this.boxBackground;
if (materialShapeDrawable == null || materialShapeDrawable.getShapeAppearanceModel() == shapeAppearanceModel) {
return;
}
this.shapeAppearanceModel = shapeAppearanceModel;
applyBoxAttributes();
}
public void setBoxCornerFamily(int i) {
this.shapeAppearanceModel = this.shapeAppearanceModel.toBuilder().setTopLeftCorner(i, this.shapeAppearanceModel.getTopLeftCornerSize()).setTopRightCorner(i, this.shapeAppearanceModel.getTopRightCornerSize()).setBottomLeftCorner(i, this.shapeAppearanceModel.getBottomLeftCornerSize()).setBottomRightCorner(i, this.shapeAppearanceModel.getBottomRightCornerSize()).build();
applyBoxAttributes();
}
public void setBoxCornerRadiiResources(int i, int i2, int i3, int i4) {
setBoxCornerRadii(getContext().getResources().getDimension(i), getContext().getResources().getDimension(i2), getContext().getResources().getDimension(i4), getContext().getResources().getDimension(i3));
}
public void setBoxCornerRadii(float f, float f2, float f3, float f4) {
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
this.areCornerRadiiRtl = isLayoutRtl;
float f5 = isLayoutRtl ? f2 : f;
if (!isLayoutRtl) {
f = f2;
}
float f6 = isLayoutRtl ? f4 : f3;
if (!isLayoutRtl) {
f3 = f4;
}
MaterialShapeDrawable materialShapeDrawable = this.boxBackground;
if (materialShapeDrawable != null && materialShapeDrawable.getTopLeftCornerResolvedSize() == f5 && this.boxBackground.getTopRightCornerResolvedSize() == f && this.boxBackground.getBottomLeftCornerResolvedSize() == f6 && this.boxBackground.getBottomRightCornerResolvedSize() == f3) {
return;
}
this.shapeAppearanceModel = this.shapeAppearanceModel.toBuilder().setTopLeftCornerSize(f5).setTopRightCornerSize(f).setBottomLeftCornerSize(f6).setBottomRightCornerSize(f3).build();
applyBoxAttributes();
}
public float getBoxCornerRadiusTopStart() {
if (ViewUtils.isLayoutRtl(this)) {
return this.shapeAppearanceModel.getTopRightCornerSize().getCornerSize(this.tmpRectF);
}
return this.shapeAppearanceModel.getTopLeftCornerSize().getCornerSize(this.tmpRectF);
}
public float getBoxCornerRadiusTopEnd() {
if (ViewUtils.isLayoutRtl(this)) {
return this.shapeAppearanceModel.getTopLeftCornerSize().getCornerSize(this.tmpRectF);
}
return this.shapeAppearanceModel.getTopRightCornerSize().getCornerSize(this.tmpRectF);
}
public float getBoxCornerRadiusBottomEnd() {
if (ViewUtils.isLayoutRtl(this)) {
return this.shapeAppearanceModel.getBottomLeftCornerSize().getCornerSize(this.tmpRectF);
}
return this.shapeAppearanceModel.getBottomRightCornerSize().getCornerSize(this.tmpRectF);
}
public float getBoxCornerRadiusBottomStart() {
if (ViewUtils.isLayoutRtl(this)) {
return this.shapeAppearanceModel.getBottomRightCornerSize().getCornerSize(this.tmpRectF);
}
return this.shapeAppearanceModel.getBottomLeftCornerSize().getCornerSize(this.tmpRectF);
}
public void setTypeface(Typeface typeface) {
if (typeface != this.typeface) {
this.typeface = typeface;
this.collapsingTextHelper.setTypefaces(typeface);
this.indicatorViewController.setTypefaces(typeface);
TextView textView = this.counterView;
if (textView != null) {
textView.setTypeface(typeface);
}
}
}
@Override // android.view.ViewGroup, android.view.View
public void dispatchProvideAutofillStructure(ViewStructure viewStructure, int i) {
EditText editText = this.editText;
if (editText == null) {
super.dispatchProvideAutofillStructure(viewStructure, i);
return;
}
if (this.originalHint != null) {
boolean z = this.isProvidingHint;
this.isProvidingHint = false;
CharSequence hint = editText.getHint();
this.editText.setHint(this.originalHint);
try {
super.dispatchProvideAutofillStructure(viewStructure, i);
return;
} finally {
this.editText.setHint(hint);
this.isProvidingHint = z;
}
}
viewStructure.setAutofillId(getAutofillId());
onProvideAutofillStructure(viewStructure, i);
onProvideAutofillVirtualStructure(viewStructure, i);
viewStructure.setChildCount(this.inputFrame.getChildCount());
for (int i2 = 0; i2 < this.inputFrame.getChildCount(); i2++) {
View childAt = this.inputFrame.getChildAt(i2);
ViewStructure newChild = viewStructure.newChild(i2);
childAt.dispatchProvideAutofillStructure(newChild, i);
if (childAt == this.editText) {
newChild.setHint(getHint());
}
}
}
private void setEditText(EditText editText) {
if (this.editText != null) {
throw new IllegalArgumentException("We already have an EditText, can only have one");
}
if (getEndIconMode() != 3 && !(editText instanceof TextInputEditText)) {
Log.i(LOG_TAG, "EditText added is not a TextInputEditText. Please switch to using that class instead.");
}
this.editText = editText;
int i = this.minEms;
if (i != -1) {
setMinEms(i);
} else {
setMinWidth(this.minWidth);
}
int i2 = this.maxEms;
if (i2 != -1) {
setMaxEms(i2);
} else {
setMaxWidth(this.maxWidth);
}
this.boxBackgroundApplied = false;
onApplyBoxBackgroundMode();
setTextInputAccessibilityDelegate(new AccessibilityDelegate(this));
this.collapsingTextHelper.setTypefaces(this.editText.getTypeface());
this.collapsingTextHelper.setExpandedTextSize(this.editText.getTextSize());
this.collapsingTextHelper.setExpandedLetterSpacing(this.editText.getLetterSpacing());
int gravity = this.editText.getGravity();
this.collapsingTextHelper.setCollapsedTextGravity((gravity & (-113)) | 48);
this.collapsingTextHelper.setExpandedTextGravity(gravity);
this.editText.addTextChangedListener(new TextWatcher() { // from class: com.google.android.material.textfield.TextInputLayout.1
@Override // android.text.TextWatcher
public void beforeTextChanged(CharSequence charSequence, int i3, int i4, int i5) {
}
@Override // android.text.TextWatcher
public void onTextChanged(CharSequence charSequence, int i3, int i4, int i5) {
}
@Override // android.text.TextWatcher
public void afterTextChanged(Editable editable) {
TextInputLayout.this.updateLabelState(!r0.restoringSavedState);
if (TextInputLayout.this.counterEnabled) {
TextInputLayout.this.updateCounter(editable);
}
if (TextInputLayout.this.placeholderEnabled) {
TextInputLayout.this.updatePlaceholderText(editable);
}
}
});
if (this.defaultHintTextColor == null) {
this.defaultHintTextColor = this.editText.getHintTextColors();
}
if (this.hintEnabled) {
if (TextUtils.isEmpty(this.hint)) {
CharSequence hint = this.editText.getHint();
this.originalHint = hint;
setHint(hint);
this.editText.setHint((CharSequence) null);
}
this.isProvidingHint = true;
}
updateCursorColor();
if (this.counterView != null) {
updateCounter(this.editText.getText());
}
updateEditTextBackground();
this.indicatorViewController.adjustIndicatorPadding();
this.startLayout.bringToFront();
this.endLayout.bringToFront();
dispatchOnEditTextAttached();
this.endLayout.updateSuffixTextViewPadding();
if (!isEnabled()) {
editText.setEnabled(false);
}
updateLabelState(false, true);
}
private void updateInputLayoutMargins() {
if (this.boxBackgroundMode != 1) {
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.inputFrame.getLayoutParams();
int calculateLabelMarginTop = calculateLabelMarginTop();
if (calculateLabelMarginTop != layoutParams.topMargin) {
layoutParams.topMargin = calculateLabelMarginTop;
this.inputFrame.requestLayout();
}
}
}
@Override // android.widget.LinearLayout, android.view.View
public int getBaseline() {
EditText editText = this.editText;
if (editText != null) {
return editText.getBaseline() + getPaddingTop() + calculateLabelMarginTop();
}
return super.getBaseline();
}
/* JADX INFO: Access modifiers changed from: package-private */
public void updateLabelState(boolean z) {
updateLabelState(z, false);
}
private void updateLabelState(boolean z, boolean z2) {
ColorStateList colorStateList;
TextView textView;
boolean isEnabled = isEnabled();
EditText editText = this.editText;
boolean z3 = (editText == null || TextUtils.isEmpty(editText.getText())) ? false : true;
EditText editText2 = this.editText;
boolean z4 = editText2 != null && editText2.hasFocus();
ColorStateList colorStateList2 = this.defaultHintTextColor;
if (colorStateList2 != null) {
this.collapsingTextHelper.setCollapsedAndExpandedTextColor(colorStateList2);
}
if (!isEnabled) {
ColorStateList colorStateList3 = this.defaultHintTextColor;
this.collapsingTextHelper.setCollapsedAndExpandedTextColor(ColorStateList.valueOf(colorStateList3 != null ? colorStateList3.getColorForState(new int[]{-16842910}, this.disabledColor) : this.disabledColor));
} else if (shouldShowError()) {
this.collapsingTextHelper.setCollapsedAndExpandedTextColor(this.indicatorViewController.getErrorViewTextColors());
} else if (this.counterOverflowed && (textView = this.counterView) != null) {
this.collapsingTextHelper.setCollapsedAndExpandedTextColor(textView.getTextColors());
} else if (z4 && (colorStateList = this.focusedTextColor) != null) {
this.collapsingTextHelper.setCollapsedTextColor(colorStateList);
}
if (z3 || !this.expandedHintEnabled || (isEnabled() && z4)) {
if (z2 || this.hintExpanded) {
collapseHint(z);
return;
}
return;
}
if (z2 || !this.hintExpanded) {
expandHint(z);
}
}
public void setMinEms(int i) {
this.minEms = i;
EditText editText = this.editText;
if (editText == null || i == -1) {
return;
}
editText.setMinEms(i);
}
public void setMaxEms(int i) {
this.maxEms = i;
EditText editText = this.editText;
if (editText == null || i == -1) {
return;
}
editText.setMaxEms(i);
}
public void setMinWidth(int i) {
this.minWidth = i;
EditText editText = this.editText;
if (editText == null || i == -1) {
return;
}
editText.setMinWidth(i);
}
public void setMinWidthResource(int i) {
setMinWidth(getContext().getResources().getDimensionPixelSize(i));
}
public void setMaxWidth(int i) {
this.maxWidth = i;
EditText editText = this.editText;
if (editText == null || i == -1) {
return;
}
editText.setMaxWidth(i);
}
public void setMaxWidthResource(int i) {
setMaxWidth(getContext().getResources().getDimensionPixelSize(i));
}
public void setHint(CharSequence charSequence) {
if (this.hintEnabled) {
setHintInternal(charSequence);
sendAccessibilityEvent(2048);
}
}
public void setHint(int i) {
setHint(i != 0 ? getResources().getText(i) : null);
}
private void setHintInternal(CharSequence charSequence) {
if (TextUtils.equals(charSequence, this.hint)) {
return;
}
this.hint = charSequence;
this.collapsingTextHelper.setText(charSequence);
if (this.hintExpanded) {
return;
}
openCutout();
}
public void setHintEnabled(boolean z) {
if (z != this.hintEnabled) {
this.hintEnabled = z;
if (!z) {
this.isProvidingHint = false;
if (!TextUtils.isEmpty(this.hint) && TextUtils.isEmpty(this.editText.getHint())) {
this.editText.setHint(this.hint);
}
setHintInternal(null);
} else {
CharSequence hint = this.editText.getHint();
if (!TextUtils.isEmpty(hint)) {
if (TextUtils.isEmpty(this.hint)) {
setHint(hint);
}
this.editText.setHint((CharSequence) null);
}
this.isProvidingHint = true;
}
if (this.editText != null) {
updateInputLayoutMargins();
}
}
}
public void setHintTextAppearance(int i) {
this.collapsingTextHelper.setCollapsedTextAppearance(i);
this.focusedTextColor = this.collapsingTextHelper.getCollapsedTextColor();
if (this.editText != null) {
updateLabelState(false);
updateInputLayoutMargins();
}
}
public void setHintTextColor(ColorStateList colorStateList) {
if (this.focusedTextColor != colorStateList) {
if (this.defaultHintTextColor == null) {
this.collapsingTextHelper.setCollapsedTextColor(colorStateList);
}
this.focusedTextColor = colorStateList;
if (this.editText != null) {
updateLabelState(false);
}
}
}
public void setDefaultHintTextColor(ColorStateList colorStateList) {
this.defaultHintTextColor = colorStateList;
this.focusedTextColor = colorStateList;
if (this.editText != null) {
updateLabelState(false);
}
}
public void setErrorEnabled(boolean z) {
this.indicatorViewController.setErrorEnabled(z);
}
public void setErrorTextAppearance(int i) {
this.indicatorViewController.setErrorTextAppearance(i);
}
public void setErrorTextColor(ColorStateList colorStateList) {
this.indicatorViewController.setErrorViewTextColor(colorStateList);
}
public int getErrorCurrentTextColors() {
return this.indicatorViewController.getErrorViewCurrentTextColor();
}
public void setHelperTextTextAppearance(int i) {
this.indicatorViewController.setHelperTextAppearance(i);
}
public void setHelperTextColor(ColorStateList colorStateList) {
this.indicatorViewController.setHelperTextViewTextColor(colorStateList);
}
public boolean isErrorEnabled() {
return this.indicatorViewController.isErrorEnabled();
}
public void setHelperTextEnabled(boolean z) {
this.indicatorViewController.setHelperTextEnabled(z);
}
public void setHelperText(CharSequence charSequence) {
if (TextUtils.isEmpty(charSequence)) {
if (isHelperTextEnabled()) {
setHelperTextEnabled(false);
}
} else {
if (!isHelperTextEnabled()) {
setHelperTextEnabled(true);
}
this.indicatorViewController.showHelper(charSequence);
}
}
public boolean isHelperTextEnabled() {
return this.indicatorViewController.isHelperTextEnabled();
}
public int getHelperTextCurrentTextColor() {
return this.indicatorViewController.getHelperTextViewCurrentTextColor();
}
public void setErrorContentDescription(CharSequence charSequence) {
this.indicatorViewController.setErrorContentDescription(charSequence);
}
public CharSequence getErrorContentDescription() {
return this.indicatorViewController.getErrorContentDescription();
}
public void setErrorAccessibilityLiveRegion(int i) {
this.indicatorViewController.setErrorAccessibilityLiveRegion(i);
}
public int getErrorAccessibilityLiveRegion() {
return this.indicatorViewController.getErrorAccessibilityLiveRegion();
}
public void setError(CharSequence charSequence) {
if (!this.indicatorViewController.isErrorEnabled()) {
if (TextUtils.isEmpty(charSequence)) {
return;
} else {
setErrorEnabled(true);
}
}
if (!TextUtils.isEmpty(charSequence)) {
this.indicatorViewController.showError(charSequence);
} else {
this.indicatorViewController.hideError();
}
}
public void setErrorIconDrawable(int i) {
this.endLayout.setErrorIconDrawable(i);
}
public void setErrorIconDrawable(Drawable drawable) {
this.endLayout.setErrorIconDrawable(drawable);
}
public Drawable getErrorIconDrawable() {
return this.endLayout.getErrorIconDrawable();
}
public void setErrorIconTintList(ColorStateList colorStateList) {
this.endLayout.setErrorIconTintList(colorStateList);
}
public void setErrorIconTintMode(PorterDuff.Mode mode) {
this.endLayout.setErrorIconTintMode(mode);
}
public void setCounterEnabled(boolean z) {
if (this.counterEnabled != z) {
if (z) {
AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
this.counterView = appCompatTextView;
appCompatTextView.setId(R.id.textinput_counter);
Typeface typeface = this.typeface;
if (typeface != null) {
this.counterView.setTypeface(typeface);
}
this.counterView.setMaxLines(1);
this.indicatorViewController.addIndicator(this.counterView, 2);
MarginLayoutParamsCompat.setMarginStart((ViewGroup.MarginLayoutParams) this.counterView.getLayoutParams(), getResources().getDimensionPixelOffset(R.dimen.mtrl_textinput_counter_margin_start));
updateCounterTextAppearanceAndColor();
updateCounter();
} else {
this.indicatorViewController.removeIndicator(this.counterView, 2);
this.counterView = null;
}
this.counterEnabled = z;
}
}
public void setCounterTextAppearance(int i) {
if (this.counterTextAppearance != i) {
this.counterTextAppearance = i;
updateCounterTextAppearanceAndColor();
}
}
public void setCounterTextColor(ColorStateList colorStateList) {
if (this.counterTextColor != colorStateList) {
this.counterTextColor = colorStateList;
updateCounterTextAppearanceAndColor();
}
}
public void setCounterOverflowTextAppearance(int i) {
if (this.counterOverflowTextAppearance != i) {
this.counterOverflowTextAppearance = i;
updateCounterTextAppearanceAndColor();
}
}
public void setCounterOverflowTextColor(ColorStateList colorStateList) {
if (this.counterOverflowTextColor != colorStateList) {
this.counterOverflowTextColor = colorStateList;
updateCounterTextAppearanceAndColor();
}
}
public void setCounterMaxLength(int i) {
if (this.counterMaxLength != i) {
if (i > 0) {
this.counterMaxLength = i;
} else {
this.counterMaxLength = -1;
}
if (this.counterEnabled) {
updateCounter();
}
}
}
private void updateCounter() {
if (this.counterView != null) {
EditText editText = this.editText;
updateCounter(editText == null ? null : editText.getText());
}
}
void updateCounter(Editable editable) {
int countLength = this.lengthCounter.countLength(editable);
boolean z = this.counterOverflowed;
int i = this.counterMaxLength;
if (i == -1) {
this.counterView.setText(String.valueOf(countLength));
this.counterView.setContentDescription(null);
this.counterOverflowed = false;
} else {
this.counterOverflowed = countLength > i;
updateCounterContentDescription(getContext(), this.counterView, countLength, this.counterMaxLength, this.counterOverflowed);
if (z != this.counterOverflowed) {
updateCounterTextAppearanceAndColor();
}
this.counterView.setText(BidiFormatter.getInstance().unicodeWrap(getContext().getString(R.string.character_counter_pattern, Integer.valueOf(countLength), Integer.valueOf(this.counterMaxLength))));
}
if (this.editText == null || z == this.counterOverflowed) {
return;
}
updateLabelState(false);
updateTextInputBoxState();
updateEditTextBackground();
}
private static void updateCounterContentDescription(Context context, TextView textView, int i, int i2, boolean z) {
int i3;
if (z) {
i3 = R.string.character_counter_overflowed_content_description;
} else {
i3 = R.string.character_counter_content_description;
}
textView.setContentDescription(context.getString(i3, Integer.valueOf(i), Integer.valueOf(i2)));
}
public void setPlaceholderText(CharSequence charSequence) {
if (this.placeholderTextView == null) {
AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
this.placeholderTextView = appCompatTextView;
appCompatTextView.setId(R.id.textinput_placeholder);
ViewCompat.setImportantForAccessibility(this.placeholderTextView, 2);
Fade createPlaceholderFadeTransition = createPlaceholderFadeTransition();
this.placeholderFadeIn = createPlaceholderFadeTransition;
createPlaceholderFadeTransition.setStartDelay(67L);
this.placeholderFadeOut = createPlaceholderFadeTransition();
setPlaceholderTextAppearance(this.placeholderTextAppearance);
setPlaceholderTextColor(this.placeholderTextColor);
}
if (TextUtils.isEmpty(charSequence)) {
setPlaceholderTextEnabled(false);
} else {
if (!this.placeholderEnabled) {
setPlaceholderTextEnabled(true);
}
this.placeholderText = charSequence;
}
updatePlaceholderText();
}
private void setPlaceholderTextEnabled(boolean z) {
if (this.placeholderEnabled == z) {
return;
}
if (z) {
addPlaceholderTextView();
} else {
removePlaceholderTextView();
this.placeholderTextView = null;
}
this.placeholderEnabled = z;
}
private Fade createPlaceholderFadeTransition() {
Fade fade = new Fade();
fade.setDuration(MotionUtils.resolveThemeDuration(getContext(), R.attr.motionDurationShort2, DEFAULT_PLACEHOLDER_FADE_DURATION));
fade.setInterpolator(MotionUtils.resolveThemeInterpolator(getContext(), R.attr.motionEasingLinearInterpolator, AnimationUtils.LINEAR_INTERPOLATOR));
return fade;
}
private void updatePlaceholderText() {
EditText editText = this.editText;
updatePlaceholderText(editText == null ? null : editText.getText());
}
/* JADX INFO: Access modifiers changed from: private */
public void updatePlaceholderText(Editable editable) {
if (this.lengthCounter.countLength(editable) == 0 && !this.hintExpanded) {
showPlaceholderText();
} else {
hidePlaceholderText();
}
}
private void showPlaceholderText() {
if (this.placeholderTextView == null || !this.placeholderEnabled || TextUtils.isEmpty(this.placeholderText)) {
return;
}
this.placeholderTextView.setText(this.placeholderText);
TransitionManager.beginDelayedTransition(this.inputFrame, this.placeholderFadeIn);
this.placeholderTextView.setVisibility(0);
this.placeholderTextView.bringToFront();
announceForAccessibility(this.placeholderText);
}
private void hidePlaceholderText() {
TextView textView = this.placeholderTextView;
if (textView == null || !this.placeholderEnabled) {
return;
}
textView.setText((CharSequence) null);
TransitionManager.beginDelayedTransition(this.inputFrame, this.placeholderFadeOut);
this.placeholderTextView.setVisibility(4);
}
private void addPlaceholderTextView() {
TextView textView = this.placeholderTextView;
if (textView != null) {
this.inputFrame.addView(textView);
this.placeholderTextView.setVisibility(0);
}
}
private void removePlaceholderTextView() {
TextView textView = this.placeholderTextView;
if (textView != null) {
textView.setVisibility(8);
}
}
public void setPlaceholderTextColor(ColorStateList colorStateList) {
if (this.placeholderTextColor != colorStateList) {
this.placeholderTextColor = colorStateList;
TextView textView = this.placeholderTextView;
if (textView == null || colorStateList == null) {
return;
}
textView.setTextColor(colorStateList);
}
}
public void setPlaceholderTextAppearance(int i) {
this.placeholderTextAppearance = i;
TextView textView = this.placeholderTextView;
if (textView != null) {
TextViewCompat.setTextAppearance(textView, i);
}
}
public void setCursorColor(ColorStateList colorStateList) {
if (this.cursorColor != colorStateList) {
this.cursorColor = colorStateList;
updateCursorColor();
}
}
public void setCursorErrorColor(ColorStateList colorStateList) {
if (this.cursorErrorColor != colorStateList) {
this.cursorErrorColor = colorStateList;
if (isOnError()) {
updateCursorColor();
}
}
}
public void setPrefixText(CharSequence charSequence) {
this.startLayout.setPrefixText(charSequence);
}
public CharSequence getPrefixText() {
return this.startLayout.getPrefixText();
}
public TextView getPrefixTextView() {
return this.startLayout.getPrefixTextView();
}
public void setPrefixTextColor(ColorStateList colorStateList) {
this.startLayout.setPrefixTextColor(colorStateList);
}
public ColorStateList getPrefixTextColor() {
return this.startLayout.getPrefixTextColor();
}
public void setPrefixTextAppearance(int i) {
this.startLayout.setPrefixTextAppearance(i);
}
public void setSuffixText(CharSequence charSequence) {
this.endLayout.setSuffixText(charSequence);
}
public CharSequence getSuffixText() {
return this.endLayout.getSuffixText();
}
public TextView getSuffixTextView() {
return this.endLayout.getSuffixTextView();
}
public void setSuffixTextColor(ColorStateList colorStateList) {
this.endLayout.setSuffixTextColor(colorStateList);
}
public ColorStateList getSuffixTextColor() {
return this.endLayout.getSuffixTextColor();
}
public void setSuffixTextAppearance(int i) {
this.endLayout.setSuffixTextAppearance(i);
}
@Override // android.view.View
public void setEnabled(boolean z) {
recursiveSetEnabled(this, z);
super.setEnabled(z);
}
private static void recursiveSetEnabled(ViewGroup viewGroup, boolean z) {
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = viewGroup.getChildAt(i);
childAt.setEnabled(z);
if (childAt instanceof ViewGroup) {
recursiveSetEnabled((ViewGroup) childAt, z);
}
}
}
CharSequence getCounterOverflowDescription() {
TextView textView;
if (this.counterEnabled && this.counterOverflowed && (textView = this.counterView) != null) {
return textView.getContentDescription();
}
return null;
}
private void updateCounterTextAppearanceAndColor() {
ColorStateList colorStateList;
ColorStateList colorStateList2;
TextView textView = this.counterView;
if (textView != null) {
setTextAppearanceCompatWithErrorFallback(textView, this.counterOverflowed ? this.counterOverflowTextAppearance : this.counterTextAppearance);
if (!this.counterOverflowed && (colorStateList2 = this.counterTextColor) != null) {
this.counterView.setTextColor(colorStateList2);
}
if (!this.counterOverflowed || (colorStateList = this.counterOverflowTextColor) == null) {
return;
}
this.counterView.setTextColor(colorStateList);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public void setTextAppearanceCompatWithErrorFallback(TextView textView, int i) {
try {
TextViewCompat.setTextAppearance(textView, i);
if (textView.getTextColors().getDefaultColor() != -65281) {
return;
}
} catch (Exception unused) {
}
TextViewCompat.setTextAppearance(textView, R.style.TextAppearance_AppCompat_Caption);
textView.setTextColor(ContextCompat.getColor(getContext(), R.color.design_error));
}
private int calculateLabelMarginTop() {
float collapsedTextHeight;
if (!this.hintEnabled) {
return 0;
}
int i = this.boxBackgroundMode;
if (i == 0) {
collapsedTextHeight = this.collapsingTextHelper.getCollapsedTextHeight();
} else {
if (i != 2) {
return 0;
}
collapsedTextHeight = this.collapsingTextHelper.getCollapsedTextHeight() / 2.0f;
}
return (int) collapsedTextHeight;
}
private Rect calculateCollapsedTextBounds(Rect rect) {
if (this.editText == null) {
throw new IllegalStateException();
}
Rect rect2 = this.tmpBoundsRect;
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
rect2.bottom = rect.bottom;
int i = this.boxBackgroundMode;
if (i == 1) {
rect2.left = getLabelLeftBoundAlignedWithPrefixAndSuffix(rect.left, isLayoutRtl);
rect2.top = rect.top + this.boxCollapsedPaddingTopPx;
rect2.right = getLabelRightBoundAlignedWithPrefixAndSuffix(rect.right, isLayoutRtl);
return rect2;
}
if (i == 2) {
rect2.left = rect.left + this.editText.getPaddingLeft();
rect2.top = rect.top - calculateLabelMarginTop();
rect2.right = rect.right - this.editText.getPaddingRight();
return rect2;
}
rect2.left = getLabelLeftBoundAlignedWithPrefixAndSuffix(rect.left, isLayoutRtl);
rect2.top = getPaddingTop();
rect2.right = getLabelRightBoundAlignedWithPrefixAndSuffix(rect.right, isLayoutRtl);
return rect2;
}
private int getLabelLeftBoundAlignedWithPrefixAndSuffix(int i, boolean z) {
int compoundPaddingLeft;
if (!z && getPrefixText() != null) {
compoundPaddingLeft = this.startLayout.getPrefixTextStartOffset();
} else if (z && getSuffixText() != null) {
compoundPaddingLeft = this.endLayout.getSuffixTextEndOffset();
} else {
compoundPaddingLeft = this.editText.getCompoundPaddingLeft();
}
return i + compoundPaddingLeft;
}
private int getLabelRightBoundAlignedWithPrefixAndSuffix(int i, boolean z) {
int compoundPaddingRight;
if (!z && getSuffixText() != null) {
compoundPaddingRight = this.endLayout.getSuffixTextEndOffset();
} else if (z && getPrefixText() != null) {
compoundPaddingRight = this.startLayout.getPrefixTextStartOffset();
} else {
compoundPaddingRight = this.editText.getCompoundPaddingRight();
}
return i - compoundPaddingRight;
}
private Rect calculateExpandedTextBounds(Rect rect) {
if (this.editText == null) {
throw new IllegalStateException();
}
Rect rect2 = this.tmpBoundsRect;
float expandedTextHeight = this.collapsingTextHelper.getExpandedTextHeight();
rect2.left = rect.left + this.editText.getCompoundPaddingLeft();
rect2.top = calculateExpandedLabelTop(rect, expandedTextHeight);
rect2.right = rect.right - this.editText.getCompoundPaddingRight();
rect2.bottom = calculateExpandedLabelBottom(rect, rect2, expandedTextHeight);
return rect2;
}
private int calculateExpandedLabelTop(Rect rect, float f) {
if (isSingleLineFilledTextField()) {
return (int) (rect.centerY() - (f / 2.0f));
}
return rect.top + this.editText.getCompoundPaddingTop();
}
private int calculateExpandedLabelBottom(Rect rect, Rect rect2, float f) {
if (isSingleLineFilledTextField()) {
return (int) (rect2.top + f);
}
return rect.bottom - this.editText.getCompoundPaddingBottom();
}
private boolean isSingleLineFilledTextField() {
return this.boxBackgroundMode == 1 && this.editText.getMinLines() <= 1;
}
private int calculateBoxBackgroundColor() {
return this.boxBackgroundMode == 1 ? MaterialColors.layer(MaterialColors.getColor(this, R.attr.colorSurface, 0), this.boxBackgroundColor) : this.boxBackgroundColor;
}
private void applyBoxAttributes() {
MaterialShapeDrawable materialShapeDrawable = this.boxBackground;
if (materialShapeDrawable == null) {
return;
}
ShapeAppearanceModel shapeAppearanceModel = materialShapeDrawable.getShapeAppearanceModel();
ShapeAppearanceModel shapeAppearanceModel2 = this.shapeAppearanceModel;
if (shapeAppearanceModel != shapeAppearanceModel2) {
this.boxBackground.setShapeAppearanceModel(shapeAppearanceModel2);
}
if (canDrawOutlineStroke()) {
this.boxBackground.setStroke(this.boxStrokeWidthPx, this.boxStrokeColor);
}
int calculateBoxBackgroundColor = calculateBoxBackgroundColor();
this.boxBackgroundColor = calculateBoxBackgroundColor;
this.boxBackground.setFillColor(ColorStateList.valueOf(calculateBoxBackgroundColor));
applyBoxUnderlineAttributes();
updateEditTextBoxBackgroundIfNeeded();
}
private void applyBoxUnderlineAttributes() {
ColorStateList valueOf;
if (this.boxUnderlineDefault == null || this.boxUnderlineFocused == null) {
return;
}
if (canDrawStroke()) {
MaterialShapeDrawable materialShapeDrawable = this.boxUnderlineDefault;
if (this.editText.isFocused()) {
valueOf = ColorStateList.valueOf(this.defaultStrokeColor);
} else {
valueOf = ColorStateList.valueOf(this.boxStrokeColor);
}
materialShapeDrawable.setFillColor(valueOf);
this.boxUnderlineFocused.setFillColor(ColorStateList.valueOf(this.boxStrokeColor));
}
invalidate();
}
private boolean canDrawOutlineStroke() {
return this.boxBackgroundMode == 2 && canDrawStroke();
}
/* JADX INFO: Access modifiers changed from: package-private */
public void updateEditTextBackground() {
Drawable background;
TextView textView;
EditText editText = this.editText;
if (editText == null || this.boxBackgroundMode != 0 || (background = editText.getBackground()) == null) {
return;
}
if (DrawableUtils.canSafelyMutateDrawable(background)) {
background = background.mutate();
}
if (shouldShowError()) {
background.setColorFilter(AppCompatDrawableManager.getPorterDuffColorFilter(getErrorCurrentTextColors(), PorterDuff.Mode.SRC_IN));
} else if (this.counterOverflowed && (textView = this.counterView) != null) {
background.setColorFilter(AppCompatDrawableManager.getPorterDuffColorFilter(textView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
} else {
DrawableCompat.clearColorFilter(background);
this.editText.refreshDrawableState();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public boolean shouldShowError() {
return this.indicatorViewController.errorShouldBeShown();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static class SavedState extends AbsSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: com.google.android.material.textfield.TextInputLayout.SavedState.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.ClassLoaderCreator
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
return new SavedState(parcel, classLoader);
}
@Override // android.os.Parcelable.Creator
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel, null);
}
@Override // android.os.Parcelable.Creator
public SavedState[] newArray(int i) {
return new SavedState[i];
}
};
CharSequence error;
boolean isEndIconChecked;
SavedState(Parcelable parcelable) {
super(parcelable);
}
SavedState(Parcel parcel, ClassLoader classLoader) {
super(parcel, classLoader);
this.error = (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
this.isEndIconChecked = parcel.readInt() == 1;
}
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
TextUtils.writeToParcel(this.error, parcel, i);
parcel.writeInt(this.isEndIconChecked ? 1 : 0);
}
public String toString() {
return "TextInputLayout.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " error=" + ((Object) this.error) + "}";
}
}
@Override // android.view.View
public Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
if (shouldShowError()) {
savedState.error = getError();
}
savedState.isEndIconChecked = this.endLayout.isEndIconChecked();
return savedState;
}
@Override // android.view.View
protected void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
setError(savedState.error);
if (savedState.isEndIconChecked) {
post(new Runnable() { // from class: com.google.android.material.textfield.TextInputLayout.2
@Override // java.lang.Runnable
public void run() {
TextInputLayout.this.endLayout.checkEndIcon();
}
});
}
requestLayout();
}
@Override // android.view.ViewGroup, android.view.View
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> sparseArray) {
this.restoringSavedState = true;
super.dispatchRestoreInstanceState(sparseArray);
this.restoringSavedState = false;
}
public CharSequence getError() {
if (this.indicatorViewController.isErrorEnabled()) {
return this.indicatorViewController.getErrorText();
}
return null;
}
public CharSequence getHelperText() {
if (this.indicatorViewController.isHelperTextEnabled()) {
return this.indicatorViewController.getHelperText();
}
return null;
}
public void setExpandedHintEnabled(boolean z) {
if (this.expandedHintEnabled != z) {
this.expandedHintEnabled = z;
updateLabelState(false);
}
}
@Override // android.widget.LinearLayout, android.view.View
public void onRtlPropertiesChanged(int i) {
super.onRtlPropertiesChanged(i);
boolean z = i == 1;
if (z != this.areCornerRadiiRtl) {
float cornerSize = this.shapeAppearanceModel.getTopLeftCornerSize().getCornerSize(this.tmpRectF);
float cornerSize2 = this.shapeAppearanceModel.getTopRightCornerSize().getCornerSize(this.tmpRectF);
ShapeAppearanceModel build = ShapeAppearanceModel.builder().setTopLeftCorner(this.shapeAppearanceModel.getTopRightCorner()).setTopRightCorner(this.shapeAppearanceModel.getTopLeftCorner()).setBottomLeftCorner(this.shapeAppearanceModel.getBottomRightCorner()).setBottomRightCorner(this.shapeAppearanceModel.getBottomLeftCorner()).setTopLeftCornerSize(cornerSize2).setTopRightCornerSize(cornerSize).setBottomLeftCornerSize(this.shapeAppearanceModel.getBottomRightCornerSize().getCornerSize(this.tmpRectF)).setBottomRightCornerSize(this.shapeAppearanceModel.getBottomLeftCornerSize().getCornerSize(this.tmpRectF)).build();
this.areCornerRadiiRtl = z;
setShapeAppearanceModel(build);
}
}
@Override // android.widget.LinearLayout, android.view.View
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
if (!this.globalLayoutListenerAdded) {
this.endLayout.getViewTreeObserver().addOnGlobalLayoutListener(this);
this.globalLayoutListenerAdded = true;
}
updatePlaceholderMeasurementsBasedOnEditText();
this.endLayout.updateSuffixTextViewPadding();
}
private boolean updateEditTextHeightBasedOnIcon() {
int max;
if (this.editText == null || this.editText.getMeasuredHeight() >= (max = Math.max(this.endLayout.getMeasuredHeight(), this.startLayout.getMeasuredHeight()))) {
return false;
}
this.editText.setMinimumHeight(max);
return true;
}
private void updatePlaceholderMeasurementsBasedOnEditText() {
EditText editText;
if (this.placeholderTextView == null || (editText = this.editText) == null) {
return;
}
this.placeholderTextView.setGravity(editText.getGravity());
this.placeholderTextView.setPadding(this.editText.getCompoundPaddingLeft(), this.editText.getCompoundPaddingTop(), this.editText.getCompoundPaddingRight(), this.editText.getCompoundPaddingBottom());
}
public void setStartIconDrawable(int i) {
setStartIconDrawable(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
}
public void setStartIconDrawable(Drawable drawable) {
this.startLayout.setStartIconDrawable(drawable);
}
public Drawable getStartIconDrawable() {
return this.startLayout.getStartIconDrawable();
}
public void setStartIconMinSize(int i) {
this.startLayout.setStartIconMinSize(i);
}
public int getStartIconMinSize() {
return this.startLayout.getStartIconMinSize();
}
public void setStartIconOnClickListener(View.OnClickListener onClickListener) {
this.startLayout.setStartIconOnClickListener(onClickListener);
}
public void setStartIconOnLongClickListener(View.OnLongClickListener onLongClickListener) {
this.startLayout.setStartIconOnLongClickListener(onLongClickListener);
}
public void setStartIconVisible(boolean z) {
this.startLayout.setStartIconVisible(z);
}
public boolean isStartIconVisible() {
return this.startLayout.isStartIconVisible();
}
public void refreshStartIconDrawableState() {
this.startLayout.refreshStartIconDrawableState();
}
public void setStartIconCheckable(boolean z) {
this.startLayout.setStartIconCheckable(z);
}
public boolean isStartIconCheckable() {
return this.startLayout.isStartIconCheckable();
}
public void setStartIconContentDescription(int i) {
setStartIconContentDescription(i != 0 ? getResources().getText(i) : null);
}
public void setStartIconContentDescription(CharSequence charSequence) {
this.startLayout.setStartIconContentDescription(charSequence);
}
public CharSequence getStartIconContentDescription() {
return this.startLayout.getStartIconContentDescription();
}
public void setStartIconTintList(ColorStateList colorStateList) {
this.startLayout.setStartIconTintList(colorStateList);
}
public void setStartIconTintMode(PorterDuff.Mode mode) {
this.startLayout.setStartIconTintMode(mode);
}
public void setEndIconMode(int i) {
this.endLayout.setEndIconMode(i);
}
public int getEndIconMode() {
return this.endLayout.getEndIconMode();
}
public void setEndIconOnClickListener(View.OnClickListener onClickListener) {
this.endLayout.setEndIconOnClickListener(onClickListener);
}
public void setErrorIconOnClickListener(View.OnClickListener onClickListener) {
this.endLayout.setErrorIconOnClickListener(onClickListener);
}
public void setEndIconOnLongClickListener(View.OnLongClickListener onLongClickListener) {
this.endLayout.setEndIconOnLongClickListener(onLongClickListener);
}
public void setErrorIconOnLongClickListener(View.OnLongClickListener onLongClickListener) {
this.endLayout.setErrorIconOnLongClickListener(onLongClickListener);
}
public void refreshErrorIconDrawableState() {
this.endLayout.refreshErrorIconDrawableState();
}
public void setEndIconVisible(boolean z) {
this.endLayout.setEndIconVisible(z);
}
public boolean isEndIconVisible() {
return this.endLayout.isEndIconVisible();
}
public void setEndIconActivated(boolean z) {
this.endLayout.setEndIconActivated(z);
}
public void refreshEndIconDrawableState() {
this.endLayout.refreshEndIconDrawableState();
}
public void setEndIconCheckable(boolean z) {
this.endLayout.setEndIconCheckable(z);
}
public boolean isEndIconCheckable() {
return this.endLayout.isEndIconCheckable();
}
public void setEndIconDrawable(int i) {
this.endLayout.setEndIconDrawable(i);
}
public void setEndIconDrawable(Drawable drawable) {
this.endLayout.setEndIconDrawable(drawable);
}
public Drawable getEndIconDrawable() {
return this.endLayout.getEndIconDrawable();
}
public void setEndIconMinSize(int i) {
this.endLayout.setEndIconMinSize(i);
}
public int getEndIconMinSize() {
return this.endLayout.getEndIconMinSize();
}
public void setStartIconScaleType(ImageView.ScaleType scaleType) {
this.startLayout.setStartIconScaleType(scaleType);
}
public ImageView.ScaleType getStartIconScaleType() {
return this.startLayout.getStartIconScaleType();
}
public void setEndIconScaleType(ImageView.ScaleType scaleType) {
this.endLayout.setEndIconScaleType(scaleType);
}
public ImageView.ScaleType getEndIconScaleType() {
return this.endLayout.getEndIconScaleType();
}
public void setEndIconContentDescription(int i) {
this.endLayout.setEndIconContentDescription(i);
}
public void setEndIconContentDescription(CharSequence charSequence) {
this.endLayout.setEndIconContentDescription(charSequence);
}
public CharSequence getEndIconContentDescription() {
return this.endLayout.getEndIconContentDescription();
}
public void setEndIconTintList(ColorStateList colorStateList) {
this.endLayout.setEndIconTintList(colorStateList);
}
public void setEndIconTintMode(PorterDuff.Mode mode) {
this.endLayout.setEndIconTintMode(mode);
}
public void addOnEndIconChangedListener(OnEndIconChangedListener onEndIconChangedListener) {
this.endLayout.addOnEndIconChangedListener(onEndIconChangedListener);
}
public void removeOnEndIconChangedListener(OnEndIconChangedListener onEndIconChangedListener) {
this.endLayout.removeOnEndIconChangedListener(onEndIconChangedListener);
}
public void clearOnEndIconChangedListeners() {
this.endLayout.clearOnEndIconChangedListeners();
}
public void addOnEditTextAttachedListener(OnEditTextAttachedListener onEditTextAttachedListener) {
this.editTextAttachedListeners.add(onEditTextAttachedListener);
if (this.editText != null) {
onEditTextAttachedListener.onEditTextAttached(this);
}
}
public void removeOnEditTextAttachedListener(OnEditTextAttachedListener onEditTextAttachedListener) {
this.editTextAttachedListeners.remove(onEditTextAttachedListener);
}
public void clearOnEditTextAttachedListeners() {
this.editTextAttachedListeners.clear();
}
@Deprecated
public void setPasswordVisibilityToggleDrawable(int i) {
this.endLayout.setPasswordVisibilityToggleDrawable(i);
}
@Deprecated
public void setPasswordVisibilityToggleDrawable(Drawable drawable) {
this.endLayout.setPasswordVisibilityToggleDrawable(drawable);
}
@Deprecated
public void setPasswordVisibilityToggleContentDescription(int i) {
this.endLayout.setPasswordVisibilityToggleContentDescription(i);
}
@Deprecated
public void setPasswordVisibilityToggleContentDescription(CharSequence charSequence) {
this.endLayout.setPasswordVisibilityToggleContentDescription(charSequence);
}
@Deprecated
public Drawable getPasswordVisibilityToggleDrawable() {
return this.endLayout.getPasswordVisibilityToggleDrawable();
}
@Deprecated
public CharSequence getPasswordVisibilityToggleContentDescription() {
return this.endLayout.getPasswordVisibilityToggleContentDescription();
}
@Deprecated
public boolean isPasswordVisibilityToggleEnabled() {
return this.endLayout.isPasswordVisibilityToggleEnabled();
}
@Deprecated
public void setPasswordVisibilityToggleEnabled(boolean z) {
this.endLayout.setPasswordVisibilityToggleEnabled(z);
}
@Deprecated
public void setPasswordVisibilityToggleTintList(ColorStateList colorStateList) {
this.endLayout.setPasswordVisibilityToggleTintList(colorStateList);
}
@Deprecated
public void setPasswordVisibilityToggleTintMode(PorterDuff.Mode mode) {
this.endLayout.setPasswordVisibilityToggleTintMode(mode);
}
@Deprecated
public void passwordVisibilityToggleRequested(boolean z) {
this.endLayout.togglePasswordVisibilityToggle(z);
}
public void setTextInputAccessibilityDelegate(AccessibilityDelegate accessibilityDelegate) {
EditText editText = this.editText;
if (editText != null) {
ViewCompat.setAccessibilityDelegate(editText, accessibilityDelegate);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public CheckableImageButton getEndIconView() {
return this.endLayout.getEndIconView();
}
private void dispatchOnEditTextAttached() {
Iterator<OnEditTextAttachedListener> it = this.editTextAttachedListeners.iterator();
while (it.hasNext()) {
it.next().onEditTextAttached(this);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public boolean updateDummyDrawables() {
boolean z;
if (this.editText == null) {
return false;
}
boolean z2 = true;
if (shouldUpdateStartDummyDrawable()) {
int measuredWidth = this.startLayout.getMeasuredWidth() - this.editText.getPaddingLeft();
if (this.startDummyDrawable == null || this.startDummyDrawableWidth != measuredWidth) {
ColorDrawable colorDrawable = new ColorDrawable();
this.startDummyDrawable = colorDrawable;
this.startDummyDrawableWidth = measuredWidth;
colorDrawable.setBounds(0, 0, measuredWidth, 1);
}
Drawable[] compoundDrawablesRelative = TextViewCompat.getCompoundDrawablesRelative(this.editText);
Drawable drawable = compoundDrawablesRelative[0];
Drawable drawable2 = this.startDummyDrawable;
if (drawable != drawable2) {
TextViewCompat.setCompoundDrawablesRelative(this.editText, drawable2, compoundDrawablesRelative[1], compoundDrawablesRelative[2], compoundDrawablesRelative[3]);
z = true;
}
z = false;
} else {
if (this.startDummyDrawable != null) {
Drawable[] compoundDrawablesRelative2 = TextViewCompat.getCompoundDrawablesRelative(this.editText);
TextViewCompat.setCompoundDrawablesRelative(this.editText, null, compoundDrawablesRelative2[1], compoundDrawablesRelative2[2], compoundDrawablesRelative2[3]);
this.startDummyDrawable = null;
z = true;
}
z = false;
}
if (shouldUpdateEndDummyDrawable()) {
int measuredWidth2 = this.endLayout.getSuffixTextView().getMeasuredWidth() - this.editText.getPaddingRight();
CheckableImageButton currentEndIconView = this.endLayout.getCurrentEndIconView();
if (currentEndIconView != null) {
measuredWidth2 = measuredWidth2 + currentEndIconView.getMeasuredWidth() + MarginLayoutParamsCompat.getMarginStart((ViewGroup.MarginLayoutParams) currentEndIconView.getLayoutParams());
}
Drawable[] compoundDrawablesRelative3 = TextViewCompat.getCompoundDrawablesRelative(this.editText);
Drawable drawable3 = this.endDummyDrawable;
if (drawable3 != null && this.endDummyDrawableWidth != measuredWidth2) {
this.endDummyDrawableWidth = measuredWidth2;
drawable3.setBounds(0, 0, measuredWidth2, 1);
TextViewCompat.setCompoundDrawablesRelative(this.editText, compoundDrawablesRelative3[0], compoundDrawablesRelative3[1], this.endDummyDrawable, compoundDrawablesRelative3[3]);
} else {
if (drawable3 == null) {
ColorDrawable colorDrawable2 = new ColorDrawable();
this.endDummyDrawable = colorDrawable2;
this.endDummyDrawableWidth = measuredWidth2;
colorDrawable2.setBounds(0, 0, measuredWidth2, 1);
}
Drawable drawable4 = compoundDrawablesRelative3[2];
Drawable drawable5 = this.endDummyDrawable;
if (drawable4 != drawable5) {
this.originalEditTextEndDrawable = drawable4;
TextViewCompat.setCompoundDrawablesRelative(this.editText, compoundDrawablesRelative3[0], compoundDrawablesRelative3[1], drawable5, compoundDrawablesRelative3[3]);
} else {
z2 = z;
}
}
} else {
if (this.endDummyDrawable == null) {
return z;
}
Drawable[] compoundDrawablesRelative4 = TextViewCompat.getCompoundDrawablesRelative(this.editText);
if (compoundDrawablesRelative4[2] == this.endDummyDrawable) {
TextViewCompat.setCompoundDrawablesRelative(this.editText, compoundDrawablesRelative4[0], compoundDrawablesRelative4[1], this.originalEditTextEndDrawable, compoundDrawablesRelative4[3]);
} else {
z2 = z;
}
this.endDummyDrawable = null;
}
return z2;
}
private boolean shouldUpdateStartDummyDrawable() {
return (getStartIconDrawable() != null || (getPrefixText() != null && getPrefixTextView().getVisibility() == 0)) && this.startLayout.getMeasuredWidth() > 0;
}
private boolean shouldUpdateEndDummyDrawable() {
return (this.endLayout.isErrorIconVisible() || ((this.endLayout.hasEndIcon() && isEndIconVisible()) || this.endLayout.getSuffixText() != null)) && this.endLayout.getMeasuredWidth() > 0;
}
@Override // android.widget.LinearLayout, android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
EditText editText = this.editText;
if (editText != null) {
Rect rect = this.tmpRect;
DescendantOffsetUtils.getDescendantRect(this, editText, rect);
updateBoxUnderlineBounds(rect);
if (this.hintEnabled) {
this.collapsingTextHelper.setExpandedTextSize(this.editText.getTextSize());
int gravity = this.editText.getGravity();
this.collapsingTextHelper.setCollapsedTextGravity((gravity & (-113)) | 48);
this.collapsingTextHelper.setExpandedTextGravity(gravity);
this.collapsingTextHelper.setCollapsedBounds(calculateCollapsedTextBounds(rect));
this.collapsingTextHelper.setExpandedBounds(calculateExpandedTextBounds(rect));
this.collapsingTextHelper.recalculate();
if (!cutoutEnabled() || this.hintExpanded) {
return;
}
openCutout();
}
}
}
private void updateBoxUnderlineBounds(Rect rect) {
if (this.boxUnderlineDefault != null) {
this.boxUnderlineDefault.setBounds(rect.left, rect.bottom - this.boxStrokeWidthDefaultPx, rect.right, rect.bottom);
}
if (this.boxUnderlineFocused != null) {
this.boxUnderlineFocused.setBounds(rect.left, rect.bottom - this.boxStrokeWidthFocusedPx, rect.right, rect.bottom);
}
}
@Override // android.view.View
public void draw(Canvas canvas) {
super.draw(canvas);
drawHint(canvas);
drawBoxUnderline(canvas);
}
@Override // android.view.View
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
this.collapsingTextHelper.maybeUpdateFontWeightAdjustment(configuration);
}
private void drawHint(Canvas canvas) {
if (this.hintEnabled) {
this.collapsingTextHelper.draw(canvas);
}
}
private void drawBoxUnderline(Canvas canvas) {
MaterialShapeDrawable materialShapeDrawable;
if (this.boxUnderlineFocused == null || (materialShapeDrawable = this.boxUnderlineDefault) == null) {
return;
}
materialShapeDrawable.draw(canvas);
if (this.editText.isFocused()) {
Rect bounds = this.boxUnderlineFocused.getBounds();
Rect bounds2 = this.boxUnderlineDefault.getBounds();
float expansionFraction = this.collapsingTextHelper.getExpansionFraction();
int centerX = bounds2.centerX();
bounds.left = AnimationUtils.lerp(centerX, bounds2.left, expansionFraction);
bounds.right = AnimationUtils.lerp(centerX, bounds2.right, expansionFraction);
this.boxUnderlineFocused.draw(canvas);
}
}
private void collapseHint(boolean z) {
ValueAnimator valueAnimator = this.animator;
if (valueAnimator != null && valueAnimator.isRunning()) {
this.animator.cancel();
}
if (z && this.hintAnimationEnabled) {
animateToExpansionFraction(1.0f);
} else {
this.collapsingTextHelper.setExpansionFraction(1.0f);
}
this.hintExpanded = false;
if (cutoutEnabled()) {
openCutout();
}
updatePlaceholderText();
this.startLayout.onHintStateChanged(false);
this.endLayout.onHintStateChanged(false);
}
private boolean cutoutEnabled() {
return this.hintEnabled && !TextUtils.isEmpty(this.hint) && (this.boxBackground instanceof CutoutDrawable);
}
private void openCutout() {
if (cutoutEnabled()) {
RectF rectF = this.tmpRectF;
this.collapsingTextHelper.getCollapsedTextActualBounds(rectF, this.editText.getWidth(), this.editText.getGravity());
if (rectF.width() <= 0.0f || rectF.height() <= 0.0f) {
return;
}
applyCutoutPadding(rectF);
rectF.offset(-getPaddingLeft(), ((-getPaddingTop()) - (rectF.height() / 2.0f)) + this.boxStrokeWidthPx);
((CutoutDrawable) this.boxBackground).setCutout(rectF);
}
}
private void recalculateCutout() {
if (!cutoutEnabled() || this.hintExpanded) {
return;
}
closeCutout();
openCutout();
}
private void closeCutout() {
if (cutoutEnabled()) {
((CutoutDrawable) this.boxBackground).removeCutout();
}
}
private void applyCutoutPadding(RectF rectF) {
rectF.left -= this.boxLabelCutoutPaddingPx;
rectF.right += this.boxLabelCutoutPaddingPx;
}
boolean cutoutIsOpen() {
return cutoutEnabled() && ((CutoutDrawable) this.boxBackground).hasCutout();
}
@Override // android.view.ViewGroup, android.view.View
protected void drawableStateChanged() {
if (this.inDrawableStateChanged) {
return;
}
this.inDrawableStateChanged = true;
super.drawableStateChanged();
int[] drawableState = getDrawableState();
CollapsingTextHelper collapsingTextHelper = this.collapsingTextHelper;
boolean state = collapsingTextHelper != null ? collapsingTextHelper.setState(drawableState) : false;
if (this.editText != null) {
updateLabelState(ViewCompat.isLaidOut(this) && isEnabled());
}
updateEditTextBackground();
updateTextInputBoxState();
if (state) {
invalidate();
}
this.inDrawableStateChanged = false;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void updateTextInputBoxState() {
TextView textView;
EditText editText;
EditText editText2;
if (this.boxBackground == null || this.boxBackgroundMode == 0) {
return;
}
boolean z = false;
boolean z2 = isFocused() || ((editText2 = this.editText) != null && editText2.hasFocus());
if (isHovered() || ((editText = this.editText) != null && editText.isHovered())) {
z = true;
}
if (!isEnabled()) {
this.boxStrokeColor = this.disabledColor;
} else if (shouldShowError()) {
if (this.strokeErrorColor != null) {
updateStrokeErrorColor(z2, z);
} else {
this.boxStrokeColor = getErrorCurrentTextColors();
}
} else if (!this.counterOverflowed || (textView = this.counterView) == null) {
if (z2) {
this.boxStrokeColor = this.focusedStrokeColor;
} else if (z) {
this.boxStrokeColor = this.hoveredStrokeColor;
} else {
this.boxStrokeColor = this.defaultStrokeColor;
}
} else if (this.strokeErrorColor != null) {
updateStrokeErrorColor(z2, z);
} else {
this.boxStrokeColor = textView.getCurrentTextColor();
}
updateCursorColor();
this.endLayout.onTextInputBoxStateUpdated();
refreshStartIconDrawableState();
if (this.boxBackgroundMode == 2) {
int i = this.boxStrokeWidthPx;
if (z2 && isEnabled()) {
this.boxStrokeWidthPx = this.boxStrokeWidthFocusedPx;
} else {
this.boxStrokeWidthPx = this.boxStrokeWidthDefaultPx;
}
if (this.boxStrokeWidthPx != i) {
recalculateCutout();
}
}
if (this.boxBackgroundMode == 1) {
if (!isEnabled()) {
this.boxBackgroundColor = this.disabledFilledBackgroundColor;
} else if (z && !z2) {
this.boxBackgroundColor = this.hoveredFilledBackgroundColor;
} else if (z2) {
this.boxBackgroundColor = this.focusedFilledBackgroundColor;
} else {
this.boxBackgroundColor = this.defaultFilledBackgroundColor;
}
}
applyBoxAttributes();
}
private boolean isOnError() {
return shouldShowError() || (this.counterView != null && this.counterOverflowed);
}
private void updateStrokeErrorColor(boolean z, boolean z2) {
int defaultColor = this.strokeErrorColor.getDefaultColor();
int colorForState = this.strokeErrorColor.getColorForState(new int[]{android.R.attr.state_hovered, android.R.attr.state_enabled}, defaultColor);
int colorForState2 = this.strokeErrorColor.getColorForState(new int[]{android.R.attr.state_activated, android.R.attr.state_enabled}, defaultColor);
if (z) {
this.boxStrokeColor = colorForState2;
} else if (z2) {
this.boxStrokeColor = colorForState;
} else {
this.boxStrokeColor = defaultColor;
}
}
private void updateCursorColor() {
ColorStateList colorStateList;
ColorStateList colorStateList2 = this.cursorColor;
if (colorStateList2 == null) {
colorStateList2 = MaterialColors.getColorStateListOrNull(getContext(), R.attr.colorControlActivated);
}
EditText editText = this.editText;
if (editText == null || editText.getTextCursorDrawable() == null) {
return;
}
Drawable mutate = DrawableCompat.wrap(this.editText.getTextCursorDrawable()).mutate();
if (isOnError() && (colorStateList = this.cursorErrorColor) != null) {
colorStateList2 = colorStateList;
}
DrawableCompat.setTintList(mutate, colorStateList2);
}
private void expandHint(boolean z) {
ValueAnimator valueAnimator = this.animator;
if (valueAnimator != null && valueAnimator.isRunning()) {
this.animator.cancel();
}
if (z && this.hintAnimationEnabled) {
animateToExpansionFraction(0.0f);
} else {
this.collapsingTextHelper.setExpansionFraction(0.0f);
}
if (cutoutEnabled() && ((CutoutDrawable) this.boxBackground).hasCutout()) {
closeCutout();
}
this.hintExpanded = true;
hidePlaceholderText();
this.startLayout.onHintStateChanged(true);
this.endLayout.onHintStateChanged(true);
}
void animateToExpansionFraction(float f) {
if (this.collapsingTextHelper.getExpansionFraction() == f) {
return;
}
if (this.animator == null) {
ValueAnimator valueAnimator = new ValueAnimator();
this.animator = valueAnimator;
valueAnimator.setInterpolator(MotionUtils.resolveThemeInterpolator(getContext(), R.attr.motionEasingEmphasizedInterpolator, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
this.animator.setDuration(MotionUtils.resolveThemeDuration(getContext(), R.attr.motionDurationMedium4, LABEL_SCALE_ANIMATION_DURATION));
this.animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.textfield.TextInputLayout.3
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator2) {
TextInputLayout.this.collapsingTextHelper.setExpansionFraction(((Float) valueAnimator2.getAnimatedValue()).floatValue());
}
});
}
this.animator.setFloatValues(this.collapsingTextHelper.getExpansionFraction(), f);
this.animator.start();
}
final boolean isHelperTextDisplayed() {
return this.indicatorViewController.helperTextIsDisplayed();
}
final int getHintCurrentCollapsedTextColor() {
return this.collapsingTextHelper.getCurrentCollapsedTextColor();
}
final float getHintCollapsedTextHeight() {
return this.collapsingTextHelper.getCollapsedTextHeight();
}
/* loaded from: classes2.dex */
public static class AccessibilityDelegate extends AccessibilityDelegateCompat {
private final TextInputLayout layout;
public AccessibilityDelegate(TextInputLayout textInputLayout) {
this.layout = textInputLayout;
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
EditText editText = this.layout.getEditText();
CharSequence text = editText != null ? editText.getText() : null;
CharSequence hint = this.layout.getHint();
CharSequence error = this.layout.getError();
CharSequence placeholderText = this.layout.getPlaceholderText();
int counterMaxLength = this.layout.getCounterMaxLength();
CharSequence counterOverflowDescription = this.layout.getCounterOverflowDescription();
boolean isEmpty = TextUtils.isEmpty(text);
boolean z = !isEmpty;
boolean z2 = true;
boolean z3 = !TextUtils.isEmpty(hint);
boolean z4 = !this.layout.isHintExpanded();
boolean z5 = !TextUtils.isEmpty(error);
if (!z5 && TextUtils.isEmpty(counterOverflowDescription)) {
z2 = false;
}
String charSequence = z3 ? hint.toString() : "";
this.layout.startLayout.setupAccessibilityNodeInfo(accessibilityNodeInfoCompat);
if (z) {
accessibilityNodeInfoCompat.setText(text);
} else if (!TextUtils.isEmpty(charSequence)) {
accessibilityNodeInfoCompat.setText(charSequence);
if (z4 && placeholderText != null) {
accessibilityNodeInfoCompat.setText(charSequence + ", " + ((Object) placeholderText));
}
} else if (placeholderText != null) {
accessibilityNodeInfoCompat.setText(placeholderText);
}
if (!TextUtils.isEmpty(charSequence)) {
accessibilityNodeInfoCompat.setHintText(charSequence);
accessibilityNodeInfoCompat.setShowingHintText(isEmpty);
}
if (text == null || text.length() != counterMaxLength) {
counterMaxLength = -1;
}
accessibilityNodeInfoCompat.setMaxTextLength(counterMaxLength);
if (z2) {
if (!z5) {
error = counterOverflowDescription;
}
accessibilityNodeInfoCompat.setError(error);
}
View helperTextView = this.layout.indicatorViewController.getHelperTextView();
if (helperTextView != null) {
accessibilityNodeInfoCompat.setLabelFor(helperTextView);
}
this.layout.endLayout.getEndIconDelegate().onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
super.onPopulateAccessibilityEvent(view, accessibilityEvent);
this.layout.endLayout.getEndIconDelegate().onPopulateAccessibilityEvent(view, accessibilityEvent);
}
}
}