Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
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.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.view.View;
/* loaded from: classes.dex */
class CutoutDrawable extends GradientDrawable {
private final Paint a = new Paint(1);
private final RectF b;
private int c;
CutoutDrawable() {
c();
this.b = new RectF();
}
private void c() {
this.a.setStyle(Paint.Style.FILL_AND_STROKE);
this.a.setColor(-1);
this.a.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
}
boolean a() {
return !this.b.isEmpty();
}
void b() {
a(0.0f, 0.0f, 0.0f, 0.0f);
}
@Override // android.graphics.drawable.GradientDrawable, android.graphics.drawable.Drawable
public void draw(Canvas canvas) {
b(canvas);
super.draw(canvas);
canvas.drawRect(this.b, this.a);
a(canvas);
}
private void b(Canvas canvas) {
Drawable.Callback callback = getCallback();
if (a(callback)) {
((View) callback).setLayerType(2, null);
} else {
c(canvas);
}
}
void a(float f, float f2, float f3, float f4) {
RectF rectF = this.b;
if (f == rectF.left && f2 == rectF.top && f3 == rectF.right && f4 == rectF.bottom) {
return;
}
this.b.set(f, f2, f3, f4);
invalidateSelf();
}
private void c(Canvas canvas) {
if (Build.VERSION.SDK_INT >= 21) {
this.c = canvas.saveLayer(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight(), null);
} else {
this.c = canvas.saveLayer(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight(), null, 31);
}
}
void a(RectF rectF) {
a(rectF.left, rectF.top, rectF.right, rectF.bottom);
}
private void a(Canvas canvas) {
if (a(getCallback())) {
return;
}
canvas.restoreToCount(this.c);
}
private boolean a(Drawable.Callback callback) {
return callback instanceof View;
}
}

View File

