ADD week 5
This commit is contained in:
@ -0,0 +1,223 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.text.Editable;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.motion.MotionUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ClearTextEndIconDelegate extends EndIconDelegate {
|
||||
private static final float ANIMATION_SCALE_FROM_VALUE = 0.8f;
|
||||
private static final int DEFAULT_ANIMATION_FADE_DURATION = 100;
|
||||
private static final int DEFAULT_ANIMATION_SCALE_DURATION = 150;
|
||||
private final int animationFadeDuration;
|
||||
private final TimeInterpolator animationFadeInterpolator;
|
||||
private final int animationScaleDuration;
|
||||
private final TimeInterpolator animationScaleInterpolator;
|
||||
private EditText editText;
|
||||
private AnimatorSet iconInAnim;
|
||||
private ValueAnimator iconOutAnim;
|
||||
private final View.OnFocusChangeListener onFocusChangeListener;
|
||||
private final View.OnClickListener onIconClickListener;
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
View.OnFocusChangeListener getOnEditTextFocusChangeListener() {
|
||||
return this.onFocusChangeListener;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
View.OnClickListener getOnIconClickListener() {
|
||||
return this.onIconClickListener;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
View.OnFocusChangeListener getOnIconViewFocusChangeListener() {
|
||||
return this.onFocusChangeListener;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$0$com-google-android-material-textfield-ClearTextEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m268xfc81bd94(View view) {
|
||||
EditText editText = this.editText;
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
Editable text = editText.getText();
|
||||
if (text != null) {
|
||||
text.clear();
|
||||
}
|
||||
refreshIconState();
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$1$com-google-android-material-textfield-ClearTextEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m269x7ae2c173(View view, boolean z) {
|
||||
animateIcon(shouldBeVisible());
|
||||
}
|
||||
|
||||
ClearTextEndIconDelegate(EndCompoundLayout endCompoundLayout) {
|
||||
super(endCompoundLayout);
|
||||
this.onIconClickListener = new View.OnClickListener() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate$$ExternalSyntheticLambda3
|
||||
@Override // android.view.View.OnClickListener
|
||||
public final void onClick(View view) {
|
||||
ClearTextEndIconDelegate.this.m268xfc81bd94(view);
|
||||
}
|
||||
};
|
||||
this.onFocusChangeListener = new View.OnFocusChangeListener() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate$$ExternalSyntheticLambda4
|
||||
@Override // android.view.View.OnFocusChangeListener
|
||||
public final void onFocusChange(View view, boolean z) {
|
||||
ClearTextEndIconDelegate.this.m269x7ae2c173(view, z);
|
||||
}
|
||||
};
|
||||
this.animationFadeDuration = MotionUtils.resolveThemeDuration(endCompoundLayout.getContext(), R.attr.motionDurationShort3, 100);
|
||||
this.animationScaleDuration = MotionUtils.resolveThemeDuration(endCompoundLayout.getContext(), R.attr.motionDurationShort3, DEFAULT_ANIMATION_SCALE_DURATION);
|
||||
this.animationFadeInterpolator = MotionUtils.resolveThemeInterpolator(endCompoundLayout.getContext(), R.attr.motionEasingLinearInterpolator, AnimationUtils.LINEAR_INTERPOLATOR);
|
||||
this.animationScaleInterpolator = MotionUtils.resolveThemeInterpolator(endCompoundLayout.getContext(), R.attr.motionEasingEmphasizedInterpolator, AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void setUp() {
|
||||
initAnimators();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void tearDown() {
|
||||
EditText editText = this.editText;
|
||||
if (editText != null) {
|
||||
editText.post(new Runnable() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate$$ExternalSyntheticLambda0
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
ClearTextEndIconDelegate.this.m270x26d8c5f4();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* renamed from: lambda$tearDown$2$com-google-android-material-textfield-ClearTextEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m270x26d8c5f4() {
|
||||
animateIcon(true);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
int getIconDrawableResId() {
|
||||
return R.drawable.mtrl_ic_cancel;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
int getIconContentDescriptionResId() {
|
||||
return R.string.clear_text_end_icon_content_description;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void onSuffixVisibilityChanged(boolean z) {
|
||||
if (this.endLayout.getSuffixText() == null) {
|
||||
return;
|
||||
}
|
||||
animateIcon(z);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
public void onEditTextAttached(EditText editText) {
|
||||
this.editText = editText;
|
||||
this.textInputLayout.setEndIconVisible(shouldBeVisible());
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void afterEditTextChanged(Editable editable) {
|
||||
if (this.endLayout.getSuffixText() != null) {
|
||||
return;
|
||||
}
|
||||
animateIcon(shouldBeVisible());
|
||||
}
|
||||
|
||||
private void animateIcon(boolean z) {
|
||||
boolean z2 = this.endLayout.isEndIconVisible() == z;
|
||||
if (z && !this.iconInAnim.isRunning()) {
|
||||
this.iconOutAnim.cancel();
|
||||
this.iconInAnim.start();
|
||||
if (z2) {
|
||||
this.iconInAnim.end();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (z) {
|
||||
return;
|
||||
}
|
||||
this.iconInAnim.cancel();
|
||||
this.iconOutAnim.start();
|
||||
if (z2) {
|
||||
this.iconOutAnim.end();
|
||||
}
|
||||
}
|
||||
|
||||
private void initAnimators() {
|
||||
ValueAnimator scaleAnimator = getScaleAnimator();
|
||||
ValueAnimator alphaAnimator = getAlphaAnimator(0.0f, 1.0f);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
this.iconInAnim = animatorSet;
|
||||
animatorSet.playTogether(scaleAnimator, alphaAnimator);
|
||||
this.iconInAnim.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
ClearTextEndIconDelegate.this.endLayout.setEndIconVisible(true);
|
||||
}
|
||||
});
|
||||
ValueAnimator alphaAnimator2 = getAlphaAnimator(1.0f, 0.0f);
|
||||
this.iconOutAnim = alphaAnimator2;
|
||||
alphaAnimator2.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
ClearTextEndIconDelegate.this.endLayout.setEndIconVisible(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ValueAnimator getAlphaAnimator(float... fArr) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
|
||||
ofFloat.setInterpolator(this.animationFadeInterpolator);
|
||||
ofFloat.setDuration(this.animationFadeDuration);
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate$$ExternalSyntheticLambda2
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
ClearTextEndIconDelegate.this.m266xa5c23ba8(valueAnimator);
|
||||
}
|
||||
});
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$getAlphaAnimator$3$com-google-android-material-textfield-ClearTextEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m266xa5c23ba8(ValueAnimator valueAnimator) {
|
||||
this.endIconView.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
|
||||
}
|
||||
|
||||
private ValueAnimator getScaleAnimator() {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(ANIMATION_SCALE_FROM_VALUE, 1.0f);
|
||||
ofFloat.setInterpolator(this.animationScaleInterpolator);
|
||||
ofFloat.setDuration(this.animationScaleDuration);
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.textfield.ClearTextEndIconDelegate$$ExternalSyntheticLambda1
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
ClearTextEndIconDelegate.this.m267x3819711b(valueAnimator);
|
||||
}
|
||||
});
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$getScaleAnimator$4$com-google-android-material-textfield-ClearTextEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m267x3819711b(ValueAnimator valueAnimator) {
|
||||
float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
|
||||
this.endIconView.setScaleX(floatValue);
|
||||
this.endIconView.setScaleY(floatValue);
|
||||
}
|
||||
|
||||
private boolean shouldBeVisible() {
|
||||
EditText editText = this.editText;
|
||||
return editText != null && (editText.hasFocus() || this.endIconView.hasFocus()) && this.editText.getText().length() > 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class CustomEndIconDelegate extends EndIconDelegate {
|
||||
CustomEndIconDelegate(EndCompoundLayout endCompoundLayout) {
|
||||
super(endCompoundLayout);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void setUp() {
|
||||
this.endLayout.setEndIconOnLongClickListener(null);
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class CutoutDrawable extends MaterialShapeDrawable {
|
||||
CutoutDrawableState drawableState;
|
||||
|
||||
static CutoutDrawable create(ShapeAppearanceModel shapeAppearanceModel) {
|
||||
if (shapeAppearanceModel == null) {
|
||||
shapeAppearanceModel = new ShapeAppearanceModel();
|
||||
}
|
||||
return create(new CutoutDrawableState(shapeAppearanceModel, new RectF()));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static CutoutDrawable create(CutoutDrawableState cutoutDrawableState) {
|
||||
return new ImplApi18(cutoutDrawableState);
|
||||
}
|
||||
|
||||
private CutoutDrawable(CutoutDrawableState cutoutDrawableState) {
|
||||
super(cutoutDrawableState);
|
||||
this.drawableState = cutoutDrawableState;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.MaterialShapeDrawable, android.graphics.drawable.Drawable
|
||||
public Drawable mutate() {
|
||||
this.drawableState = new CutoutDrawableState(this.drawableState);
|
||||
return this;
|
||||
}
|
||||
|
||||
boolean hasCutout() {
|
||||
return !this.drawableState.cutoutBounds.isEmpty();
|
||||
}
|
||||
|
||||
void setCutout(float f, float f2, float f3, float f4) {
|
||||
if (f == this.drawableState.cutoutBounds.left && f2 == this.drawableState.cutoutBounds.top && f3 == this.drawableState.cutoutBounds.right && f4 == this.drawableState.cutoutBounds.bottom) {
|
||||
return;
|
||||
}
|
||||
this.drawableState.cutoutBounds.set(f, f2, f3, f4);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
void setCutout(RectF rectF) {
|
||||
setCutout(rectF.left, rectF.top, rectF.right, rectF.bottom);
|
||||
}
|
||||
|
||||
void removeCutout() {
|
||||
setCutout(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
private static class ImplApi18 extends CutoutDrawable {
|
||||
ImplApi18(CutoutDrawableState cutoutDrawableState) {
|
||||
super(cutoutDrawableState);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.MaterialShapeDrawable
|
||||
protected void drawStrokeShape(Canvas canvas) {
|
||||
if (this.drawableState.cutoutBounds.isEmpty()) {
|
||||
super.drawStrokeShape(canvas);
|
||||
return;
|
||||
}
|
||||
canvas.save();
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
canvas.clipOutRect(this.drawableState.cutoutBounds);
|
||||
} else {
|
||||
canvas.clipRect(this.drawableState.cutoutBounds, Region.Op.DIFFERENCE);
|
||||
}
|
||||
super.drawStrokeShape(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ImplApi14 extends CutoutDrawable {
|
||||
private Paint cutoutPaint;
|
||||
private int savedLayer;
|
||||
|
||||
ImplApi14(CutoutDrawableState cutoutDrawableState) {
|
||||
super(cutoutDrawableState);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.MaterialShapeDrawable, android.graphics.drawable.Drawable
|
||||
public void draw(Canvas canvas) {
|
||||
preDraw(canvas);
|
||||
super.draw(canvas);
|
||||
postDraw(canvas);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.MaterialShapeDrawable
|
||||
protected void drawStrokeShape(Canvas canvas) {
|
||||
super.drawStrokeShape(canvas);
|
||||
canvas.drawRect(this.drawableState.cutoutBounds, getCutoutPaint());
|
||||
}
|
||||
|
||||
private Paint getCutoutPaint() {
|
||||
if (this.cutoutPaint == null) {
|
||||
Paint paint = new Paint(1);
|
||||
this.cutoutPaint = paint;
|
||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
this.cutoutPaint.setColor(-1);
|
||||
this.cutoutPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
|
||||
}
|
||||
return this.cutoutPaint;
|
||||
}
|
||||
|
||||
private void preDraw(Canvas canvas) {
|
||||
Drawable.Callback callback = getCallback();
|
||||
if (useHardwareLayer(callback)) {
|
||||
View view = (View) callback;
|
||||
if (view.getLayerType() != 2) {
|
||||
view.setLayerType(2, null);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
saveCanvasLayer(canvas);
|
||||
}
|
||||
|
||||
private void saveCanvasLayer(Canvas canvas) {
|
||||
this.savedLayer = canvas.saveLayer(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight(), null);
|
||||
}
|
||||
|
||||
private void postDraw(Canvas canvas) {
|
||||
if (useHardwareLayer(getCallback())) {
|
||||
return;
|
||||
}
|
||||
canvas.restoreToCount(this.savedLayer);
|
||||
}
|
||||
|
||||
private boolean useHardwareLayer(Drawable.Callback callback) {
|
||||
return callback instanceof View;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CutoutDrawableState extends MaterialShapeDrawable.MaterialShapeDrawableState {
|
||||
private final RectF cutoutBounds;
|
||||
|
||||
private CutoutDrawableState(ShapeAppearanceModel shapeAppearanceModel, RectF rectF) {
|
||||
super(shapeAppearanceModel, null);
|
||||
this.cutoutBounds = rectF;
|
||||
}
|
||||
|
||||
private CutoutDrawableState(CutoutDrawableState cutoutDrawableState) {
|
||||
super(cutoutDrawableState);
|
||||
this.cutoutBounds = cutoutDrawableState.cutoutBounds;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.shape.MaterialShapeDrawable.MaterialShapeDrawableState, android.graphics.drawable.Drawable.ConstantState
|
||||
public Drawable newDrawable() {
|
||||
CutoutDrawable create = CutoutDrawable.create(this);
|
||||
create.invalidateSelf();
|
||||
return create;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,335 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Editable;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityManagerCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.motion.MotionUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class DropdownMenuEndIconDelegate extends EndIconDelegate {
|
||||
private static final int DEFAULT_ANIMATION_FADE_IN_DURATION = 67;
|
||||
private static final int DEFAULT_ANIMATION_FADE_OUT_DURATION = 50;
|
||||
private static final boolean IS_LOLLIPOP = true;
|
||||
private AccessibilityManager accessibilityManager;
|
||||
private final int animationFadeInDuration;
|
||||
private final TimeInterpolator animationFadeInterpolator;
|
||||
private final int animationFadeOutDuration;
|
||||
private AutoCompleteTextView autoCompleteTextView;
|
||||
private long dropdownPopupActivatedAt;
|
||||
private boolean dropdownPopupDirty;
|
||||
private boolean editTextHasFocus;
|
||||
private ValueAnimator fadeInAnim;
|
||||
private ValueAnimator fadeOutAnim;
|
||||
private boolean isEndIconChecked;
|
||||
private final View.OnFocusChangeListener onEditTextFocusChangeListener;
|
||||
private final View.OnClickListener onIconClickListener;
|
||||
private final AccessibilityManagerCompat.TouchExplorationStateChangeListener touchExplorationStateChangeListener;
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
View.OnFocusChangeListener getOnEditTextFocusChangeListener() {
|
||||
return this.onEditTextFocusChangeListener;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
View.OnClickListener getOnIconClickListener() {
|
||||
return this.onIconClickListener;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
public AccessibilityManagerCompat.TouchExplorationStateChangeListener getTouchExplorationStateChangeListener() {
|
||||
return this.touchExplorationStateChangeListener;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isBoxBackgroundModeSupported(int i) {
|
||||
return i != 0;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isIconActivable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isIconActivated() {
|
||||
return this.editTextHasFocus;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isIconCheckable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isIconChecked() {
|
||||
return this.isEndIconChecked;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean shouldTintIconOnError() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$0$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m273xd03fedd4(View view) {
|
||||
showHideDropdown();
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$1$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m274xac016995(View view, boolean z) {
|
||||
this.editTextHasFocus = z;
|
||||
refreshIconState();
|
||||
if (z) {
|
||||
return;
|
||||
}
|
||||
setEndIconChecked(false);
|
||||
this.dropdownPopupDirty = false;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$2$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m275x87c2e556(boolean z) {
|
||||
AutoCompleteTextView autoCompleteTextView = this.autoCompleteTextView;
|
||||
if (autoCompleteTextView == null || EditTextUtils.isEditable(autoCompleteTextView)) {
|
||||
return;
|
||||
}
|
||||
ViewCompat.setImportantForAccessibility(this.endIconView, z ? 2 : 1);
|
||||
}
|
||||
|
||||
DropdownMenuEndIconDelegate(EndCompoundLayout endCompoundLayout) {
|
||||
super(endCompoundLayout);
|
||||
this.onIconClickListener = new View.OnClickListener() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda0
|
||||
@Override // android.view.View.OnClickListener
|
||||
public final void onClick(View view) {
|
||||
DropdownMenuEndIconDelegate.this.m273xd03fedd4(view);
|
||||
}
|
||||
};
|
||||
this.onEditTextFocusChangeListener = new View.OnFocusChangeListener() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda1
|
||||
@Override // android.view.View.OnFocusChangeListener
|
||||
public final void onFocusChange(View view, boolean z) {
|
||||
DropdownMenuEndIconDelegate.this.m274xac016995(view, z);
|
||||
}
|
||||
};
|
||||
this.touchExplorationStateChangeListener = new AccessibilityManagerCompat.TouchExplorationStateChangeListener() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda2
|
||||
@Override // androidx.core.view.accessibility.AccessibilityManagerCompat.TouchExplorationStateChangeListener
|
||||
public final void onTouchExplorationStateChanged(boolean z) {
|
||||
DropdownMenuEndIconDelegate.this.m275x87c2e556(z);
|
||||
}
|
||||
};
|
||||
this.dropdownPopupActivatedAt = Long.MAX_VALUE;
|
||||
this.animationFadeInDuration = MotionUtils.resolveThemeDuration(endCompoundLayout.getContext(), R.attr.motionDurationShort3, 67);
|
||||
this.animationFadeOutDuration = MotionUtils.resolveThemeDuration(endCompoundLayout.getContext(), R.attr.motionDurationShort3, 50);
|
||||
this.animationFadeInterpolator = MotionUtils.resolveThemeInterpolator(endCompoundLayout.getContext(), R.attr.motionEasingLinearInterpolator, AnimationUtils.LINEAR_INTERPOLATOR);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void setUp() {
|
||||
initAnimators();
|
||||
this.accessibilityManager = (AccessibilityManager) this.context.getSystemService("accessibility");
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void tearDown() {
|
||||
AutoCompleteTextView autoCompleteTextView = this.autoCompleteTextView;
|
||||
if (autoCompleteTextView != null) {
|
||||
autoCompleteTextView.setOnTouchListener(null);
|
||||
if (IS_LOLLIPOP) {
|
||||
this.autoCompleteTextView.setOnDismissListener(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
int getIconDrawableResId() {
|
||||
return IS_LOLLIPOP ? R.drawable.mtrl_dropdown_arrow : R.drawable.mtrl_ic_arrow_drop_down;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
int getIconContentDescriptionResId() {
|
||||
return R.string.exposed_dropdown_menu_content_description;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
public void onEditTextAttached(EditText editText) {
|
||||
this.autoCompleteTextView = castAutoCompleteTextViewOrThrow(editText);
|
||||
setUpDropdownShowHideBehavior();
|
||||
this.textInputLayout.setErrorIconDrawable((Drawable) null);
|
||||
if (!EditTextUtils.isEditable(editText) && this.accessibilityManager.isTouchExplorationEnabled()) {
|
||||
ViewCompat.setImportantForAccessibility(this.endIconView, 2);
|
||||
}
|
||||
this.textInputLayout.setEndIconVisible(true);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
public void afterEditTextChanged(Editable editable) {
|
||||
if (this.accessibilityManager.isTouchExplorationEnabled() && EditTextUtils.isEditable(this.autoCompleteTextView) && !this.endIconView.hasFocus()) {
|
||||
this.autoCompleteTextView.dismissDropDown();
|
||||
}
|
||||
this.autoCompleteTextView.post(new Runnable() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda4
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
DropdownMenuEndIconDelegate.this.m271xae660ff2();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* renamed from: lambda$afterEditTextChanged$3$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m271xae660ff2() {
|
||||
boolean isPopupShowing = this.autoCompleteTextView.isPopupShowing();
|
||||
setEndIconChecked(isPopupShowing);
|
||||
this.dropdownPopupDirty = isPopupShowing;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
if (!EditTextUtils.isEditable(this.autoCompleteTextView)) {
|
||||
accessibilityNodeInfoCompat.setClassName(Spinner.class.getName());
|
||||
}
|
||||
if (accessibilityNodeInfoCompat.isShowingHintText()) {
|
||||
accessibilityNodeInfoCompat.setHintText(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
|
||||
if (!this.accessibilityManager.isEnabled() || EditTextUtils.isEditable(this.autoCompleteTextView)) {
|
||||
return;
|
||||
}
|
||||
boolean z = accessibilityEvent.getEventType() == 32768 && this.isEndIconChecked && !this.autoCompleteTextView.isPopupShowing();
|
||||
if (accessibilityEvent.getEventType() == 1 || z) {
|
||||
showHideDropdown();
|
||||
updateDropdownPopupDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void showHideDropdown() {
|
||||
if (this.autoCompleteTextView == null) {
|
||||
return;
|
||||
}
|
||||
if (isDropdownPopupActive()) {
|
||||
this.dropdownPopupDirty = false;
|
||||
}
|
||||
if (this.dropdownPopupDirty) {
|
||||
this.dropdownPopupDirty = false;
|
||||
return;
|
||||
}
|
||||
if (IS_LOLLIPOP) {
|
||||
setEndIconChecked(!this.isEndIconChecked);
|
||||
} else {
|
||||
this.isEndIconChecked = !this.isEndIconChecked;
|
||||
refreshIconState();
|
||||
}
|
||||
if (this.isEndIconChecked) {
|
||||
this.autoCompleteTextView.requestFocus();
|
||||
this.autoCompleteTextView.showDropDown();
|
||||
} else {
|
||||
this.autoCompleteTextView.dismissDropDown();
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpDropdownShowHideBehavior() {
|
||||
this.autoCompleteTextView.setOnTouchListener(new View.OnTouchListener() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda5
|
||||
@Override // android.view.View.OnTouchListener
|
||||
public final boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return DropdownMenuEndIconDelegate.this.m276x5f2e2537(view, motionEvent);
|
||||
}
|
||||
});
|
||||
if (IS_LOLLIPOP) {
|
||||
this.autoCompleteTextView.setOnDismissListener(new AutoCompleteTextView.OnDismissListener() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda6
|
||||
@Override // android.widget.AutoCompleteTextView.OnDismissListener
|
||||
public final void onDismiss() {
|
||||
DropdownMenuEndIconDelegate.this.m277x3aefa0f8();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.autoCompleteTextView.setThreshold(0);
|
||||
}
|
||||
|
||||
/* renamed from: lambda$setUpDropdownShowHideBehavior$4$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ boolean m276x5f2e2537(View view, MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == 1) {
|
||||
if (isDropdownPopupActive()) {
|
||||
this.dropdownPopupDirty = false;
|
||||
}
|
||||
showHideDropdown();
|
||||
updateDropdownPopupDirty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$setUpDropdownShowHideBehavior$5$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m277x3aefa0f8() {
|
||||
updateDropdownPopupDirty();
|
||||
setEndIconChecked(false);
|
||||
}
|
||||
|
||||
private boolean isDropdownPopupActive() {
|
||||
long currentTimeMillis = System.currentTimeMillis() - this.dropdownPopupActivatedAt;
|
||||
return currentTimeMillis < 0 || currentTimeMillis > 300;
|
||||
}
|
||||
|
||||
private static AutoCompleteTextView castAutoCompleteTextViewOrThrow(EditText editText) {
|
||||
if (!(editText instanceof AutoCompleteTextView)) {
|
||||
throw new RuntimeException("EditText needs to be an AutoCompleteTextView if an Exposed Dropdown Menu is being used.");
|
||||
}
|
||||
return (AutoCompleteTextView) editText;
|
||||
}
|
||||
|
||||
private void updateDropdownPopupDirty() {
|
||||
this.dropdownPopupDirty = true;
|
||||
this.dropdownPopupActivatedAt = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void setEndIconChecked(boolean z) {
|
||||
if (this.isEndIconChecked != z) {
|
||||
this.isEndIconChecked = z;
|
||||
this.fadeInAnim.cancel();
|
||||
this.fadeOutAnim.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void initAnimators() {
|
||||
this.fadeInAnim = getAlphaAnimator(this.animationFadeInDuration, 0.0f, 1.0f);
|
||||
ValueAnimator alphaAnimator = getAlphaAnimator(this.animationFadeOutDuration, 1.0f, 0.0f);
|
||||
this.fadeOutAnim = alphaAnimator;
|
||||
alphaAnimator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
DropdownMenuEndIconDelegate.this.refreshIconState();
|
||||
DropdownMenuEndIconDelegate.this.fadeInAnim.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ValueAnimator getAlphaAnimator(int i, float... fArr) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
|
||||
ofFloat.setInterpolator(this.animationFadeInterpolator);
|
||||
ofFloat.setDuration(i);
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.textfield.DropdownMenuEndIconDelegate$$ExternalSyntheticLambda3
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
DropdownMenuEndIconDelegate.this.m272x6b943a83(valueAnimator);
|
||||
}
|
||||
});
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$getAlphaAnimator$6$com-google-android-material-textfield-DropdownMenuEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m272x6b943a83(ValueAnimator valueAnimator) {
|
||||
this.endIconView.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.widget.EditText;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class EditTextUtils {
|
||||
private EditTextUtils() {
|
||||
}
|
||||
|
||||
static boolean isEditable(EditText editText) {
|
||||
return editText.getInputType() != 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,704 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
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.AppCompatTextView;
|
||||
import androidx.appcompat.widget.TintTypedArray;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.MarginLayoutParamsCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityManagerCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.CheckableImageButton;
|
||||
import com.google.android.material.internal.TextWatcherAdapter;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class EndCompoundLayout extends LinearLayout {
|
||||
private final AccessibilityManager accessibilityManager;
|
||||
private EditText editText;
|
||||
private final TextWatcher editTextWatcher;
|
||||
private final LinkedHashSet<TextInputLayout.OnEndIconChangedListener> endIconChangedListeners;
|
||||
private final EndIconDelegates endIconDelegates;
|
||||
private final FrameLayout endIconFrame;
|
||||
private int endIconMinSize;
|
||||
private int endIconMode;
|
||||
private View.OnLongClickListener endIconOnLongClickListener;
|
||||
private ImageView.ScaleType endIconScaleType;
|
||||
private ColorStateList endIconTintList;
|
||||
private PorterDuff.Mode endIconTintMode;
|
||||
private final CheckableImageButton endIconView;
|
||||
private View.OnLongClickListener errorIconOnLongClickListener;
|
||||
private ColorStateList errorIconTintList;
|
||||
private PorterDuff.Mode errorIconTintMode;
|
||||
private final CheckableImageButton errorIconView;
|
||||
private boolean hintExpanded;
|
||||
private final TextInputLayout.OnEditTextAttachedListener onEditTextAttachedListener;
|
||||
private CharSequence suffixText;
|
||||
private final TextView suffixTextView;
|
||||
final TextInputLayout textInputLayout;
|
||||
private AccessibilityManagerCompat.TouchExplorationStateChangeListener touchExplorationStateChangeListener;
|
||||
|
||||
int getEndIconMinSize() {
|
||||
return this.endIconMinSize;
|
||||
}
|
||||
|
||||
int getEndIconMode() {
|
||||
return this.endIconMode;
|
||||
}
|
||||
|
||||
ImageView.ScaleType getEndIconScaleType() {
|
||||
return this.endIconScaleType;
|
||||
}
|
||||
|
||||
CheckableImageButton getEndIconView() {
|
||||
return this.endIconView;
|
||||
}
|
||||
|
||||
CharSequence getSuffixText() {
|
||||
return this.suffixText;
|
||||
}
|
||||
|
||||
TextView getSuffixTextView() {
|
||||
return this.suffixTextView;
|
||||
}
|
||||
|
||||
boolean hasEndIcon() {
|
||||
return this.endIconMode != 0;
|
||||
}
|
||||
|
||||
boolean isPasswordVisibilityToggleEnabled() {
|
||||
return this.endIconMode == 1;
|
||||
}
|
||||
|
||||
EndCompoundLayout(TextInputLayout textInputLayout, TintTypedArray tintTypedArray) {
|
||||
super(textInputLayout.getContext());
|
||||
this.endIconMode = 0;
|
||||
this.endIconChangedListeners = new LinkedHashSet<>();
|
||||
this.editTextWatcher = new TextWatcherAdapter() { // from class: com.google.android.material.textfield.EndCompoundLayout.1
|
||||
@Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
EndCompoundLayout.this.getEndIconDelegate().beforeEditTextChanged(charSequence, i, i2, i3);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher
|
||||
public void afterTextChanged(Editable editable) {
|
||||
EndCompoundLayout.this.getEndIconDelegate().afterEditTextChanged(editable);
|
||||
}
|
||||
};
|
||||
TextInputLayout.OnEditTextAttachedListener onEditTextAttachedListener = new TextInputLayout.OnEditTextAttachedListener() { // from class: com.google.android.material.textfield.EndCompoundLayout.2
|
||||
@Override // com.google.android.material.textfield.TextInputLayout.OnEditTextAttachedListener
|
||||
public void onEditTextAttached(TextInputLayout textInputLayout2) {
|
||||
if (EndCompoundLayout.this.editText == textInputLayout2.getEditText()) {
|
||||
return;
|
||||
}
|
||||
if (EndCompoundLayout.this.editText != null) {
|
||||
EndCompoundLayout.this.editText.removeTextChangedListener(EndCompoundLayout.this.editTextWatcher);
|
||||
if (EndCompoundLayout.this.editText.getOnFocusChangeListener() == EndCompoundLayout.this.getEndIconDelegate().getOnEditTextFocusChangeListener()) {
|
||||
EndCompoundLayout.this.editText.setOnFocusChangeListener(null);
|
||||
}
|
||||
}
|
||||
EndCompoundLayout.this.editText = textInputLayout2.getEditText();
|
||||
if (EndCompoundLayout.this.editText != null) {
|
||||
EndCompoundLayout.this.editText.addTextChangedListener(EndCompoundLayout.this.editTextWatcher);
|
||||
}
|
||||
EndCompoundLayout.this.getEndIconDelegate().onEditTextAttached(EndCompoundLayout.this.editText);
|
||||
EndCompoundLayout endCompoundLayout = EndCompoundLayout.this;
|
||||
endCompoundLayout.setOnFocusChangeListenersIfNeeded(endCompoundLayout.getEndIconDelegate());
|
||||
}
|
||||
};
|
||||
this.onEditTextAttachedListener = onEditTextAttachedListener;
|
||||
this.accessibilityManager = (AccessibilityManager) getContext().getSystemService("accessibility");
|
||||
this.textInputLayout = textInputLayout;
|
||||
setVisibility(8);
|
||||
setOrientation(0);
|
||||
setLayoutParams(new FrameLayout.LayoutParams(-2, -1, GravityCompat.END));
|
||||
FrameLayout frameLayout = new FrameLayout(getContext());
|
||||
this.endIconFrame = frameLayout;
|
||||
frameLayout.setVisibility(8);
|
||||
frameLayout.setLayoutParams(new LinearLayout.LayoutParams(-2, -1));
|
||||
LayoutInflater from = LayoutInflater.from(getContext());
|
||||
CheckableImageButton createIconView = createIconView(this, from, R.id.text_input_error_icon);
|
||||
this.errorIconView = createIconView;
|
||||
CheckableImageButton createIconView2 = createIconView(frameLayout, from, R.id.text_input_end_icon);
|
||||
this.endIconView = createIconView2;
|
||||
this.endIconDelegates = new EndIconDelegates(this, tintTypedArray);
|
||||
AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
|
||||
this.suffixTextView = appCompatTextView;
|
||||
initErrorIconView(tintTypedArray);
|
||||
initEndIconView(tintTypedArray);
|
||||
initSuffixTextView(tintTypedArray);
|
||||
frameLayout.addView(createIconView2);
|
||||
addView(appCompatTextView);
|
||||
addView(frameLayout);
|
||||
addView(createIconView);
|
||||
textInputLayout.addOnEditTextAttachedListener(onEditTextAttachedListener);
|
||||
addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { // from class: com.google.android.material.textfield.EndCompoundLayout.3
|
||||
@Override // android.view.View.OnAttachStateChangeListener
|
||||
public void onViewAttachedToWindow(View view) {
|
||||
EndCompoundLayout.this.addTouchExplorationStateChangeListenerIfNeeded();
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnAttachStateChangeListener
|
||||
public void onViewDetachedFromWindow(View view) {
|
||||
EndCompoundLayout.this.removeTouchExplorationStateChangeListenerIfNeeded();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CheckableImageButton createIconView(ViewGroup viewGroup, LayoutInflater layoutInflater, int i) {
|
||||
CheckableImageButton checkableImageButton = (CheckableImageButton) layoutInflater.inflate(R.layout.design_text_input_end_icon, viewGroup, false);
|
||||
checkableImageButton.setId(i);
|
||||
IconHelper.setCompatRippleBackgroundIfNeeded(checkableImageButton);
|
||||
if (MaterialResources.isFontScaleAtLeast1_3(getContext())) {
|
||||
MarginLayoutParamsCompat.setMarginStart((ViewGroup.MarginLayoutParams) checkableImageButton.getLayoutParams(), 0);
|
||||
}
|
||||
return checkableImageButton;
|
||||
}
|
||||
|
||||
private void initErrorIconView(TintTypedArray tintTypedArray) {
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_errorIconTint)) {
|
||||
this.errorIconTintList = MaterialResources.getColorStateList(getContext(), tintTypedArray, R.styleable.TextInputLayout_errorIconTint);
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_errorIconTintMode)) {
|
||||
this.errorIconTintMode = ViewUtils.parseTintMode(tintTypedArray.getInt(R.styleable.TextInputLayout_errorIconTintMode, -1), null);
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_errorIconDrawable)) {
|
||||
setErrorIconDrawable(tintTypedArray.getDrawable(R.styleable.TextInputLayout_errorIconDrawable));
|
||||
}
|
||||
this.errorIconView.setContentDescription(getResources().getText(R.string.error_icon_content_description));
|
||||
ViewCompat.setImportantForAccessibility(this.errorIconView, 2);
|
||||
this.errorIconView.setClickable(false);
|
||||
this.errorIconView.setPressable(false);
|
||||
this.errorIconView.setFocusable(false);
|
||||
}
|
||||
|
||||
private void initEndIconView(TintTypedArray tintTypedArray) {
|
||||
if (!tintTypedArray.hasValue(R.styleable.TextInputLayout_passwordToggleEnabled)) {
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_endIconTint)) {
|
||||
this.endIconTintList = MaterialResources.getColorStateList(getContext(), tintTypedArray, R.styleable.TextInputLayout_endIconTint);
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_endIconTintMode)) {
|
||||
this.endIconTintMode = ViewUtils.parseTintMode(tintTypedArray.getInt(R.styleable.TextInputLayout_endIconTintMode, -1), null);
|
||||
}
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_endIconMode)) {
|
||||
setEndIconMode(tintTypedArray.getInt(R.styleable.TextInputLayout_endIconMode, 0));
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_endIconContentDescription)) {
|
||||
setEndIconContentDescription(tintTypedArray.getText(R.styleable.TextInputLayout_endIconContentDescription));
|
||||
}
|
||||
setEndIconCheckable(tintTypedArray.getBoolean(R.styleable.TextInputLayout_endIconCheckable, true));
|
||||
} else if (tintTypedArray.hasValue(R.styleable.TextInputLayout_passwordToggleEnabled)) {
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) {
|
||||
this.endIconTintList = MaterialResources.getColorStateList(getContext(), tintTypedArray, R.styleable.TextInputLayout_passwordToggleTint);
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) {
|
||||
this.endIconTintMode = ViewUtils.parseTintMode(tintTypedArray.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null);
|
||||
}
|
||||
setEndIconMode(tintTypedArray.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false) ? 1 : 0);
|
||||
setEndIconContentDescription(tintTypedArray.getText(R.styleable.TextInputLayout_passwordToggleContentDescription));
|
||||
}
|
||||
setEndIconMinSize(tintTypedArray.getDimensionPixelSize(R.styleable.TextInputLayout_endIconMinSize, getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size)));
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_endIconScaleType)) {
|
||||
setEndIconScaleType(IconHelper.convertScaleType(tintTypedArray.getInt(R.styleable.TextInputLayout_endIconScaleType, -1)));
|
||||
}
|
||||
}
|
||||
|
||||
private void initSuffixTextView(TintTypedArray tintTypedArray) {
|
||||
this.suffixTextView.setVisibility(8);
|
||||
this.suffixTextView.setId(R.id.textinput_suffix_text);
|
||||
this.suffixTextView.setLayoutParams(new LinearLayout.LayoutParams(-2, -2, 80.0f));
|
||||
ViewCompat.setAccessibilityLiveRegion(this.suffixTextView, 1);
|
||||
setSuffixTextAppearance(tintTypedArray.getResourceId(R.styleable.TextInputLayout_suffixTextAppearance, 0));
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_suffixTextColor)) {
|
||||
setSuffixTextColor(tintTypedArray.getColorStateList(R.styleable.TextInputLayout_suffixTextColor));
|
||||
}
|
||||
setSuffixText(tintTypedArray.getText(R.styleable.TextInputLayout_suffixText));
|
||||
}
|
||||
|
||||
void setErrorIconDrawable(int i) {
|
||||
setErrorIconDrawable(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
|
||||
refreshErrorIconDrawableState();
|
||||
}
|
||||
|
||||
void setErrorIconDrawable(Drawable drawable) {
|
||||
this.errorIconView.setImageDrawable(drawable);
|
||||
updateErrorIconVisibility();
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.errorIconView, this.errorIconTintList, this.errorIconTintMode);
|
||||
}
|
||||
|
||||
Drawable getErrorIconDrawable() {
|
||||
return this.errorIconView.getDrawable();
|
||||
}
|
||||
|
||||
void setErrorIconTintList(ColorStateList colorStateList) {
|
||||
if (this.errorIconTintList != colorStateList) {
|
||||
this.errorIconTintList = colorStateList;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.errorIconView, colorStateList, this.errorIconTintMode);
|
||||
}
|
||||
}
|
||||
|
||||
void setErrorIconTintMode(PorterDuff.Mode mode) {
|
||||
if (this.errorIconTintMode != mode) {
|
||||
this.errorIconTintMode = mode;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.errorIconView, this.errorIconTintList, mode);
|
||||
}
|
||||
}
|
||||
|
||||
void setErrorIconOnClickListener(View.OnClickListener onClickListener) {
|
||||
IconHelper.setIconOnClickListener(this.errorIconView, onClickListener, this.errorIconOnLongClickListener);
|
||||
}
|
||||
|
||||
EndIconDelegate getEndIconDelegate() {
|
||||
return this.endIconDelegates.get(this.endIconMode);
|
||||
}
|
||||
|
||||
void setEndIconMode(int i) {
|
||||
if (this.endIconMode == i) {
|
||||
return;
|
||||
}
|
||||
tearDownDelegate(getEndIconDelegate());
|
||||
int i2 = this.endIconMode;
|
||||
this.endIconMode = i;
|
||||
dispatchOnEndIconChanged(i2);
|
||||
setEndIconVisible(i != 0);
|
||||
EndIconDelegate endIconDelegate = getEndIconDelegate();
|
||||
setEndIconDrawable(getIconResId(endIconDelegate));
|
||||
setEndIconContentDescription(endIconDelegate.getIconContentDescriptionResId());
|
||||
setEndIconCheckable(endIconDelegate.isIconCheckable());
|
||||
if (endIconDelegate.isBoxBackgroundModeSupported(this.textInputLayout.getBoxBackgroundMode())) {
|
||||
setUpDelegate(endIconDelegate);
|
||||
setEndIconOnClickListener(endIconDelegate.getOnIconClickListener());
|
||||
EditText editText = this.editText;
|
||||
if (editText != null) {
|
||||
endIconDelegate.onEditTextAttached(editText);
|
||||
setOnFocusChangeListenersIfNeeded(endIconDelegate);
|
||||
}
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, this.endIconTintList, this.endIconTintMode);
|
||||
refreshIconState(true);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("The current box background mode " + this.textInputLayout.getBoxBackgroundMode() + " is not supported by the end icon mode " + i);
|
||||
}
|
||||
|
||||
void refreshIconState(boolean z) {
|
||||
boolean z2;
|
||||
boolean isActivated;
|
||||
boolean isChecked;
|
||||
EndIconDelegate endIconDelegate = getEndIconDelegate();
|
||||
boolean z3 = true;
|
||||
if (!endIconDelegate.isIconCheckable() || (isChecked = this.endIconView.isChecked()) == endIconDelegate.isIconChecked()) {
|
||||
z2 = false;
|
||||
} else {
|
||||
this.endIconView.setChecked(!isChecked);
|
||||
z2 = true;
|
||||
}
|
||||
if (!endIconDelegate.isIconActivable() || (isActivated = this.endIconView.isActivated()) == endIconDelegate.isIconActivated()) {
|
||||
z3 = z2;
|
||||
} else {
|
||||
setEndIconActivated(!isActivated);
|
||||
}
|
||||
if (z || z3) {
|
||||
refreshEndIconDrawableState();
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpDelegate(EndIconDelegate endIconDelegate) {
|
||||
endIconDelegate.setUp();
|
||||
this.touchExplorationStateChangeListener = endIconDelegate.getTouchExplorationStateChangeListener();
|
||||
addTouchExplorationStateChangeListenerIfNeeded();
|
||||
}
|
||||
|
||||
private void tearDownDelegate(EndIconDelegate endIconDelegate) {
|
||||
removeTouchExplorationStateChangeListenerIfNeeded();
|
||||
this.touchExplorationStateChangeListener = null;
|
||||
endIconDelegate.tearDown();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void addTouchExplorationStateChangeListenerIfNeeded() {
|
||||
if (this.touchExplorationStateChangeListener == null || this.accessibilityManager == null || !ViewCompat.isAttachedToWindow(this)) {
|
||||
return;
|
||||
}
|
||||
AccessibilityManagerCompat.addTouchExplorationStateChangeListener(this.accessibilityManager, this.touchExplorationStateChangeListener);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void removeTouchExplorationStateChangeListenerIfNeeded() {
|
||||
AccessibilityManager accessibilityManager;
|
||||
AccessibilityManagerCompat.TouchExplorationStateChangeListener touchExplorationStateChangeListener = this.touchExplorationStateChangeListener;
|
||||
if (touchExplorationStateChangeListener == null || (accessibilityManager = this.accessibilityManager) == null) {
|
||||
return;
|
||||
}
|
||||
AccessibilityManagerCompat.removeTouchExplorationStateChangeListener(accessibilityManager, touchExplorationStateChangeListener);
|
||||
}
|
||||
|
||||
private int getIconResId(EndIconDelegate endIconDelegate) {
|
||||
int i = this.endIconDelegates.customEndIconDrawableId;
|
||||
return i == 0 ? endIconDelegate.getIconDrawableResId() : i;
|
||||
}
|
||||
|
||||
void setEndIconOnClickListener(View.OnClickListener onClickListener) {
|
||||
IconHelper.setIconOnClickListener(this.endIconView, onClickListener, this.endIconOnLongClickListener);
|
||||
}
|
||||
|
||||
void setEndIconOnLongClickListener(View.OnLongClickListener onLongClickListener) {
|
||||
this.endIconOnLongClickListener = onLongClickListener;
|
||||
IconHelper.setIconOnLongClickListener(this.endIconView, onLongClickListener);
|
||||
}
|
||||
|
||||
void setErrorIconOnLongClickListener(View.OnLongClickListener onLongClickListener) {
|
||||
this.errorIconOnLongClickListener = onLongClickListener;
|
||||
IconHelper.setIconOnLongClickListener(this.errorIconView, onLongClickListener);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setOnFocusChangeListenersIfNeeded(EndIconDelegate endIconDelegate) {
|
||||
if (this.editText == null) {
|
||||
return;
|
||||
}
|
||||
if (endIconDelegate.getOnEditTextFocusChangeListener() != null) {
|
||||
this.editText.setOnFocusChangeListener(endIconDelegate.getOnEditTextFocusChangeListener());
|
||||
}
|
||||
if (endIconDelegate.getOnIconViewFocusChangeListener() != null) {
|
||||
this.endIconView.setOnFocusChangeListener(endIconDelegate.getOnIconViewFocusChangeListener());
|
||||
}
|
||||
}
|
||||
|
||||
void refreshErrorIconDrawableState() {
|
||||
IconHelper.refreshIconDrawableState(this.textInputLayout, this.errorIconView, this.errorIconTintList);
|
||||
}
|
||||
|
||||
void setEndIconVisible(boolean z) {
|
||||
if (isEndIconVisible() != z) {
|
||||
this.endIconView.setVisibility(z ? 0 : 8);
|
||||
updateEndLayoutVisibility();
|
||||
updateSuffixTextViewPadding();
|
||||
this.textInputLayout.updateDummyDrawables();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isEndIconVisible() {
|
||||
return this.endIconFrame.getVisibility() == 0 && this.endIconView.getVisibility() == 0;
|
||||
}
|
||||
|
||||
void setEndIconActivated(boolean z) {
|
||||
this.endIconView.setActivated(z);
|
||||
}
|
||||
|
||||
void refreshEndIconDrawableState() {
|
||||
IconHelper.refreshIconDrawableState(this.textInputLayout, this.endIconView, this.endIconTintList);
|
||||
}
|
||||
|
||||
void setEndIconCheckable(boolean z) {
|
||||
this.endIconView.setCheckable(z);
|
||||
}
|
||||
|
||||
boolean isEndIconCheckable() {
|
||||
return this.endIconView.isCheckable();
|
||||
}
|
||||
|
||||
boolean isEndIconChecked() {
|
||||
return hasEndIcon() && this.endIconView.isChecked();
|
||||
}
|
||||
|
||||
void checkEndIcon() {
|
||||
this.endIconView.performClick();
|
||||
this.endIconView.jumpDrawablesToCurrentState();
|
||||
}
|
||||
|
||||
void setEndIconDrawable(int i) {
|
||||
setEndIconDrawable(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
|
||||
}
|
||||
|
||||
void setEndIconDrawable(Drawable drawable) {
|
||||
this.endIconView.setImageDrawable(drawable);
|
||||
if (drawable != null) {
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, this.endIconTintList, this.endIconTintMode);
|
||||
refreshEndIconDrawableState();
|
||||
}
|
||||
}
|
||||
|
||||
Drawable getEndIconDrawable() {
|
||||
return this.endIconView.getDrawable();
|
||||
}
|
||||
|
||||
void setEndIconContentDescription(int i) {
|
||||
setEndIconContentDescription(i != 0 ? getResources().getText(i) : null);
|
||||
}
|
||||
|
||||
void setEndIconContentDescription(CharSequence charSequence) {
|
||||
if (getEndIconContentDescription() != charSequence) {
|
||||
this.endIconView.setContentDescription(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence getEndIconContentDescription() {
|
||||
return this.endIconView.getContentDescription();
|
||||
}
|
||||
|
||||
void setEndIconTintList(ColorStateList colorStateList) {
|
||||
if (this.endIconTintList != colorStateList) {
|
||||
this.endIconTintList = colorStateList;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, colorStateList, this.endIconTintMode);
|
||||
}
|
||||
}
|
||||
|
||||
void setEndIconTintMode(PorterDuff.Mode mode) {
|
||||
if (this.endIconTintMode != mode) {
|
||||
this.endIconTintMode = mode;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, this.endIconTintList, mode);
|
||||
}
|
||||
}
|
||||
|
||||
void setEndIconMinSize(int i) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("endIconSize cannot be less than 0");
|
||||
}
|
||||
if (i != this.endIconMinSize) {
|
||||
this.endIconMinSize = i;
|
||||
IconHelper.setIconMinSize(this.endIconView, i);
|
||||
IconHelper.setIconMinSize(this.errorIconView, i);
|
||||
}
|
||||
}
|
||||
|
||||
void setEndIconScaleType(ImageView.ScaleType scaleType) {
|
||||
this.endIconScaleType = scaleType;
|
||||
IconHelper.setIconScaleType(this.endIconView, scaleType);
|
||||
IconHelper.setIconScaleType(this.errorIconView, scaleType);
|
||||
}
|
||||
|
||||
void addOnEndIconChangedListener(TextInputLayout.OnEndIconChangedListener onEndIconChangedListener) {
|
||||
this.endIconChangedListeners.add(onEndIconChangedListener);
|
||||
}
|
||||
|
||||
void removeOnEndIconChangedListener(TextInputLayout.OnEndIconChangedListener onEndIconChangedListener) {
|
||||
this.endIconChangedListeners.remove(onEndIconChangedListener);
|
||||
}
|
||||
|
||||
void clearOnEndIconChangedListeners() {
|
||||
this.endIconChangedListeners.clear();
|
||||
}
|
||||
|
||||
void setSuffixText(CharSequence charSequence) {
|
||||
this.suffixText = TextUtils.isEmpty(charSequence) ? null : charSequence;
|
||||
this.suffixTextView.setText(charSequence);
|
||||
updateSuffixTextVisibility();
|
||||
}
|
||||
|
||||
void setSuffixTextAppearance(int i) {
|
||||
TextViewCompat.setTextAppearance(this.suffixTextView, i);
|
||||
}
|
||||
|
||||
void setSuffixTextColor(ColorStateList colorStateList) {
|
||||
this.suffixTextView.setTextColor(colorStateList);
|
||||
}
|
||||
|
||||
ColorStateList getSuffixTextColor() {
|
||||
return this.suffixTextView.getTextColors();
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleDrawable(int i) {
|
||||
setPasswordVisibilityToggleDrawable(i != 0 ? AppCompatResources.getDrawable(getContext(), i) : null);
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleDrawable(Drawable drawable) {
|
||||
this.endIconView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleContentDescription(int i) {
|
||||
setPasswordVisibilityToggleContentDescription(i != 0 ? getResources().getText(i) : null);
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleContentDescription(CharSequence charSequence) {
|
||||
this.endIconView.setContentDescription(charSequence);
|
||||
}
|
||||
|
||||
Drawable getPasswordVisibilityToggleDrawable() {
|
||||
return this.endIconView.getDrawable();
|
||||
}
|
||||
|
||||
CharSequence getPasswordVisibilityToggleContentDescription() {
|
||||
return this.endIconView.getContentDescription();
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleEnabled(boolean z) {
|
||||
if (z && this.endIconMode != 1) {
|
||||
setEndIconMode(1);
|
||||
} else {
|
||||
if (z) {
|
||||
return;
|
||||
}
|
||||
setEndIconMode(0);
|
||||
}
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleTintList(ColorStateList colorStateList) {
|
||||
this.endIconTintList = colorStateList;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, colorStateList, this.endIconTintMode);
|
||||
}
|
||||
|
||||
void setPasswordVisibilityToggleTintMode(PorterDuff.Mode mode) {
|
||||
this.endIconTintMode = mode;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, this.endIconTintList, mode);
|
||||
}
|
||||
|
||||
void togglePasswordVisibilityToggle(boolean z) {
|
||||
if (this.endIconMode == 1) {
|
||||
this.endIconView.performClick();
|
||||
if (z) {
|
||||
this.endIconView.jumpDrawablesToCurrentState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onHintStateChanged(boolean z) {
|
||||
this.hintExpanded = z;
|
||||
updateSuffixTextVisibility();
|
||||
}
|
||||
|
||||
void onTextInputBoxStateUpdated() {
|
||||
updateErrorIconVisibility();
|
||||
refreshErrorIconDrawableState();
|
||||
refreshEndIconDrawableState();
|
||||
if (getEndIconDelegate().shouldTintIconOnError()) {
|
||||
tintEndIconOnError(this.textInputLayout.shouldShowError());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSuffixTextVisibility() {
|
||||
int visibility = this.suffixTextView.getVisibility();
|
||||
int i = (this.suffixText == null || this.hintExpanded) ? 8 : 0;
|
||||
if (visibility != i) {
|
||||
getEndIconDelegate().onSuffixVisibilityChanged(i == 0);
|
||||
}
|
||||
updateEndLayoutVisibility();
|
||||
this.suffixTextView.setVisibility(i);
|
||||
this.textInputLayout.updateDummyDrawables();
|
||||
}
|
||||
|
||||
void updateSuffixTextViewPadding() {
|
||||
if (this.textInputLayout.editText == null) {
|
||||
return;
|
||||
}
|
||||
ViewCompat.setPaddingRelative(this.suffixTextView, getContext().getResources().getDimensionPixelSize(R.dimen.material_input_text_to_prefix_suffix_padding), this.textInputLayout.editText.getPaddingTop(), (isEndIconVisible() || isErrorIconVisible()) ? 0 : ViewCompat.getPaddingEnd(this.textInputLayout.editText), this.textInputLayout.editText.getPaddingBottom());
|
||||
}
|
||||
|
||||
int getSuffixTextEndOffset() {
|
||||
return ViewCompat.getPaddingEnd(this) + ViewCompat.getPaddingEnd(this.suffixTextView) + ((isEndIconVisible() || isErrorIconVisible()) ? this.endIconView.getMeasuredWidth() + MarginLayoutParamsCompat.getMarginStart((ViewGroup.MarginLayoutParams) this.endIconView.getLayoutParams()) : 0);
|
||||
}
|
||||
|
||||
CheckableImageButton getCurrentEndIconView() {
|
||||
if (isErrorIconVisible()) {
|
||||
return this.errorIconView;
|
||||
}
|
||||
if (hasEndIcon() && isEndIconVisible()) {
|
||||
return this.endIconView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isErrorIconVisible() {
|
||||
return this.errorIconView.getVisibility() == 0;
|
||||
}
|
||||
|
||||
private void updateErrorIconVisibility() {
|
||||
this.errorIconView.setVisibility(getErrorIconDrawable() != null && this.textInputLayout.isErrorEnabled() && this.textInputLayout.shouldShowError() ? 0 : 8);
|
||||
updateEndLayoutVisibility();
|
||||
updateSuffixTextViewPadding();
|
||||
if (hasEndIcon()) {
|
||||
return;
|
||||
}
|
||||
this.textInputLayout.updateDummyDrawables();
|
||||
}
|
||||
|
||||
private void updateEndLayoutVisibility() {
|
||||
int i = 0;
|
||||
this.endIconFrame.setVisibility((this.endIconView.getVisibility() != 0 || isErrorIconVisible()) ? 8 : 0);
|
||||
char c = (this.suffixText == null || this.hintExpanded) ? '\b' : (char) 0;
|
||||
if (!isEndIconVisible() && !isErrorIconVisible() && c != 0) {
|
||||
i = 8;
|
||||
}
|
||||
setVisibility(i);
|
||||
}
|
||||
|
||||
private void dispatchOnEndIconChanged(int i) {
|
||||
Iterator<TextInputLayout.OnEndIconChangedListener> it = this.endIconChangedListeners.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onEndIconChanged(this.textInputLayout, i);
|
||||
}
|
||||
}
|
||||
|
||||
private void tintEndIconOnError(boolean z) {
|
||||
if (z && getEndIconDrawable() != null) {
|
||||
Drawable mutate = DrawableCompat.wrap(getEndIconDrawable()).mutate();
|
||||
DrawableCompat.setTint(mutate, this.textInputLayout.getErrorCurrentTextColors());
|
||||
this.endIconView.setImageDrawable(mutate);
|
||||
return;
|
||||
}
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.endIconView, this.endIconTintList, this.endIconTintMode);
|
||||
}
|
||||
|
||||
private static class EndIconDelegates {
|
||||
private final int customEndIconDrawableId;
|
||||
private final SparseArray<EndIconDelegate> delegates = new SparseArray<>();
|
||||
private final EndCompoundLayout endLayout;
|
||||
private final int passwordIconDrawableId;
|
||||
|
||||
EndIconDelegates(EndCompoundLayout endCompoundLayout, TintTypedArray tintTypedArray) {
|
||||
this.endLayout = endCompoundLayout;
|
||||
this.customEndIconDrawableId = tintTypedArray.getResourceId(R.styleable.TextInputLayout_endIconDrawable, 0);
|
||||
this.passwordIconDrawableId = tintTypedArray.getResourceId(R.styleable.TextInputLayout_passwordToggleDrawable, 0);
|
||||
}
|
||||
|
||||
EndIconDelegate get(int i) {
|
||||
EndIconDelegate endIconDelegate = this.delegates.get(i);
|
||||
if (endIconDelegate != null) {
|
||||
return endIconDelegate;
|
||||
}
|
||||
EndIconDelegate create = create(i);
|
||||
this.delegates.append(i, create);
|
||||
return create;
|
||||
}
|
||||
|
||||
private EndIconDelegate create(int i) {
|
||||
if (i == -1) {
|
||||
return new CustomEndIconDelegate(this.endLayout);
|
||||
}
|
||||
if (i == 0) {
|
||||
return new NoEndIconDelegate(this.endLayout);
|
||||
}
|
||||
if (i == 1) {
|
||||
return new PasswordToggleEndIconDelegate(this.endLayout, this.passwordIconDrawableId);
|
||||
}
|
||||
if (i == 2) {
|
||||
return new ClearTextEndIconDelegate(this.endLayout);
|
||||
}
|
||||
if (i == 3) {
|
||||
return new DropdownMenuEndIconDelegate(this.endLayout);
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid end icon mode: " + i);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.widget.EditText;
|
||||
import androidx.core.view.accessibility.AccessibilityManagerCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.internal.CheckableImageButton;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class EndIconDelegate {
|
||||
final Context context;
|
||||
final CheckableImageButton endIconView;
|
||||
final EndCompoundLayout endLayout;
|
||||
final TextInputLayout textInputLayout;
|
||||
|
||||
void afterEditTextChanged(Editable editable) {
|
||||
}
|
||||
|
||||
void beforeEditTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
}
|
||||
|
||||
int getIconContentDescriptionResId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getIconDrawableResId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
View.OnFocusChangeListener getOnEditTextFocusChangeListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
View.OnClickListener getOnIconClickListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
View.OnFocusChangeListener getOnIconViewFocusChangeListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
AccessibilityManagerCompat.TouchExplorationStateChangeListener getTouchExplorationStateChangeListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isBoxBackgroundModeSupported(int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isIconActivable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isIconActivated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isIconCheckable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isIconChecked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void onEditTextAttached(EditText editText) {
|
||||
}
|
||||
|
||||
void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
}
|
||||
|
||||
void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
|
||||
}
|
||||
|
||||
void onSuffixVisibilityChanged(boolean z) {
|
||||
}
|
||||
|
||||
void setUp() {
|
||||
}
|
||||
|
||||
boolean shouldTintIconOnError() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
}
|
||||
|
||||
EndIconDelegate(EndCompoundLayout endCompoundLayout) {
|
||||
this.textInputLayout = endCompoundLayout.textInputLayout;
|
||||
this.endLayout = endCompoundLayout;
|
||||
this.context = endCompoundLayout.getContext();
|
||||
this.endIconView = endCompoundLayout.getEndIconView();
|
||||
}
|
||||
|
||||
final void refreshIconState() {
|
||||
this.endLayout.refreshIconState(false);
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.internal.CheckableImageButton;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.ripple.RippleUtils;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class IconHelper {
|
||||
private IconHelper() {
|
||||
}
|
||||
|
||||
static void setIconOnClickListener(CheckableImageButton checkableImageButton, View.OnClickListener onClickListener, View.OnLongClickListener onLongClickListener) {
|
||||
checkableImageButton.setOnClickListener(onClickListener);
|
||||
setIconClickable(checkableImageButton, onLongClickListener);
|
||||
}
|
||||
|
||||
static void setIconOnLongClickListener(CheckableImageButton checkableImageButton, View.OnLongClickListener onLongClickListener) {
|
||||
checkableImageButton.setOnLongClickListener(onLongClickListener);
|
||||
setIconClickable(checkableImageButton, onLongClickListener);
|
||||
}
|
||||
|
||||
private static void setIconClickable(CheckableImageButton checkableImageButton, View.OnLongClickListener onLongClickListener) {
|
||||
boolean hasOnClickListeners = ViewCompat.hasOnClickListeners(checkableImageButton);
|
||||
boolean z = onLongClickListener != null;
|
||||
boolean z2 = hasOnClickListeners || z;
|
||||
checkableImageButton.setFocusable(z2);
|
||||
checkableImageButton.setClickable(hasOnClickListeners);
|
||||
checkableImageButton.setPressable(hasOnClickListeners);
|
||||
checkableImageButton.setLongClickable(z);
|
||||
ViewCompat.setImportantForAccessibility(checkableImageButton, z2 ? 1 : 2);
|
||||
}
|
||||
|
||||
static void applyIconTint(TextInputLayout textInputLayout, CheckableImageButton checkableImageButton, ColorStateList colorStateList, PorterDuff.Mode mode) {
|
||||
Drawable drawable = checkableImageButton.getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable = DrawableCompat.wrap(drawable).mutate();
|
||||
if (colorStateList != null && colorStateList.isStateful()) {
|
||||
DrawableCompat.setTintList(drawable, ColorStateList.valueOf(colorStateList.getColorForState(mergeIconState(textInputLayout, checkableImageButton), colorStateList.getDefaultColor())));
|
||||
} else {
|
||||
DrawableCompat.setTintList(drawable, colorStateList);
|
||||
}
|
||||
if (mode != null) {
|
||||
DrawableCompat.setTintMode(drawable, mode);
|
||||
}
|
||||
}
|
||||
if (checkableImageButton.getDrawable() != drawable) {
|
||||
checkableImageButton.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
static void refreshIconDrawableState(TextInputLayout textInputLayout, CheckableImageButton checkableImageButton, ColorStateList colorStateList) {
|
||||
Drawable drawable = checkableImageButton.getDrawable();
|
||||
if (checkableImageButton.getDrawable() == null || colorStateList == null || !colorStateList.isStateful()) {
|
||||
return;
|
||||
}
|
||||
int colorForState = colorStateList.getColorForState(mergeIconState(textInputLayout, checkableImageButton), colorStateList.getDefaultColor());
|
||||
Drawable mutate = DrawableCompat.wrap(drawable).mutate();
|
||||
DrawableCompat.setTintList(mutate, ColorStateList.valueOf(colorForState));
|
||||
checkableImageButton.setImageDrawable(mutate);
|
||||
}
|
||||
|
||||
private static int[] mergeIconState(TextInputLayout textInputLayout, CheckableImageButton checkableImageButton) {
|
||||
int[] drawableState = textInputLayout.getDrawableState();
|
||||
int[] drawableState2 = checkableImageButton.getDrawableState();
|
||||
int length = drawableState.length;
|
||||
int[] copyOf = Arrays.copyOf(drawableState, drawableState.length + drawableState2.length);
|
||||
System.arraycopy(drawableState2, 0, copyOf, length, drawableState2.length);
|
||||
return copyOf;
|
||||
}
|
||||
|
||||
static void setCompatRippleBackgroundIfNeeded(CheckableImageButton checkableImageButton) {
|
||||
if (Build.VERSION.SDK_INT <= 22) {
|
||||
checkableImageButton.setBackground(RippleUtils.createOvalRippleLollipop(checkableImageButton.getContext(), (int) ViewUtils.dpToPx(checkableImageButton.getContext(), 4)));
|
||||
}
|
||||
}
|
||||
|
||||
static void setIconMinSize(CheckableImageButton checkableImageButton, int i) {
|
||||
checkableImageButton.setMinimumWidth(i);
|
||||
checkableImageButton.setMinimumHeight(i);
|
||||
}
|
||||
|
||||
static void setIconScaleType(CheckableImageButton checkableImageButton, ImageView.ScaleType scaleType) {
|
||||
checkableImageButton.setScaleType(scaleType);
|
||||
}
|
||||
|
||||
static ImageView.ScaleType convertScaleType(int i) {
|
||||
if (i == 0) {
|
||||
return ImageView.ScaleType.FIT_XY;
|
||||
}
|
||||
if (i == 1) {
|
||||
return ImageView.ScaleType.FIT_START;
|
||||
}
|
||||
if (i == 2) {
|
||||
return ImageView.ScaleType.FIT_CENTER;
|
||||
}
|
||||
if (i == 3) {
|
||||
return ImageView.ScaleType.FIT_END;
|
||||
}
|
||||
if (i == 5) {
|
||||
return ImageView.ScaleType.CENTER_CROP;
|
||||
}
|
||||
if (i == 6) {
|
||||
return ImageView.ScaleType.CENTER_INSIDE;
|
||||
}
|
||||
return ImageView.ScaleType.CENTER;
|
||||
}
|
||||
}
|
@ -0,0 +1,529 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.animation.AnimatorSetCompat;
|
||||
import com.google.android.material.motion.MotionUtils;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class IndicatorViewController {
|
||||
private static final int CAPTION_STATE_ERROR = 1;
|
||||
private static final int CAPTION_STATE_HELPER_TEXT = 2;
|
||||
private static final int CAPTION_STATE_NONE = 0;
|
||||
static final int COUNTER_INDEX = 2;
|
||||
private static final int DEFAULT_CAPTION_FADE_ANIMATION_DURATION = 167;
|
||||
private static final int DEFAULT_CAPTION_TRANSLATION_Y_ANIMATION_DURATION = 217;
|
||||
static final int ERROR_INDEX = 0;
|
||||
static final int HELPER_INDEX = 1;
|
||||
private Animator captionAnimator;
|
||||
private FrameLayout captionArea;
|
||||
private int captionDisplayed;
|
||||
private final int captionFadeInAnimationDuration;
|
||||
private final TimeInterpolator captionFadeInAnimationInterpolator;
|
||||
private final int captionFadeOutAnimationDuration;
|
||||
private final TimeInterpolator captionFadeOutAnimationInterpolator;
|
||||
private int captionToShow;
|
||||
private final int captionTranslationYAnimationDuration;
|
||||
private final TimeInterpolator captionTranslationYAnimationInterpolator;
|
||||
private final float captionTranslationYPx;
|
||||
private final Context context;
|
||||
private boolean errorEnabled;
|
||||
private CharSequence errorText;
|
||||
private int errorTextAppearance;
|
||||
private TextView errorView;
|
||||
private int errorViewAccessibilityLiveRegion;
|
||||
private CharSequence errorViewContentDescription;
|
||||
private ColorStateList errorViewTextColor;
|
||||
private CharSequence helperText;
|
||||
private boolean helperTextEnabled;
|
||||
private int helperTextTextAppearance;
|
||||
private TextView helperTextView;
|
||||
private ColorStateList helperTextViewTextColor;
|
||||
private LinearLayout indicatorArea;
|
||||
private int indicatorsAdded;
|
||||
private final TextInputLayout textInputView;
|
||||
private Typeface typeface;
|
||||
|
||||
private TextView getCaptionViewFromDisplayState(int i) {
|
||||
if (i == 1) {
|
||||
return this.errorView;
|
||||
}
|
||||
if (i != 2) {
|
||||
return null;
|
||||
}
|
||||
return this.helperTextView;
|
||||
}
|
||||
|
||||
int getErrorAccessibilityLiveRegion() {
|
||||
return this.errorViewAccessibilityLiveRegion;
|
||||
}
|
||||
|
||||
CharSequence getErrorContentDescription() {
|
||||
return this.errorViewContentDescription;
|
||||
}
|
||||
|
||||
CharSequence getErrorText() {
|
||||
return this.errorText;
|
||||
}
|
||||
|
||||
CharSequence getHelperText() {
|
||||
return this.helperText;
|
||||
}
|
||||
|
||||
View getHelperTextView() {
|
||||
return this.helperTextView;
|
||||
}
|
||||
|
||||
boolean isCaptionView(int i) {
|
||||
return i == 0 || i == 1;
|
||||
}
|
||||
|
||||
boolean isErrorEnabled() {
|
||||
return this.errorEnabled;
|
||||
}
|
||||
|
||||
boolean isHelperTextEnabled() {
|
||||
return this.helperTextEnabled;
|
||||
}
|
||||
|
||||
public IndicatorViewController(TextInputLayout textInputLayout) {
|
||||
Context context = textInputLayout.getContext();
|
||||
this.context = context;
|
||||
this.textInputView = textInputLayout;
|
||||
this.captionTranslationYPx = context.getResources().getDimensionPixelSize(R.dimen.design_textinput_caption_translate_y);
|
||||
this.captionTranslationYAnimationDuration = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationShort4, DEFAULT_CAPTION_TRANSLATION_Y_ANIMATION_DURATION);
|
||||
this.captionFadeInAnimationDuration = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationMedium4, DEFAULT_CAPTION_FADE_ANIMATION_DURATION);
|
||||
this.captionFadeOutAnimationDuration = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationShort4, DEFAULT_CAPTION_FADE_ANIMATION_DURATION);
|
||||
this.captionTranslationYAnimationInterpolator = MotionUtils.resolveThemeInterpolator(context, R.attr.motionEasingEmphasizedDecelerateInterpolator, AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
|
||||
this.captionFadeInAnimationInterpolator = MotionUtils.resolveThemeInterpolator(context, R.attr.motionEasingEmphasizedDecelerateInterpolator, AnimationUtils.LINEAR_INTERPOLATOR);
|
||||
this.captionFadeOutAnimationInterpolator = MotionUtils.resolveThemeInterpolator(context, R.attr.motionEasingLinearInterpolator, AnimationUtils.LINEAR_INTERPOLATOR);
|
||||
}
|
||||
|
||||
void showHelper(CharSequence charSequence) {
|
||||
cancelCaptionAnimator();
|
||||
this.helperText = charSequence;
|
||||
this.helperTextView.setText(charSequence);
|
||||
int i = this.captionDisplayed;
|
||||
if (i != 2) {
|
||||
this.captionToShow = 2;
|
||||
}
|
||||
updateCaptionViewsVisibility(i, this.captionToShow, shouldAnimateCaptionView(this.helperTextView, charSequence));
|
||||
}
|
||||
|
||||
void hideHelperText() {
|
||||
cancelCaptionAnimator();
|
||||
int i = this.captionDisplayed;
|
||||
if (i == 2) {
|
||||
this.captionToShow = 0;
|
||||
}
|
||||
updateCaptionViewsVisibility(i, this.captionToShow, shouldAnimateCaptionView(this.helperTextView, ""));
|
||||
}
|
||||
|
||||
void showError(CharSequence charSequence) {
|
||||
cancelCaptionAnimator();
|
||||
this.errorText = charSequence;
|
||||
this.errorView.setText(charSequence);
|
||||
int i = this.captionDisplayed;
|
||||
if (i != 1) {
|
||||
this.captionToShow = 1;
|
||||
}
|
||||
updateCaptionViewsVisibility(i, this.captionToShow, shouldAnimateCaptionView(this.errorView, charSequence));
|
||||
}
|
||||
|
||||
void hideError() {
|
||||
this.errorText = null;
|
||||
cancelCaptionAnimator();
|
||||
if (this.captionDisplayed == 1) {
|
||||
if (!this.helperTextEnabled || TextUtils.isEmpty(this.helperText)) {
|
||||
this.captionToShow = 0;
|
||||
} else {
|
||||
this.captionToShow = 2;
|
||||
}
|
||||
}
|
||||
updateCaptionViewsVisibility(this.captionDisplayed, this.captionToShow, shouldAnimateCaptionView(this.errorView, ""));
|
||||
}
|
||||
|
||||
private boolean shouldAnimateCaptionView(TextView textView, CharSequence charSequence) {
|
||||
return ViewCompat.isLaidOut(this.textInputView) && this.textInputView.isEnabled() && !(this.captionToShow == this.captionDisplayed && textView != null && TextUtils.equals(textView.getText(), charSequence));
|
||||
}
|
||||
|
||||
private void updateCaptionViewsVisibility(final int i, final int i2, boolean z) {
|
||||
if (i == i2) {
|
||||
return;
|
||||
}
|
||||
if (z) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
this.captionAnimator = animatorSet;
|
||||
ArrayList arrayList = new ArrayList();
|
||||
createCaptionAnimators(arrayList, this.helperTextEnabled, this.helperTextView, 2, i, i2);
|
||||
createCaptionAnimators(arrayList, this.errorEnabled, this.errorView, 1, i, i2);
|
||||
AnimatorSetCompat.playTogether(animatorSet, arrayList);
|
||||
final TextView captionViewFromDisplayState = getCaptionViewFromDisplayState(i);
|
||||
final TextView captionViewFromDisplayState2 = getCaptionViewFromDisplayState(i2);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.textfield.IndicatorViewController.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
IndicatorViewController.this.captionDisplayed = i2;
|
||||
IndicatorViewController.this.captionAnimator = null;
|
||||
TextView textView = captionViewFromDisplayState;
|
||||
if (textView != null) {
|
||||
textView.setVisibility(4);
|
||||
if (i == 1 && IndicatorViewController.this.errorView != null) {
|
||||
IndicatorViewController.this.errorView.setText((CharSequence) null);
|
||||
}
|
||||
}
|
||||
TextView textView2 = captionViewFromDisplayState2;
|
||||
if (textView2 != null) {
|
||||
textView2.setTranslationY(0.0f);
|
||||
captionViewFromDisplayState2.setAlpha(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
TextView textView = captionViewFromDisplayState2;
|
||||
if (textView != null) {
|
||||
textView.setVisibility(0);
|
||||
captionViewFromDisplayState2.setAlpha(0.0f);
|
||||
}
|
||||
}
|
||||
});
|
||||
animatorSet.start();
|
||||
} else {
|
||||
setCaptionViewVisibilities(i, i2);
|
||||
}
|
||||
this.textInputView.updateEditTextBackground();
|
||||
this.textInputView.updateLabelState(z);
|
||||
this.textInputView.updateTextInputBoxState();
|
||||
}
|
||||
|
||||
private void setCaptionViewVisibilities(int i, int i2) {
|
||||
TextView captionViewFromDisplayState;
|
||||
TextView captionViewFromDisplayState2;
|
||||
if (i == i2) {
|
||||
return;
|
||||
}
|
||||
if (i2 != 0 && (captionViewFromDisplayState2 = getCaptionViewFromDisplayState(i2)) != null) {
|
||||
captionViewFromDisplayState2.setVisibility(0);
|
||||
captionViewFromDisplayState2.setAlpha(1.0f);
|
||||
}
|
||||
if (i != 0 && (captionViewFromDisplayState = getCaptionViewFromDisplayState(i)) != null) {
|
||||
captionViewFromDisplayState.setVisibility(4);
|
||||
if (i == 1) {
|
||||
captionViewFromDisplayState.setText((CharSequence) null);
|
||||
}
|
||||
}
|
||||
this.captionDisplayed = i2;
|
||||
}
|
||||
|
||||
private void createCaptionAnimators(List<Animator> list, boolean z, TextView textView, int i, int i2, int i3) {
|
||||
if (textView == null || !z) {
|
||||
return;
|
||||
}
|
||||
if (i == i3 || i == i2) {
|
||||
ObjectAnimator createCaptionOpacityAnimator = createCaptionOpacityAnimator(textView, i3 == i);
|
||||
if (i == i3 && i2 != 0) {
|
||||
createCaptionOpacityAnimator.setStartDelay(this.captionFadeOutAnimationDuration);
|
||||
}
|
||||
list.add(createCaptionOpacityAnimator);
|
||||
if (i3 != i || i2 == 0) {
|
||||
return;
|
||||
}
|
||||
ObjectAnimator createCaptionTranslationYAnimator = createCaptionTranslationYAnimator(textView);
|
||||
createCaptionTranslationYAnimator.setStartDelay(this.captionFadeOutAnimationDuration);
|
||||
list.add(createCaptionTranslationYAnimator);
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectAnimator createCaptionOpacityAnimator(TextView textView, boolean z) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, (Property<TextView, Float>) View.ALPHA, z ? 1.0f : 0.0f);
|
||||
ofFloat.setDuration(z ? this.captionFadeInAnimationDuration : this.captionFadeOutAnimationDuration);
|
||||
ofFloat.setInterpolator(z ? this.captionFadeInAnimationInterpolator : this.captionFadeOutAnimationInterpolator);
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private ObjectAnimator createCaptionTranslationYAnimator(TextView textView) {
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, (Property<TextView, Float>) View.TRANSLATION_Y, -this.captionTranslationYPx, 0.0f);
|
||||
ofFloat.setDuration(this.captionTranslationYAnimationDuration);
|
||||
ofFloat.setInterpolator(this.captionTranslationYAnimationInterpolator);
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
void cancelCaptionAnimator() {
|
||||
Animator animator = this.captionAnimator;
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void adjustIndicatorPadding() {
|
||||
if (canAdjustIndicatorPadding()) {
|
||||
EditText editText = this.textInputView.getEditText();
|
||||
boolean isFontScaleAtLeast1_3 = MaterialResources.isFontScaleAtLeast1_3(this.context);
|
||||
ViewCompat.setPaddingRelative(this.indicatorArea, getIndicatorPadding(isFontScaleAtLeast1_3, R.dimen.material_helper_text_font_1_3_padding_horizontal, ViewCompat.getPaddingStart(editText)), getIndicatorPadding(isFontScaleAtLeast1_3, R.dimen.material_helper_text_font_1_3_padding_top, this.context.getResources().getDimensionPixelSize(R.dimen.material_helper_text_default_padding_top)), getIndicatorPadding(isFontScaleAtLeast1_3, R.dimen.material_helper_text_font_1_3_padding_horizontal, ViewCompat.getPaddingEnd(editText)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canAdjustIndicatorPadding() {
|
||||
return (this.indicatorArea == null || this.textInputView.getEditText() == null) ? false : true;
|
||||
}
|
||||
|
||||
private int getIndicatorPadding(boolean z, int i, int i2) {
|
||||
return z ? this.context.getResources().getDimensionPixelSize(i) : i2;
|
||||
}
|
||||
|
||||
void addIndicator(TextView textView, int i) {
|
||||
if (this.indicatorArea == null && this.captionArea == null) {
|
||||
LinearLayout linearLayout = new LinearLayout(this.context);
|
||||
this.indicatorArea = linearLayout;
|
||||
linearLayout.setOrientation(0);
|
||||
this.textInputView.addView(this.indicatorArea, -1, -2);
|
||||
this.captionArea = new FrameLayout(this.context);
|
||||
this.indicatorArea.addView(this.captionArea, new LinearLayout.LayoutParams(0, -2, 1.0f));
|
||||
if (this.textInputView.getEditText() != null) {
|
||||
adjustIndicatorPadding();
|
||||
}
|
||||
}
|
||||
if (isCaptionView(i)) {
|
||||
this.captionArea.setVisibility(0);
|
||||
this.captionArea.addView(textView);
|
||||
} else {
|
||||
this.indicatorArea.addView(textView, new LinearLayout.LayoutParams(-2, -2));
|
||||
}
|
||||
this.indicatorArea.setVisibility(0);
|
||||
this.indicatorsAdded++;
|
||||
}
|
||||
|
||||
void removeIndicator(TextView textView, int i) {
|
||||
FrameLayout frameLayout;
|
||||
if (this.indicatorArea == null) {
|
||||
return;
|
||||
}
|
||||
if (isCaptionView(i) && (frameLayout = this.captionArea) != null) {
|
||||
frameLayout.removeView(textView);
|
||||
} else {
|
||||
this.indicatorArea.removeView(textView);
|
||||
}
|
||||
int i2 = this.indicatorsAdded - 1;
|
||||
this.indicatorsAdded = i2;
|
||||
setViewGroupGoneIfEmpty(this.indicatorArea, i2);
|
||||
}
|
||||
|
||||
private void setViewGroupGoneIfEmpty(ViewGroup viewGroup, int i) {
|
||||
if (i == 0) {
|
||||
viewGroup.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
void setErrorEnabled(boolean z) {
|
||||
if (this.errorEnabled == z) {
|
||||
return;
|
||||
}
|
||||
cancelCaptionAnimator();
|
||||
if (z) {
|
||||
AppCompatTextView appCompatTextView = new AppCompatTextView(this.context);
|
||||
this.errorView = appCompatTextView;
|
||||
appCompatTextView.setId(R.id.textinput_error);
|
||||
this.errorView.setTextAlignment(5);
|
||||
Typeface typeface = this.typeface;
|
||||
if (typeface != null) {
|
||||
this.errorView.setTypeface(typeface);
|
||||
}
|
||||
setErrorTextAppearance(this.errorTextAppearance);
|
||||
setErrorViewTextColor(this.errorViewTextColor);
|
||||
setErrorContentDescription(this.errorViewContentDescription);
|
||||
setErrorAccessibilityLiveRegion(this.errorViewAccessibilityLiveRegion);
|
||||
this.errorView.setVisibility(4);
|
||||
addIndicator(this.errorView, 0);
|
||||
} else {
|
||||
hideError();
|
||||
removeIndicator(this.errorView, 0);
|
||||
this.errorView = null;
|
||||
this.textInputView.updateEditTextBackground();
|
||||
this.textInputView.updateTextInputBoxState();
|
||||
}
|
||||
this.errorEnabled = z;
|
||||
}
|
||||
|
||||
void setHelperTextEnabled(boolean z) {
|
||||
if (this.helperTextEnabled == z) {
|
||||
return;
|
||||
}
|
||||
cancelCaptionAnimator();
|
||||
if (z) {
|
||||
AppCompatTextView appCompatTextView = new AppCompatTextView(this.context);
|
||||
this.helperTextView = appCompatTextView;
|
||||
appCompatTextView.setId(R.id.textinput_helper_text);
|
||||
this.helperTextView.setTextAlignment(5);
|
||||
Typeface typeface = this.typeface;
|
||||
if (typeface != null) {
|
||||
this.helperTextView.setTypeface(typeface);
|
||||
}
|
||||
this.helperTextView.setVisibility(4);
|
||||
ViewCompat.setAccessibilityLiveRegion(this.helperTextView, 1);
|
||||
setHelperTextAppearance(this.helperTextTextAppearance);
|
||||
setHelperTextViewTextColor(this.helperTextViewTextColor);
|
||||
addIndicator(this.helperTextView, 1);
|
||||
this.helperTextView.setAccessibilityDelegate(new View.AccessibilityDelegate() { // from class: com.google.android.material.textfield.IndicatorViewController.2
|
||||
@Override // android.view.View.AccessibilityDelegate
|
||||
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfo);
|
||||
EditText editText = IndicatorViewController.this.textInputView.getEditText();
|
||||
if (editText != null) {
|
||||
accessibilityNodeInfo.setLabeledBy(editText);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
hideHelperText();
|
||||
removeIndicator(this.helperTextView, 1);
|
||||
this.helperTextView = null;
|
||||
this.textInputView.updateEditTextBackground();
|
||||
this.textInputView.updateTextInputBoxState();
|
||||
}
|
||||
this.helperTextEnabled = z;
|
||||
}
|
||||
|
||||
boolean errorIsDisplayed() {
|
||||
return isCaptionStateError(this.captionDisplayed);
|
||||
}
|
||||
|
||||
boolean errorShouldBeShown() {
|
||||
return isCaptionStateError(this.captionToShow);
|
||||
}
|
||||
|
||||
private boolean isCaptionStateError(int i) {
|
||||
return (i != 1 || this.errorView == null || TextUtils.isEmpty(this.errorText)) ? false : true;
|
||||
}
|
||||
|
||||
boolean helperTextIsDisplayed() {
|
||||
return isCaptionStateHelperText(this.captionDisplayed);
|
||||
}
|
||||
|
||||
boolean helperTextShouldBeShown() {
|
||||
return isCaptionStateHelperText(this.captionToShow);
|
||||
}
|
||||
|
||||
private boolean isCaptionStateHelperText(int i) {
|
||||
return (i != 2 || this.helperTextView == null || TextUtils.isEmpty(this.helperText)) ? false : true;
|
||||
}
|
||||
|
||||
void setTypefaces(Typeface typeface) {
|
||||
if (typeface != this.typeface) {
|
||||
this.typeface = typeface;
|
||||
setTextViewTypeface(this.errorView, typeface);
|
||||
setTextViewTypeface(this.helperTextView, typeface);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTextViewTypeface(TextView textView, Typeface typeface) {
|
||||
if (textView != null) {
|
||||
textView.setTypeface(typeface);
|
||||
}
|
||||
}
|
||||
|
||||
int getErrorViewCurrentTextColor() {
|
||||
TextView textView = this.errorView;
|
||||
if (textView != null) {
|
||||
return textView.getCurrentTextColor();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ColorStateList getErrorViewTextColors() {
|
||||
TextView textView = this.errorView;
|
||||
if (textView != null) {
|
||||
return textView.getTextColors();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void setErrorViewTextColor(ColorStateList colorStateList) {
|
||||
this.errorViewTextColor = colorStateList;
|
||||
TextView textView = this.errorView;
|
||||
if (textView == null || colorStateList == null) {
|
||||
return;
|
||||
}
|
||||
textView.setTextColor(colorStateList);
|
||||
}
|
||||
|
||||
void setErrorTextAppearance(int i) {
|
||||
this.errorTextAppearance = i;
|
||||
TextView textView = this.errorView;
|
||||
if (textView != null) {
|
||||
this.textInputView.setTextAppearanceCompatWithErrorFallback(textView, i);
|
||||
}
|
||||
}
|
||||
|
||||
void setErrorContentDescription(CharSequence charSequence) {
|
||||
this.errorViewContentDescription = charSequence;
|
||||
TextView textView = this.errorView;
|
||||
if (textView != null) {
|
||||
textView.setContentDescription(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
void setErrorAccessibilityLiveRegion(int i) {
|
||||
this.errorViewAccessibilityLiveRegion = i;
|
||||
TextView textView = this.errorView;
|
||||
if (textView != null) {
|
||||
ViewCompat.setAccessibilityLiveRegion(textView, i);
|
||||
}
|
||||
}
|
||||
|
||||
int getHelperTextViewCurrentTextColor() {
|
||||
TextView textView = this.helperTextView;
|
||||
if (textView != null) {
|
||||
return textView.getCurrentTextColor();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ColorStateList getHelperTextViewColors() {
|
||||
TextView textView = this.helperTextView;
|
||||
if (textView != null) {
|
||||
return textView.getTextColors();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void setHelperTextViewTextColor(ColorStateList colorStateList) {
|
||||
this.helperTextViewTextColor = colorStateList;
|
||||
TextView textView = this.helperTextView;
|
||||
if (textView == null || colorStateList == null) {
|
||||
return;
|
||||
}
|
||||
textView.setTextColor(colorStateList);
|
||||
}
|
||||
|
||||
void setHelperTextAppearance(int i) {
|
||||
this.helperTextTextAppearance = i;
|
||||
TextView textView = this.helperTextView;
|
||||
if (textView != null) {
|
||||
TextViewCompat.setTextAppearance(textView, i);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,352 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.AppCompatAutoCompleteTextView;
|
||||
import androidx.appcompat.widget.ListPopupWindow;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.internal.ManufacturerUtils;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.theme.overlay.MaterialThemeOverlay;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MaterialAutoCompleteTextView extends AppCompatAutoCompleteTextView {
|
||||
private static final int MAX_ITEMS_MEASURED = 15;
|
||||
private final AccessibilityManager accessibilityManager;
|
||||
private ColorStateList dropDownBackgroundTint;
|
||||
private final ListPopupWindow modalListPopup;
|
||||
private final float popupElevation;
|
||||
private final int simpleItemLayout;
|
||||
private int simpleItemSelectedColor;
|
||||
private ColorStateList simpleItemSelectedRippleColor;
|
||||
private final Rect tempRect;
|
||||
|
||||
public ColorStateList getDropDownBackgroundTintList() {
|
||||
return this.dropDownBackgroundTint;
|
||||
}
|
||||
|
||||
public float getPopupElevation() {
|
||||
return this.popupElevation;
|
||||
}
|
||||
|
||||
public int getSimpleItemSelectedColor() {
|
||||
return this.simpleItemSelectedColor;
|
||||
}
|
||||
|
||||
public ColorStateList getSimpleItemSelectedRippleColor() {
|
||||
return this.simpleItemSelectedRippleColor;
|
||||
}
|
||||
|
||||
public MaterialAutoCompleteTextView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public MaterialAutoCompleteTextView(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.autoCompleteTextViewStyle);
|
||||
}
|
||||
|
||||
public MaterialAutoCompleteTextView(Context context, AttributeSet attributeSet, int i) {
|
||||
super(MaterialThemeOverlay.wrap(context, attributeSet, i, 0), attributeSet, i);
|
||||
this.tempRect = new Rect();
|
||||
Context context2 = getContext();
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context2, attributeSet, R.styleable.MaterialAutoCompleteTextView, i, R.style.Widget_AppCompat_AutoCompleteTextView, new int[0]);
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.MaterialAutoCompleteTextView_android_inputType) && obtainStyledAttributes.getInt(R.styleable.MaterialAutoCompleteTextView_android_inputType, 0) == 0) {
|
||||
setKeyListener(null);
|
||||
}
|
||||
this.simpleItemLayout = obtainStyledAttributes.getResourceId(R.styleable.MaterialAutoCompleteTextView_simpleItemLayout, R.layout.mtrl_auto_complete_simple_item);
|
||||
this.popupElevation = obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialAutoCompleteTextView_android_popupElevation, R.dimen.mtrl_exposed_dropdown_menu_popup_elevation);
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.MaterialAutoCompleteTextView_dropDownBackgroundTint)) {
|
||||
this.dropDownBackgroundTint = ColorStateList.valueOf(obtainStyledAttributes.getColor(R.styleable.MaterialAutoCompleteTextView_dropDownBackgroundTint, 0));
|
||||
}
|
||||
this.simpleItemSelectedColor = obtainStyledAttributes.getColor(R.styleable.MaterialAutoCompleteTextView_simpleItemSelectedColor, 0);
|
||||
this.simpleItemSelectedRippleColor = MaterialResources.getColorStateList(context2, obtainStyledAttributes, R.styleable.MaterialAutoCompleteTextView_simpleItemSelectedRippleColor);
|
||||
this.accessibilityManager = (AccessibilityManager) context2.getSystemService("accessibility");
|
||||
ListPopupWindow listPopupWindow = new ListPopupWindow(context2);
|
||||
this.modalListPopup = listPopupWindow;
|
||||
listPopupWindow.setModal(true);
|
||||
listPopupWindow.setAnchorView(this);
|
||||
listPopupWindow.setInputMethodMode(2);
|
||||
listPopupWindow.setAdapter(getAdapter());
|
||||
listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: com.google.android.material.textfield.MaterialAutoCompleteTextView.1
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i2, long j) {
|
||||
MaterialAutoCompleteTextView materialAutoCompleteTextView = MaterialAutoCompleteTextView.this;
|
||||
MaterialAutoCompleteTextView.this.updateText(i2 < 0 ? materialAutoCompleteTextView.modalListPopup.getSelectedItem() : materialAutoCompleteTextView.getAdapter().getItem(i2));
|
||||
AdapterView.OnItemClickListener onItemClickListener = MaterialAutoCompleteTextView.this.getOnItemClickListener();
|
||||
if (onItemClickListener != null) {
|
||||
if (view == null || i2 < 0) {
|
||||
view = MaterialAutoCompleteTextView.this.modalListPopup.getSelectedView();
|
||||
i2 = MaterialAutoCompleteTextView.this.modalListPopup.getSelectedItemPosition();
|
||||
j = MaterialAutoCompleteTextView.this.modalListPopup.getSelectedItemId();
|
||||
}
|
||||
onItemClickListener.onItemClick(MaterialAutoCompleteTextView.this.modalListPopup.getListView(), view, i2, j);
|
||||
}
|
||||
MaterialAutoCompleteTextView.this.modalListPopup.dismiss();
|
||||
}
|
||||
});
|
||||
if (obtainStyledAttributes.hasValue(R.styleable.MaterialAutoCompleteTextView_simpleItems)) {
|
||||
setSimpleItems(obtainStyledAttributes.getResourceId(R.styleable.MaterialAutoCompleteTextView_simpleItems, 0));
|
||||
}
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView
|
||||
public void showDropDown() {
|
||||
if (isTouchExplorationEnabled()) {
|
||||
this.modalListPopup.show();
|
||||
} else {
|
||||
super.showDropDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView
|
||||
public void dismissDropDown() {
|
||||
if (isTouchExplorationEnabled()) {
|
||||
this.modalListPopup.dismiss();
|
||||
} else {
|
||||
super.dismissDropDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View
|
||||
public void onWindowFocusChanged(boolean z) {
|
||||
if (isTouchExplorationEnabled()) {
|
||||
return;
|
||||
}
|
||||
super.onWindowFocusChanged(z);
|
||||
}
|
||||
|
||||
private boolean isTouchExplorationEnabled() {
|
||||
AccessibilityManager accessibilityManager = this.accessibilityManager;
|
||||
return accessibilityManager != null && accessibilityManager.isTouchExplorationEnabled();
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView
|
||||
public <T extends ListAdapter & Filterable> void setAdapter(T t) {
|
||||
super.setAdapter(t);
|
||||
this.modalListPopup.setAdapter(getAdapter());
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView
|
||||
public void setRawInputType(int i) {
|
||||
super.setRawInputType(i);
|
||||
onInputTypeChanged();
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView
|
||||
public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener onItemSelectedListener) {
|
||||
super.setOnItemSelectedListener(onItemSelectedListener);
|
||||
this.modalListPopup.setOnItemSelectedListener(getOnItemSelectedListener());
|
||||
}
|
||||
|
||||
public void setSimpleItems(int i) {
|
||||
setSimpleItems(getResources().getStringArray(i));
|
||||
}
|
||||
|
||||
public void setSimpleItems(String[] strArr) {
|
||||
setAdapter(new MaterialArrayAdapter(getContext(), this.simpleItemLayout, strArr));
|
||||
}
|
||||
|
||||
public void setDropDownBackgroundTint(int i) {
|
||||
setDropDownBackgroundTintList(ColorStateList.valueOf(i));
|
||||
}
|
||||
|
||||
public void setDropDownBackgroundTintList(ColorStateList colorStateList) {
|
||||
this.dropDownBackgroundTint = colorStateList;
|
||||
Drawable dropDownBackground = getDropDownBackground();
|
||||
if (dropDownBackground instanceof MaterialShapeDrawable) {
|
||||
((MaterialShapeDrawable) dropDownBackground).setFillColor(this.dropDownBackgroundTint);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSimpleItemSelectedColor(int i) {
|
||||
this.simpleItemSelectedColor = i;
|
||||
if (getAdapter() instanceof MaterialArrayAdapter) {
|
||||
((MaterialArrayAdapter) getAdapter()).updateSelectedItemColorStateList();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSimpleItemSelectedRippleColor(ColorStateList colorStateList) {
|
||||
this.simpleItemSelectedRippleColor = colorStateList;
|
||||
if (getAdapter() instanceof MaterialArrayAdapter) {
|
||||
((MaterialArrayAdapter) getAdapter()).updateSelectedItemColorStateList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView
|
||||
public void setDropDownBackgroundDrawable(Drawable drawable) {
|
||||
super.setDropDownBackgroundDrawable(drawable);
|
||||
ListPopupWindow listPopupWindow = this.modalListPopup;
|
||||
if (listPopupWindow != null) {
|
||||
listPopupWindow.setBackgroundDrawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
TextInputLayout findTextInputLayoutAncestor = findTextInputLayoutAncestor();
|
||||
if (findTextInputLayoutAncestor != null && findTextInputLayoutAncestor.isProvidingHint() && super.getHint() == null && ManufacturerUtils.isMeizuDevice()) {
|
||||
setHint("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.AutoCompleteTextView, android.view.View
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
this.modalListPopup.dismiss();
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView
|
||||
public CharSequence getHint() {
|
||||
TextInputLayout findTextInputLayoutAncestor = findTextInputLayoutAncestor();
|
||||
if (findTextInputLayoutAncestor != null && findTextInputLayoutAncestor.isProvidingHint()) {
|
||||
return findTextInputLayoutAncestor.getHint();
|
||||
}
|
||||
return super.getHint();
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
super.onMeasure(i, i2);
|
||||
if (View.MeasureSpec.getMode(i) == Integer.MIN_VALUE) {
|
||||
setMeasuredDimension(Math.min(Math.max(getMeasuredWidth(), measureContentWidth()), View.MeasureSpec.getSize(i)), getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
private int measureContentWidth() {
|
||||
ListAdapter adapter = getAdapter();
|
||||
TextInputLayout findTextInputLayoutAncestor = findTextInputLayoutAncestor();
|
||||
int i = 0;
|
||||
if (adapter == null || findTextInputLayoutAncestor == null) {
|
||||
return 0;
|
||||
}
|
||||
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0);
|
||||
int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 0);
|
||||
int min = Math.min(adapter.getCount(), Math.max(0, this.modalListPopup.getSelectedItemPosition()) + 15);
|
||||
View view = null;
|
||||
int i2 = 0;
|
||||
for (int max = Math.max(0, min - 15); max < min; max++) {
|
||||
int itemViewType = adapter.getItemViewType(max);
|
||||
if (itemViewType != i) {
|
||||
view = null;
|
||||
i = itemViewType;
|
||||
}
|
||||
view = adapter.getView(max, view, findTextInputLayoutAncestor);
|
||||
if (view.getLayoutParams() == null) {
|
||||
view.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
|
||||
}
|
||||
view.measure(makeMeasureSpec, makeMeasureSpec2);
|
||||
i2 = Math.max(i2, view.getMeasuredWidth());
|
||||
}
|
||||
Drawable background = this.modalListPopup.getBackground();
|
||||
if (background != null) {
|
||||
background.getPadding(this.tempRect);
|
||||
i2 += this.tempRect.left + this.tempRect.right;
|
||||
}
|
||||
return i2 + findTextInputLayoutAncestor.getEndIconView().getMeasuredWidth();
|
||||
}
|
||||
|
||||
private void onInputTypeChanged() {
|
||||
TextInputLayout findTextInputLayoutAncestor = findTextInputLayoutAncestor();
|
||||
if (findTextInputLayoutAncestor != null) {
|
||||
findTextInputLayoutAncestor.updateEditTextBoxBackgroundIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
private TextInputLayout findTextInputLayoutAncestor() {
|
||||
for (ViewParent parent = getParent(); parent != null; parent = parent.getParent()) {
|
||||
if (parent instanceof TextInputLayout) {
|
||||
return (TextInputLayout) parent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public <T extends ListAdapter & Filterable> void updateText(Object obj) {
|
||||
setText(convertSelectionToString(obj), false);
|
||||
}
|
||||
|
||||
private class MaterialArrayAdapter<T> extends ArrayAdapter<String> {
|
||||
private ColorStateList pressedRippleColor;
|
||||
private ColorStateList selectedItemRippleOverlaidColor;
|
||||
|
||||
MaterialArrayAdapter(Context context, int i, String[] strArr) {
|
||||
super(context, i, strArr);
|
||||
updateSelectedItemColorStateList();
|
||||
}
|
||||
|
||||
void updateSelectedItemColorStateList() {
|
||||
this.pressedRippleColor = sanitizeDropdownItemSelectedRippleColor();
|
||||
this.selectedItemRippleOverlaidColor = createItemSelectedColorStateList();
|
||||
}
|
||||
|
||||
@Override // android.widget.ArrayAdapter, android.widget.Adapter
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
View view2 = super.getView(i, view, viewGroup);
|
||||
if (view2 instanceof TextView) {
|
||||
TextView textView = (TextView) view2;
|
||||
ViewCompat.setBackground(textView, MaterialAutoCompleteTextView.this.getText().toString().contentEquals(textView.getText()) ? getSelectedItemDrawable() : null);
|
||||
}
|
||||
return view2;
|
||||
}
|
||||
|
||||
private Drawable getSelectedItemDrawable() {
|
||||
if (!hasSelectedColor()) {
|
||||
return null;
|
||||
}
|
||||
ColorDrawable colorDrawable = new ColorDrawable(MaterialAutoCompleteTextView.this.simpleItemSelectedColor);
|
||||
if (this.pressedRippleColor == null) {
|
||||
return colorDrawable;
|
||||
}
|
||||
DrawableCompat.setTintList(colorDrawable, this.selectedItemRippleOverlaidColor);
|
||||
return new RippleDrawable(this.pressedRippleColor, colorDrawable, null);
|
||||
}
|
||||
|
||||
private ColorStateList createItemSelectedColorStateList() {
|
||||
if (!hasSelectedColor() || !hasSelectedRippleColor()) {
|
||||
return null;
|
||||
}
|
||||
int[] iArr = {android.R.attr.state_hovered, -16842919};
|
||||
int[] iArr2 = {android.R.attr.state_selected, -16842919};
|
||||
return new ColorStateList(new int[][]{iArr2, iArr, new int[0]}, new int[]{MaterialColors.layer(MaterialAutoCompleteTextView.this.simpleItemSelectedColor, MaterialAutoCompleteTextView.this.simpleItemSelectedRippleColor.getColorForState(iArr2, 0)), MaterialColors.layer(MaterialAutoCompleteTextView.this.simpleItemSelectedColor, MaterialAutoCompleteTextView.this.simpleItemSelectedRippleColor.getColorForState(iArr, 0)), MaterialAutoCompleteTextView.this.simpleItemSelectedColor});
|
||||
}
|
||||
|
||||
private ColorStateList sanitizeDropdownItemSelectedRippleColor() {
|
||||
if (!hasSelectedRippleColor()) {
|
||||
return null;
|
||||
}
|
||||
int[] iArr = {android.R.attr.state_pressed};
|
||||
return new ColorStateList(new int[][]{iArr, new int[0]}, new int[]{MaterialAutoCompleteTextView.this.simpleItemSelectedRippleColor.getColorForState(iArr, 0), 0});
|
||||
}
|
||||
|
||||
private boolean hasSelectedColor() {
|
||||
return MaterialAutoCompleteTextView.this.simpleItemSelectedColor != 0;
|
||||
}
|
||||
|
||||
private boolean hasSelectedRippleColor() {
|
||||
return MaterialAutoCompleteTextView.this.simpleItemSelectedRippleColor != null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class NoEndIconDelegate extends EndIconDelegate {
|
||||
NoEndIconDelegate(EndCompoundLayout endCompoundLayout) {
|
||||
super(endCompoundLayout);
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import com.google.android.material.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class PasswordToggleEndIconDelegate extends EndIconDelegate {
|
||||
private EditText editText;
|
||||
private int iconResId;
|
||||
private final View.OnClickListener onIconClickListener;
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
int getIconDrawableResId() {
|
||||
return this.iconResId;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
View.OnClickListener getOnIconClickListener() {
|
||||
return this.onIconClickListener;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isIconCheckable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$new$0$com-google-android-material-textfield-PasswordToggleEndIconDelegate, reason: not valid java name */
|
||||
/* synthetic */ void m278x4cc26475(View view) {
|
||||
EditText editText = this.editText;
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
int selectionEnd = editText.getSelectionEnd();
|
||||
if (hasPasswordTransformation()) {
|
||||
this.editText.setTransformationMethod(null);
|
||||
} else {
|
||||
this.editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
}
|
||||
if (selectionEnd >= 0) {
|
||||
this.editText.setSelection(selectionEnd);
|
||||
}
|
||||
refreshIconState();
|
||||
}
|
||||
|
||||
PasswordToggleEndIconDelegate(EndCompoundLayout endCompoundLayout, int i) {
|
||||
super(endCompoundLayout);
|
||||
this.iconResId = R.drawable.design_password_eye;
|
||||
this.onIconClickListener = new View.OnClickListener() { // from class: com.google.android.material.textfield.PasswordToggleEndIconDelegate$$ExternalSyntheticLambda0
|
||||
@Override // android.view.View.OnClickListener
|
||||
public final void onClick(View view) {
|
||||
PasswordToggleEndIconDelegate.this.m278x4cc26475(view);
|
||||
}
|
||||
};
|
||||
if (i != 0) {
|
||||
this.iconResId = i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void setUp() {
|
||||
if (isInputTypePassword(this.editText)) {
|
||||
this.editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void tearDown() {
|
||||
EditText editText = this.editText;
|
||||
if (editText != null) {
|
||||
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
int getIconContentDescriptionResId() {
|
||||
return R.string.password_toggle_content_description;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
boolean isIconChecked() {
|
||||
return !hasPasswordTransformation();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void onEditTextAttached(EditText editText) {
|
||||
this.editText = editText;
|
||||
refreshIconState();
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.textfield.EndIconDelegate
|
||||
void beforeEditTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
refreshIconState();
|
||||
}
|
||||
|
||||
private boolean hasPasswordTransformation() {
|
||||
EditText editText = this.editText;
|
||||
return editText != null && (editText.getTransformationMethod() instanceof PasswordTransformationMethod);
|
||||
}
|
||||
|
||||
private static boolean isInputTypePassword(EditText editText) {
|
||||
return editText != null && (editText.getInputType() == 16 || editText.getInputType() == 128 || editText.getInputType() == 144 || editText.getInputType() == 224);
|
||||
}
|
||||
}
|
@ -0,0 +1,260 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.appcompat.widget.TintTypedArray;
|
||||
import androidx.core.view.GravityCompat;
|
||||
import androidx.core.view.MarginLayoutParamsCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.CheckableImageButton;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.resources.MaterialResources;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class StartCompoundLayout extends LinearLayout {
|
||||
private boolean hintExpanded;
|
||||
private CharSequence prefixText;
|
||||
private final TextView prefixTextView;
|
||||
private int startIconMinSize;
|
||||
private View.OnLongClickListener startIconOnLongClickListener;
|
||||
private ImageView.ScaleType startIconScaleType;
|
||||
private ColorStateList startIconTintList;
|
||||
private PorterDuff.Mode startIconTintMode;
|
||||
private final CheckableImageButton startIconView;
|
||||
private final TextInputLayout textInputLayout;
|
||||
|
||||
CharSequence getPrefixText() {
|
||||
return this.prefixText;
|
||||
}
|
||||
|
||||
TextView getPrefixTextView() {
|
||||
return this.prefixTextView;
|
||||
}
|
||||
|
||||
int getStartIconMinSize() {
|
||||
return this.startIconMinSize;
|
||||
}
|
||||
|
||||
ImageView.ScaleType getStartIconScaleType() {
|
||||
return this.startIconScaleType;
|
||||
}
|
||||
|
||||
StartCompoundLayout(TextInputLayout textInputLayout, TintTypedArray tintTypedArray) {
|
||||
super(textInputLayout.getContext());
|
||||
this.textInputLayout = textInputLayout;
|
||||
setVisibility(8);
|
||||
setOrientation(0);
|
||||
setLayoutParams(new FrameLayout.LayoutParams(-2, -1, GravityCompat.START));
|
||||
CheckableImageButton checkableImageButton = (CheckableImageButton) LayoutInflater.from(getContext()).inflate(R.layout.design_text_input_start_icon, (ViewGroup) this, false);
|
||||
this.startIconView = checkableImageButton;
|
||||
IconHelper.setCompatRippleBackgroundIfNeeded(checkableImageButton);
|
||||
AppCompatTextView appCompatTextView = new AppCompatTextView(getContext());
|
||||
this.prefixTextView = appCompatTextView;
|
||||
initStartIconView(tintTypedArray);
|
||||
initPrefixTextView(tintTypedArray);
|
||||
addView(checkableImageButton);
|
||||
addView(appCompatTextView);
|
||||
}
|
||||
|
||||
private void initStartIconView(TintTypedArray tintTypedArray) {
|
||||
if (MaterialResources.isFontScaleAtLeast1_3(getContext())) {
|
||||
MarginLayoutParamsCompat.setMarginEnd((ViewGroup.MarginLayoutParams) this.startIconView.getLayoutParams(), 0);
|
||||
}
|
||||
setStartIconOnClickListener(null);
|
||||
setStartIconOnLongClickListener(null);
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_startIconTint)) {
|
||||
this.startIconTintList = MaterialResources.getColorStateList(getContext(), tintTypedArray, R.styleable.TextInputLayout_startIconTint);
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_startIconTintMode)) {
|
||||
this.startIconTintMode = ViewUtils.parseTintMode(tintTypedArray.getInt(R.styleable.TextInputLayout_startIconTintMode, -1), null);
|
||||
}
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_startIconDrawable)) {
|
||||
setStartIconDrawable(tintTypedArray.getDrawable(R.styleable.TextInputLayout_startIconDrawable));
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_startIconContentDescription)) {
|
||||
setStartIconContentDescription(tintTypedArray.getText(R.styleable.TextInputLayout_startIconContentDescription));
|
||||
}
|
||||
setStartIconCheckable(tintTypedArray.getBoolean(R.styleable.TextInputLayout_startIconCheckable, true));
|
||||
}
|
||||
setStartIconMinSize(tintTypedArray.getDimensionPixelSize(R.styleable.TextInputLayout_startIconMinSize, getResources().getDimensionPixelSize(R.dimen.mtrl_min_touch_target_size)));
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_startIconScaleType)) {
|
||||
setStartIconScaleType(IconHelper.convertScaleType(tintTypedArray.getInt(R.styleable.TextInputLayout_startIconScaleType, -1)));
|
||||
}
|
||||
}
|
||||
|
||||
private void initPrefixTextView(TintTypedArray tintTypedArray) {
|
||||
this.prefixTextView.setVisibility(8);
|
||||
this.prefixTextView.setId(R.id.textinput_prefix_text);
|
||||
this.prefixTextView.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
|
||||
ViewCompat.setAccessibilityLiveRegion(this.prefixTextView, 1);
|
||||
setPrefixTextAppearance(tintTypedArray.getResourceId(R.styleable.TextInputLayout_prefixTextAppearance, 0));
|
||||
if (tintTypedArray.hasValue(R.styleable.TextInputLayout_prefixTextColor)) {
|
||||
setPrefixTextColor(tintTypedArray.getColorStateList(R.styleable.TextInputLayout_prefixTextColor));
|
||||
}
|
||||
setPrefixText(tintTypedArray.getText(R.styleable.TextInputLayout_prefixText));
|
||||
}
|
||||
|
||||
@Override // android.widget.LinearLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
super.onMeasure(i, i2);
|
||||
updatePrefixTextViewPadding();
|
||||
}
|
||||
|
||||
void setPrefixText(CharSequence charSequence) {
|
||||
this.prefixText = TextUtils.isEmpty(charSequence) ? null : charSequence;
|
||||
this.prefixTextView.setText(charSequence);
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
void setPrefixTextColor(ColorStateList colorStateList) {
|
||||
this.prefixTextView.setTextColor(colorStateList);
|
||||
}
|
||||
|
||||
ColorStateList getPrefixTextColor() {
|
||||
return this.prefixTextView.getTextColors();
|
||||
}
|
||||
|
||||
void setPrefixTextAppearance(int i) {
|
||||
TextViewCompat.setTextAppearance(this.prefixTextView, i);
|
||||
}
|
||||
|
||||
void setStartIconDrawable(Drawable drawable) {
|
||||
this.startIconView.setImageDrawable(drawable);
|
||||
if (drawable != null) {
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.startIconView, this.startIconTintList, this.startIconTintMode);
|
||||
setStartIconVisible(true);
|
||||
refreshStartIconDrawableState();
|
||||
} else {
|
||||
setStartIconVisible(false);
|
||||
setStartIconOnClickListener(null);
|
||||
setStartIconOnLongClickListener(null);
|
||||
setStartIconContentDescription(null);
|
||||
}
|
||||
}
|
||||
|
||||
Drawable getStartIconDrawable() {
|
||||
return this.startIconView.getDrawable();
|
||||
}
|
||||
|
||||
void setStartIconOnClickListener(View.OnClickListener onClickListener) {
|
||||
IconHelper.setIconOnClickListener(this.startIconView, onClickListener, this.startIconOnLongClickListener);
|
||||
}
|
||||
|
||||
void setStartIconOnLongClickListener(View.OnLongClickListener onLongClickListener) {
|
||||
this.startIconOnLongClickListener = onLongClickListener;
|
||||
IconHelper.setIconOnLongClickListener(this.startIconView, onLongClickListener);
|
||||
}
|
||||
|
||||
void setStartIconVisible(boolean z) {
|
||||
if (isStartIconVisible() != z) {
|
||||
this.startIconView.setVisibility(z ? 0 : 8);
|
||||
updatePrefixTextViewPadding();
|
||||
updateVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isStartIconVisible() {
|
||||
return this.startIconView.getVisibility() == 0;
|
||||
}
|
||||
|
||||
void refreshStartIconDrawableState() {
|
||||
IconHelper.refreshIconDrawableState(this.textInputLayout, this.startIconView, this.startIconTintList);
|
||||
}
|
||||
|
||||
void setStartIconCheckable(boolean z) {
|
||||
this.startIconView.setCheckable(z);
|
||||
}
|
||||
|
||||
boolean isStartIconCheckable() {
|
||||
return this.startIconView.isCheckable();
|
||||
}
|
||||
|
||||
void setStartIconContentDescription(CharSequence charSequence) {
|
||||
if (getStartIconContentDescription() != charSequence) {
|
||||
this.startIconView.setContentDescription(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence getStartIconContentDescription() {
|
||||
return this.startIconView.getContentDescription();
|
||||
}
|
||||
|
||||
void setStartIconTintList(ColorStateList colorStateList) {
|
||||
if (this.startIconTintList != colorStateList) {
|
||||
this.startIconTintList = colorStateList;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.startIconView, colorStateList, this.startIconTintMode);
|
||||
}
|
||||
}
|
||||
|
||||
void setStartIconTintMode(PorterDuff.Mode mode) {
|
||||
if (this.startIconTintMode != mode) {
|
||||
this.startIconTintMode = mode;
|
||||
IconHelper.applyIconTint(this.textInputLayout, this.startIconView, this.startIconTintList, mode);
|
||||
}
|
||||
}
|
||||
|
||||
void setStartIconMinSize(int i) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("startIconSize cannot be less than 0");
|
||||
}
|
||||
if (i != this.startIconMinSize) {
|
||||
this.startIconMinSize = i;
|
||||
IconHelper.setIconMinSize(this.startIconView, i);
|
||||
}
|
||||
}
|
||||
|
||||
void setStartIconScaleType(ImageView.ScaleType scaleType) {
|
||||
this.startIconScaleType = scaleType;
|
||||
IconHelper.setIconScaleType(this.startIconView, scaleType);
|
||||
}
|
||||
|
||||
void setupAccessibilityNodeInfo(AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||||
if (this.prefixTextView.getVisibility() == 0) {
|
||||
accessibilityNodeInfoCompat.setLabelFor(this.prefixTextView);
|
||||
accessibilityNodeInfoCompat.setTraversalAfter(this.prefixTextView);
|
||||
} else {
|
||||
accessibilityNodeInfoCompat.setTraversalAfter(this.startIconView);
|
||||
}
|
||||
}
|
||||
|
||||
void updatePrefixTextViewPadding() {
|
||||
EditText editText = this.textInputLayout.editText;
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
ViewCompat.setPaddingRelative(this.prefixTextView, isStartIconVisible() ? 0 : ViewCompat.getPaddingStart(editText), editText.getCompoundPaddingTop(), getContext().getResources().getDimensionPixelSize(R.dimen.material_input_text_to_prefix_suffix_padding), editText.getCompoundPaddingBottom());
|
||||
}
|
||||
|
||||
int getPrefixTextStartOffset() {
|
||||
return ViewCompat.getPaddingStart(this) + ViewCompat.getPaddingStart(this.prefixTextView) + (isStartIconVisible() ? this.startIconView.getMeasuredWidth() + MarginLayoutParamsCompat.getMarginEnd((ViewGroup.MarginLayoutParams) this.startIconView.getLayoutParams()) : 0);
|
||||
}
|
||||
|
||||
void onHintStateChanged(boolean z) {
|
||||
this.hintExpanded = z;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
private void updateVisibility() {
|
||||
int i = 0;
|
||||
int i2 = (this.prefixText == null || this.hintExpanded) ? 8 : 0;
|
||||
if (this.startIconView.getVisibility() != 0 && i2 != 0) {
|
||||
i = 8;
|
||||
}
|
||||
setVisibility(i);
|
||||
this.prefixTextView.setVisibility(i2);
|
||||
this.textInputLayout.updateDummyDrawables();
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package com.google.android.material.textfield;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import androidx.appcompat.widget.AppCompatEditText;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.internal.ManufacturerUtils;
|
||||
import com.google.android.material.internal.ThemeEnforcement;
|
||||
import com.google.android.material.theme.overlay.MaterialThemeOverlay;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TextInputEditText extends AppCompatEditText {
|
||||
private final Rect parentRect;
|
||||
private boolean textInputLayoutFocusedRectEnabled;
|
||||
|
||||
private boolean shouldUseTextInputLayoutFocusedRect(TextInputLayout textInputLayout) {
|
||||
return textInputLayout != null && this.textInputLayoutFocusedRectEnabled;
|
||||
}
|
||||
|
||||
public boolean isTextInputLayoutFocusedRectEnabled() {
|
||||
return this.textInputLayoutFocusedRectEnabled;
|
||||
}
|
||||
|
||||
public void setTextInputLayoutFocusedRectEnabled(boolean z) {
|
||||
this.textInputLayoutFocusedRectEnabled = z;
|
||||
}
|
||||
|
||||
public TextInputEditText(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TextInputEditText(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R.attr.editTextStyle);
|
||||
}
|
||||
|
||||
public TextInputEditText(Context context, AttributeSet attributeSet, int i) {
|
||||
super(MaterialThemeOverlay.wrap(context, attributeSet, i, 0), attributeSet, i);
|
||||
this.parentRect = new Rect();
|
||||
TypedArray obtainStyledAttributes = ThemeEnforcement.obtainStyledAttributes(context, attributeSet, R.styleable.TextInputEditText, i, R.style.Widget_Design_TextInputEditText, new int[0]);
|
||||
setTextInputLayoutFocusedRectEnabled(obtainStyledAttributes.getBoolean(R.styleable.TextInputEditText_textInputLayoutFocusedRectEnabled, false));
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (textInputLayout != null && textInputLayout.isProvidingHint() && super.getHint() == null && ManufacturerUtils.isMeizuDevice()) {
|
||||
setHint("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView
|
||||
public CharSequence getHint() {
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (textInputLayout != null && textInputLayout.isProvidingHint()) {
|
||||
return textInputLayout.getHint();
|
||||
}
|
||||
return super.getHint();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.widget.AppCompatEditText, android.widget.TextView, android.view.View
|
||||
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
||||
InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo);
|
||||
if (onCreateInputConnection != null && editorInfo.hintText == null) {
|
||||
editorInfo.hintText = getHintFromLayout();
|
||||
}
|
||||
return onCreateInputConnection;
|
||||
}
|
||||
|
||||
private TextInputLayout getTextInputLayout() {
|
||||
for (ViewParent parent = getParent(); parent instanceof View; parent = parent.getParent()) {
|
||||
if (parent instanceof TextInputLayout) {
|
||||
return (TextInputLayout) parent;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CharSequence getHintFromLayout() {
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (textInputLayout != null) {
|
||||
return textInputLayout.getHint();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.widget.TextView, android.view.View
|
||||
public void getFocusedRect(Rect rect) {
|
||||
super.getFocusedRect(rect);
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (!shouldUseTextInputLayoutFocusedRect(textInputLayout) || rect == null) {
|
||||
return;
|
||||
}
|
||||
textInputLayout.getFocusedRect(this.parentRect);
|
||||
rect.bottom = this.parentRect.bottom;
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean getGlobalVisibleRect(Rect rect, Point point) {
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (shouldUseTextInputLayoutFocusedRect(textInputLayout)) {
|
||||
boolean globalVisibleRect = textInputLayout.getGlobalVisibleRect(rect, point);
|
||||
if (globalVisibleRect && point != null) {
|
||||
point.offset(-getScrollX(), -getScrollY());
|
||||
}
|
||||
return globalVisibleRect;
|
||||
}
|
||||
return super.getGlobalVisibleRect(rect, point);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean requestRectangleOnScreen(Rect rect) {
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (shouldUseTextInputLayoutFocusedRect(textInputLayout) && rect != null) {
|
||||
this.parentRect.set(rect.left, rect.top, rect.right, rect.bottom + (textInputLayout.getHeight() - getHeight()));
|
||||
return super.requestRectangleOnScreen(this.parentRect);
|
||||
}
|
||||
return super.requestRectangleOnScreen(rect);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
TextInputLayout textInputLayout = getTextInputLayout();
|
||||
if (Build.VERSION.SDK_INT >= 23 || textInputLayout == null) {
|
||||
return;
|
||||
}
|
||||
accessibilityNodeInfo.setText(getAccessibilityNodeInfoText(textInputLayout));
|
||||
}
|
||||
|
||||
private String getAccessibilityNodeInfoText(TextInputLayout textInputLayout) {
|
||||
Editable text = getText();
|
||||
CharSequence hint = textInputLayout.getHint();
|
||||
boolean z = !TextUtils.isEmpty(text);
|
||||
String str = "";
|
||||
String charSequence = TextUtils.isEmpty(hint) ^ true ? hint.toString() : "";
|
||||
if (!z) {
|
||||
return !TextUtils.isEmpty(charSequence) ? charSequence : "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append((Object) text);
|
||||
if (!TextUtils.isEmpty(charSequence)) {
|
||||
str = ", " + charSequence;
|
||||
}
|
||||
sb.append(str);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user