Rabbit-R1/switch port/java/sources/androidx/appcompat/widget/AppCompatEditText.java
2024-05-21 17:08:36 -04:00

281 lines
12 KiB
Java

package androidx.appcompat.widget;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.method.KeyListener;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.DragEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.textclassifier.TextClassifier;
import android.widget.EditText;
import androidx.appcompat.R;
import androidx.core.view.ContentInfoCompat;
import androidx.core.view.OnReceiveContentViewBehavior;
import androidx.core.view.TintableBackgroundView;
import androidx.core.widget.TextViewCompat;
import androidx.core.widget.TextViewOnReceiveContentListener;
import androidx.core.widget.TintableCompoundDrawablesView;
/* loaded from: classes.dex */
public class AppCompatEditText extends EditText implements TintableBackgroundView, OnReceiveContentViewBehavior, EmojiCompatConfigurationView, TintableCompoundDrawablesView {
private final AppCompatEmojiEditTextHelper mAppCompatEmojiEditTextHelper;
private final AppCompatBackgroundHelper mBackgroundTintHelper;
private final TextViewOnReceiveContentListener mDefaultOnReceiveContentListener;
private SuperCaller mSuperCaller;
private final AppCompatTextClassifierHelper mTextClassifierHelper;
private final AppCompatTextHelper mTextHelper;
public AppCompatEditText(Context context) {
this(context, null);
}
public AppCompatEditText(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.editTextStyle);
}
public AppCompatEditText(Context context, AttributeSet attributeSet, int i) {
super(TintContextWrapper.wrap(context), attributeSet, i);
ThemeUtils.checkAppCompatTheme(this, getContext());
AppCompatBackgroundHelper appCompatBackgroundHelper = new AppCompatBackgroundHelper(this);
this.mBackgroundTintHelper = appCompatBackgroundHelper;
appCompatBackgroundHelper.loadFromAttributes(attributeSet, i);
AppCompatTextHelper appCompatTextHelper = new AppCompatTextHelper(this);
this.mTextHelper = appCompatTextHelper;
appCompatTextHelper.loadFromAttributes(attributeSet, i);
appCompatTextHelper.applyCompoundDrawablesTints();
this.mTextClassifierHelper = new AppCompatTextClassifierHelper(this);
this.mDefaultOnReceiveContentListener = new TextViewOnReceiveContentListener();
AppCompatEmojiEditTextHelper appCompatEmojiEditTextHelper = new AppCompatEmojiEditTextHelper(this);
this.mAppCompatEmojiEditTextHelper = appCompatEmojiEditTextHelper;
appCompatEmojiEditTextHelper.loadFromAttributes(attributeSet, i);
initEmojiKeyListener(appCompatEmojiEditTextHelper);
}
void initEmojiKeyListener(AppCompatEmojiEditTextHelper appCompatEmojiEditTextHelper) {
KeyListener keyListener = getKeyListener();
if (appCompatEmojiEditTextHelper.isEmojiCapableKeyListener(keyListener)) {
boolean isFocusable = super.isFocusable();
boolean isClickable = super.isClickable();
boolean isLongClickable = super.isLongClickable();
int inputType = super.getInputType();
KeyListener keyListener2 = appCompatEmojiEditTextHelper.getKeyListener(keyListener);
if (keyListener2 == keyListener) {
return;
}
super.setKeyListener(keyListener2);
super.setRawInputType(inputType);
super.setFocusable(isFocusable);
super.setClickable(isClickable);
super.setLongClickable(isLongClickable);
}
}
@Override // android.widget.EditText, android.widget.TextView
public Editable getText() {
return super.getText();
}
@Override // android.view.View
public void setBackgroundResource(int i) {
super.setBackgroundResource(i);
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.onSetBackgroundResource(i);
}
}
@Override // android.view.View
public void setBackgroundDrawable(Drawable drawable) {
super.setBackgroundDrawable(drawable);
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.onSetBackgroundDrawable(drawable);
}
}
@Override // androidx.core.view.TintableBackgroundView
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.setSupportBackgroundTintList(colorStateList);
}
}
@Override // androidx.core.view.TintableBackgroundView
public ColorStateList getSupportBackgroundTintList() {
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
return appCompatBackgroundHelper.getSupportBackgroundTintList();
}
return null;
}
@Override // androidx.core.view.TintableBackgroundView
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.setSupportBackgroundTintMode(mode);
}
}
@Override // androidx.core.view.TintableBackgroundView
public PorterDuff.Mode getSupportBackgroundTintMode() {
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
return appCompatBackgroundHelper.getSupportBackgroundTintMode();
}
return null;
}
@Override // android.widget.TextView, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.applySupportBackgroundTint();
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.applyCompoundDrawablesTints();
}
}
@Override // android.widget.TextView
public void setTextAppearance(Context context, int i) {
super.setTextAppearance(context, i);
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.onSetTextAppearance(context, i);
}
}
@Override // android.widget.TextView, android.view.View
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo);
this.mTextHelper.populateSurroundingTextIfNeeded(this, onCreateInputConnection, editorInfo);
return this.mAppCompatEmojiEditTextHelper.onCreateInputConnection(AppCompatHintHelper.onCreateInputConnection(onCreateInputConnection, editorInfo, this), editorInfo);
}
@Override // android.widget.TextView
public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
super.setCustomSelectionActionModeCallback(TextViewCompat.wrapCustomSelectionActionModeCallback(this, callback));
}
@Override // android.widget.TextView
public ActionMode.Callback getCustomSelectionActionModeCallback() {
return TextViewCompat.unwrapCustomSelectionActionModeCallback(super.getCustomSelectionActionModeCallback());
}
private SuperCaller getSuperCaller() {
if (this.mSuperCaller == null) {
this.mSuperCaller = new SuperCaller();
}
return this.mSuperCaller;
}
@Override // android.widget.TextView
public void setTextClassifier(TextClassifier textClassifier) {
getSuperCaller().setTextClassifier(textClassifier);
}
@Override // android.widget.TextView
public TextClassifier getTextClassifier() {
return getSuperCaller().getTextClassifier();
}
@Override // android.widget.TextView, android.view.View
public boolean onDragEvent(DragEvent dragEvent) {
if (AppCompatReceiveContentHelper.maybeHandleDragEventViaPerformReceiveContent(this, dragEvent)) {
return true;
}
return super.onDragEvent(dragEvent);
}
@Override // android.widget.EditText, android.widget.TextView
public boolean onTextContextMenuItem(int i) {
if (AppCompatReceiveContentHelper.maybeHandleMenuActionViaPerformReceiveContent(this, i)) {
return true;
}
return super.onTextContextMenuItem(i);
}
@Override // androidx.core.view.OnReceiveContentViewBehavior
public ContentInfoCompat onReceiveContent(ContentInfoCompat contentInfoCompat) {
return this.mDefaultOnReceiveContentListener.onReceiveContent(this, contentInfoCompat);
}
@Override // android.widget.TextView
public void setKeyListener(KeyListener keyListener) {
super.setKeyListener(this.mAppCompatEmojiEditTextHelper.getKeyListener(keyListener));
}
@Override // androidx.appcompat.widget.EmojiCompatConfigurationView
public void setEmojiCompatEnabled(boolean z) {
this.mAppCompatEmojiEditTextHelper.setEnabled(z);
}
@Override // androidx.appcompat.widget.EmojiCompatConfigurationView
public boolean isEmojiCompatEnabled() {
return this.mAppCompatEmojiEditTextHelper.isEnabled();
}
@Override // android.widget.TextView
public void setCompoundDrawables(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
super.setCompoundDrawables(drawable, drawable2, drawable3, drawable4);
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.onSetCompoundDrawables();
}
}
@Override // android.widget.TextView
public void setCompoundDrawablesRelative(Drawable drawable, Drawable drawable2, Drawable drawable3, Drawable drawable4) {
super.setCompoundDrawablesRelative(drawable, drawable2, drawable3, drawable4);
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.onSetCompoundDrawables();
}
}
@Override // androidx.core.widget.TintableCompoundDrawablesView
public ColorStateList getSupportCompoundDrawablesTintList() {
return this.mTextHelper.getCompoundDrawableTintList();
}
@Override // androidx.core.widget.TintableCompoundDrawablesView
public void setSupportCompoundDrawablesTintList(ColorStateList colorStateList) {
this.mTextHelper.setCompoundDrawableTintList(colorStateList);
this.mTextHelper.applyCompoundDrawablesTints();
}
@Override // androidx.core.widget.TintableCompoundDrawablesView
public PorterDuff.Mode getSupportCompoundDrawablesTintMode() {
return this.mTextHelper.getCompoundDrawableTintMode();
}
@Override // androidx.core.widget.TintableCompoundDrawablesView
public void setSupportCompoundDrawablesTintMode(PorterDuff.Mode mode) {
this.mTextHelper.setCompoundDrawableTintMode(mode);
this.mTextHelper.applyCompoundDrawablesTints();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public class SuperCaller {
SuperCaller() {
}
public TextClassifier getTextClassifier() {
return AppCompatEditText.super.getTextClassifier();
}
public void setTextClassifier(TextClassifier textClassifier) {
AppCompatEditText.super.setTextClassifier(textClassifier);
}
}
}