@@ -0,0 +1,407 @@
package com.google.android.material.textfield;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
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.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 androidx.legacy.widget.Space;
import com.google.android.material.R$dimen;
import com.google.android.material.R$id;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.animation.AnimatorSetCompat;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
final class IndicatorViewController {
private final Context a;
private final TextInputLayout b;
private LinearLayout c;
private int d;
private FrameLayout e;
private int f;
private Animator g;
private final float h;
private int i;
private int j;
private CharSequence k;
private boolean l;
private TextView m;
private int n;
private CharSequence o;
private boolean p;
private TextView q;
private int r;
private Typeface s;
public IndicatorViewController(TextInputLayout textInputLayout) {
this.a = textInputLayout.getContext();
this.b = textInputLayout;
this.h = this.a.getResources().getDimensionPixelSize(R$dimen.design_textinput_caption_translate_y);
}
private TextView d(int i) {
if (i == 1) {
return this.m;
}
if (i != 2) {
return null;
}
return this.q;
}
private boolean e(int i) {
return (i != 1 || this.m == null || TextUtils.isEmpty(this.k)) ? false : true;
}
private boolean m() {
return (this.c == null || this.b.getEditText() == null) ? false : true;
}
boolean a(int i) {
return i == 0 || i == 1;
}
void b(CharSequence charSequence) {
b();
this.o = charSequence;
this.q.setText(charSequence);
if (this.i != 2) {
this.j = 2;
}
a(this.i, this.j, a(this.q, charSequence));
}
boolean c() {
return e(this.j);
}
ColorStateList f() {
TextView textView = this.m;
if (textView != null) {
return textView.getTextColors();
}
return null;
}
CharSequence g() {
return this.o;
}
int h() {
TextView textView = this.q;
if (textView != null) {
return textView.getCurrentTextColor();
}
return -1;
}
void i() {
this.k = null;
b();
if (this.i == 1) {
if (!this.p || TextUtils.isEmpty(this.o)) {
this.j = 0;
} else {
this.j = 2;
}
}
a(this.i, this.j, a(this.m, (CharSequence) null));
}
void j() {
b();
if (this.i == 2) {
this.j = 0;
}
a(this.i, this.j, a(this.q, (CharSequence) null));
}
boolean k() {
return this.l;
}
boolean l() {
return this.p;
}
void c(int i) {
this.r = i;
TextView textView = this.q;
if (textView != null) {
TextViewCompat.d(textView, i);
}
}
CharSequence d() {
return this.k;
}
int e() {
TextView textView = this.m;
if (textView != null) {
return textView.getCurrentTextColor();
}
return -1;
}
void a(CharSequence charSequence) {
b();
this.k = charSequence;
this.m.setText(charSequence);
if (this.i != 1) {
this.j = 1;
}
a(this.i, this.j, a(this.m, charSequence));
}
void b() {
Animator animator = this.g;
if (animator != null) {
animator.cancel();
}
}
void b(TextView textView, int i) {
FrameLayout frameLayout;
if (this.c == null) {
return;
}
if (a(i) && (frameLayout = this.e) != null) {
this.f--;
a(frameLayout, this.f);
this.e.removeView(textView);
} else {
this.c.removeView(textView);
}
this.d--;
a(this.c, this.d);
}
private boolean a(TextView textView, CharSequence charSequence) {
return ViewCompat.x(this.b) && this.b.isEnabled() && !(this.j == this.i && textView != null && TextUtils.equals(textView.getText(), charSequence));
}
private void a(final int i, final int i2, boolean z) {
if (z) {
AnimatorSet animatorSet = new AnimatorSet();
this.g = animatorSet;
ArrayList arrayList = new ArrayList();
a(arrayList, this.p, this.q, 2, i, i2);
a(arrayList, this.l, this.m, 1, i, i2);
AnimatorSetCompat.a(animatorSet, arrayList);
final TextView d = d(i);
final TextView d2 = d(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.i = i2;
IndicatorViewController.this.g = null;
TextView textView = d;
if (textView != null) {
textView.setVisibility(4);
if (i != 1 || IndicatorViewController.this.m == null) {
return;
}
IndicatorViewController.this.m.setText((CharSequence) null);
}
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
TextView textView = d2;
if (textView != null) {
textView.setVisibility(0);
}
}
});
animatorSet.start();
} else {
a(i, i2);
}
this.b.c();
this.b.b(z);
this.b.d();
}
void b(boolean z) {
if (this.p == z) {
return;
}
b();
if (z) {
this.q = new AppCompatTextView(this.a);
this.q.setId(R$id.textinput_helper_text);
Typeface typeface = this.s;
if (typeface != null) {
this.q.setTypeface(typeface);
}
this.q.setVisibility(4);
ViewCompat.e((View) this.q, 1);
c(this.r);
a(this.q, 1);
} else {
j();
b(this.q, 1);
this.q = null;
this.b.c();
this.b.d();
}
this.p = z;
}
private void a(int i, int i2) {
TextView d;
TextView d2;
if (i == i2) {
return;
}
if (i2 != 0 && (d2 = d(i2)) != null) {
d2.setVisibility(0);
d2.setAlpha(1.0f);
}
if (i != 0 && (d = d(i)) != null) {
d.setVisibility(4);
if (i == 1) {
d.setText((CharSequence) null);
}
}
this.i = i2;
}
void b(int i) {
this.n = i;
TextView textView = this.m;
if (textView != null) {
this.b.a(textView, i);
}
}
private void a(List<Animator> list, boolean z, TextView textView, int i, int i2, int i3) {
if (textView == null || !z) {
return;
}
if (i == i3 || i == i2) {
list.add(a(textView, i3 == i));
if (i3 == i) {
list.add(a(textView));
}
}
}
void b(ColorStateList colorStateList) {
TextView textView = this.q;
if (textView != null) {
textView.setTextColor(colorStateList);
}
}
private ObjectAnimator a(TextView textView, boolean z) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, (Property<TextView, Float>) View.ALPHA, z ? 1.0f : 0.0f);
ofFloat.setDuration(167L);
ofFloat.setInterpolator(AnimationUtils.a);
return ofFloat;
}
private ObjectAnimator a(TextView textView) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(textView, (Property<TextView, Float>) View.TRANSLATION_Y, -this.h, 0.0f);
ofFloat.setDuration(217L);
ofFloat.setInterpolator(AnimationUtils.d);
return ofFloat;
}
void a() {
if (m()) {
ViewCompat.a(this.c, ViewCompat.o(this.b.getEditText()), 0, ViewCompat.n(this.b.getEditText()), 0);
}
}
void a(TextView textView, int i) {
if (this.c == null && this.e == null) {
this.c = new LinearLayout(this.a);
this.c.setOrientation(0);
this.b.addView(this.c, -1, -2);
this.e = new FrameLayout(this.a);
this.c.addView(this.e, -1, new FrameLayout.LayoutParams(-2, -2));
this.c.addView(new Space(this.a), new LinearLayout.LayoutParams(0, 0, 1.0f));
if (this.b.getEditText() != null) {
a();
}
}
if (a(i)) {
this.e.setVisibility(0);
this.e.addView(textView);
this.f++;
} else {
this.c.addView(textView, i);
}
this.c.setVisibility(0);
this.d++;
}
private void a(ViewGroup viewGroup, int i) {
if (i == 0) {
viewGroup.setVisibility(8);
}
}
void a(boolean z) {
if (this.l == z) {
return;
}
b();
if (z) {
this.m = new AppCompatTextView(this.a);
this.m.setId(R$id.textinput_error);
Typeface typeface = this.s;
if (typeface != null) {
this.m.setTypeface(typeface);
}
b(this.n);
this.m.setVisibility(4);
ViewCompat.e((View) this.m, 1);
a(this.m, 0);
} else {
i();
b(this.m, 0);
this.m = null;
this.b.c();
this.b.d();
}
this.l = z;
}
void a(Typeface typeface) {
if (typeface != this.s) {
this.s = typeface;
a(this.m, typeface);
a(this.q, typeface);
}
}
private void a(TextView textView, Typeface typeface) {
if (textView != null) {
textView.setTypeface(typeface);
}
}
void a(ColorStateList colorStateList) {
TextView textView = this.m;
if (textView != null) {
textView.setTextColor(colorStateList);
}
}
}

View File

@@ -0,0 +1,57 @@
package com.google.android.material.textfield;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import androidx.appcompat.widget.AppCompatEditText;
import com.google.android.material.R$attr;
/* loaded from: classes.dex */
public class TextInputEditText extends AppCompatEditText {
public TextInputEditText(Context context) {
this(context, null);
}
private CharSequence getHintFromLayout() {
TextInputLayout textInputLayout = getTextInputLayout();
if (textInputLayout != null) {
return textInputLayout.getHint();
}
return null;
}
private TextInputLayout getTextInputLayout() {
for (ViewParent parent = getParent(); parent instanceof View; parent = parent.getParent()) {
if (parent instanceof TextInputLayout) {
return (TextInputLayout) parent;
}
}
return null;
}
@Override // android.widget.TextView
public CharSequence getHint() {
TextInputLayout textInputLayout = getTextInputLayout();
return (textInputLayout == null || !textInputLayout.b()) ? super.getHint() : textInputLayout.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;
}
public TextInputEditText(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R$attr.editTextStyle);
}
public TextInputEditText(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
}
}

File diff suppressed because it is too large Load Diff