what-the-bank/sources/com/google/android/material/textfield/TextInputEditText.java

129 lines
4.4 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
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.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 java.util.Locale;
import o.C17052tZT;
import o.hdZ;
import o.uqW;
/* loaded from: classes2.dex */
public class TextInputEditText extends AppCompatEditText {
private final Rect c;
private boolean d;
public TextInputEditText(Context context) {
this(context, null);
}
public TextInputEditText(Context context, AttributeSet attributeSet) {
this(context, attributeSet, C17052tZT.IeS.editTextStyle);
}
public TextInputEditText(Context context, AttributeSet attributeSet, int i) {
super(hdZ.MQ_(context, attributeSet, i, 0), attributeSet, i);
this.c = new Rect();
int[] iArr = C17052tZT.jNh.TextInputEditText;
int i2 = C17052tZT.NHB.Widget_Design_TextInputEditText;
uqW.Kb_(context, attributeSet, i, i2);
uqW.Kc_(context, attributeSet, iArr, i, i2, new int[0]);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, i, i2);
setTextInputLayoutFocusedRectEnabled(obtainStyledAttributes.getBoolean(C17052tZT.jNh.TextInputEditText_textInputLayoutFocusedRectEnabled, false));
obtainStyledAttributes.recycle();
}
@Override // android.widget.TextView, android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
TextInputLayout e = e();
if (e != null && e.n && super.getHint() == null && Build.MANUFACTURER.toLowerCase(Locale.ENGLISH).equals("meizu")) {
setHint("");
}
}
@Override // android.widget.TextView
public CharSequence getHint() {
TextInputLayout e = e();
if (e == null || !e.n) {
return super.getHint();
}
if (e.m) {
return e.j;
}
return null;
}
@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) {
TextInputLayout e = e();
CharSequence charSequence = null;
if (e != null && e.m) {
charSequence = e.j;
}
editorInfo.hintText = charSequence;
}
return onCreateInputConnection;
}
private TextInputLayout e() {
for (ViewParent parent = getParent(); parent instanceof View; parent = parent.getParent()) {
if (parent instanceof TextInputLayout) {
return (TextInputLayout) parent;
}
}
return null;
}
@Override // android.widget.TextView, android.view.View
public void getFocusedRect(Rect rect) {
super.getFocusedRect(rect);
TextInputLayout e = e();
if (e == null || !this.d || rect == null) {
return;
}
e.getFocusedRect(this.c);
rect.bottom = this.c.bottom;
}
@Override // android.view.View
public boolean getGlobalVisibleRect(Rect rect, Point point) {
TextInputLayout e = e();
if (e != null && this.d) {
return e.getGlobalVisibleRect(rect, point);
}
return super.getGlobalVisibleRect(rect, point);
}
@Override // android.view.View
public boolean requestRectangleOnScreen(Rect rect) {
TextInputLayout e = e();
if (e != null && this.d && rect != null) {
this.c.set(rect.left, rect.top, rect.right, rect.bottom + (e.getHeight() - getHeight()));
return super.requestRectangleOnScreen(this.c);
}
return super.requestRectangleOnScreen(rect);
}
@Override // android.view.View
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
e();
}
public void setTextInputLayoutFocusedRectEnabled(boolean z) {
this.d = z;
}
}