package androidx.appcompat.widget; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; 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.inputmethod.InputMethodManager; import android.view.inspector.PropertyMapper; import android.view.inspector.PropertyReader; import android.view.textclassifier.TextClassifier; import android.widget.EditText; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.annotation.RestrictTo; import androidx.annotation.UiThread; import androidx.appcompat.R; import androidx.core.view.ContentInfoCompat; import androidx.core.view.OnReceiveContentViewBehavior; import androidx.core.view.TintableBackgroundView; import androidx.core.view.ViewCompat; import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.core.view.inputmethod.InputConnectionCompat; 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 { @NonNull private final AppCompatEmojiEditTextHelper mAppCompatEmojiEditTextHelper; private final AppCompatBackgroundHelper mBackgroundTintHelper; private final TextViewOnReceiveContentListener mDefaultOnReceiveContentListener; @Nullable private SuperCaller mSuperCaller; private final AppCompatTextClassifierHelper mTextClassifierHelper; private final AppCompatTextHelper mTextHelper; @RequiresApi(29) @RestrictTo({RestrictTo.Scope.LIBRARY}) public final class InspectionCompanion implements android.view.inspector.InspectionCompanion { private int mBackgroundTintId; private int mBackgroundTintModeId; private int mDrawableTintId; private int mDrawableTintModeId; private boolean mPropertiesMapped = false; public void mapProperties(@NonNull PropertyMapper propertyMapper) { int mapObject; int mapObject2; int mapObject3; int mapObject4; mapObject = propertyMapper.mapObject("backgroundTint", R.attr.backgroundTint); this.mBackgroundTintId = mapObject; mapObject2 = propertyMapper.mapObject("backgroundTintMode", R.attr.backgroundTintMode); this.mBackgroundTintModeId = mapObject2; mapObject3 = propertyMapper.mapObject("drawableTint", R.attr.drawableTint); this.mDrawableTintId = mapObject3; mapObject4 = propertyMapper.mapObject("drawableTintMode", R.attr.drawableTintMode); this.mDrawableTintModeId = mapObject4; this.mPropertiesMapped = true; } public void readProperties(@NonNull AppCompatEditText appCompatEditText, @NonNull PropertyReader propertyReader) { if (!this.mPropertiesMapped) { throw AppCompatAutoCompleteTextView$InspectionCompanion$$ExternalSyntheticApiModelOutline2.m(); } propertyReader.readObject(this.mBackgroundTintId, appCompatEditText.getBackgroundTintList()); propertyReader.readObject(this.mBackgroundTintModeId, appCompatEditText.getBackgroundTintMode()); propertyReader.readObject(this.mDrawableTintId, appCompatEditText.getCompoundDrawableTintList()); propertyReader.readObject(this.mDrawableTintModeId, appCompatEditText.getCompoundDrawableTintMode()); } } public AppCompatEditText(@NonNull Context context) { this(context, null); } public AppCompatEditText(@NonNull Context context, @Nullable AttributeSet attributeSet) { this(context, attributeSet, R.attr.editTextStyle); } public AppCompatEditText(@NonNull Context context, @Nullable 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); } public 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 @Nullable public Editable getText() { if (Build.VERSION.SDK_INT >= 28) { return super.getText(); } return super.getEditableText(); } @Override // android.view.View public void setBackgroundResource(@DrawableRes int i) { super.setBackgroundResource(i); AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper; if (appCompatBackgroundHelper != null) { appCompatBackgroundHelper.onSetBackgroundResource(i); } } @Override // android.view.View public void setBackgroundDrawable(@Nullable Drawable drawable) { super.setBackgroundDrawable(drawable); AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper; if (appCompatBackgroundHelper != null) { appCompatBackgroundHelper.onSetBackgroundDrawable(drawable); } } @Override // androidx.core.view.TintableBackgroundView @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public void setSupportBackgroundTintList(@Nullable ColorStateList colorStateList) { AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper; if (appCompatBackgroundHelper != null) { appCompatBackgroundHelper.setSupportBackgroundTintList(colorStateList); } } @Override // androidx.core.view.TintableBackgroundView @Nullable @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public ColorStateList getSupportBackgroundTintList() { AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper; if (appCompatBackgroundHelper != null) { return appCompatBackgroundHelper.getSupportBackgroundTintList(); } return null; } @Override // androidx.core.view.TintableBackgroundView @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public void setSupportBackgroundTintMode(@Nullable PorterDuff.Mode mode) { AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper; if (appCompatBackgroundHelper != null) { appCompatBackgroundHelper.setSupportBackgroundTintMode(mode); } } @Override // androidx.core.view.TintableBackgroundView @Nullable @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public PorterDuff.Mode getSupportBackgroundTintMode() { AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper; if (appCompatBackgroundHelper != null) { return appCompatBackgroundHelper.getSupportBackgroundTintMode(); } return null; } @Override // android.widget.TextView, android.view.View public 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 @Nullable public InputConnection onCreateInputConnection(@NonNull EditorInfo editorInfo) { String[] onReceiveContentMimeTypes; InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo); this.mTextHelper.populateSurroundingTextIfNeeded(this, onCreateInputConnection, editorInfo); InputConnection onCreateInputConnection2 = AppCompatHintHelper.onCreateInputConnection(onCreateInputConnection, editorInfo, this); if (onCreateInputConnection2 != null && Build.VERSION.SDK_INT <= 30 && (onReceiveContentMimeTypes = ViewCompat.getOnReceiveContentMimeTypes(this)) != null) { EditorInfoCompat.setContentMimeTypes(editorInfo, onReceiveContentMimeTypes); onCreateInputConnection2 = InputConnectionCompat.createWrapper(this, onCreateInputConnection2, editorInfo); } return this.mAppCompatEmojiEditTextHelper.onCreateInputConnection(onCreateInputConnection2, editorInfo); } @Override // android.widget.TextView public void setCustomSelectionActionModeCallback(@Nullable ActionMode.Callback callback) { super.setCustomSelectionActionModeCallback(TextViewCompat.wrapCustomSelectionActionModeCallback(this, callback)); } @Override // android.widget.TextView @Nullable public ActionMode.Callback getCustomSelectionActionModeCallback() { return TextViewCompat.unwrapCustomSelectionActionModeCallback(super.getCustomSelectionActionModeCallback()); } @Override // android.view.View public void onDetachedFromWindow() { super.onDetachedFromWindow(); int i = Build.VERSION.SDK_INT; if (i < 30 || i >= 33) { return; } ((InputMethodManager) getContext().getSystemService("input_method")).isActive(this); } @NonNull @RequiresApi(26) @UiThread private SuperCaller getSuperCaller() { if (this.mSuperCaller == null) { this.mSuperCaller = new SuperCaller(); } return this.mSuperCaller; } @Override // android.widget.TextView @RequiresApi(api = 26) public void setTextClassifier(@Nullable TextClassifier textClassifier) { AppCompatTextClassifierHelper appCompatTextClassifierHelper; if (Build.VERSION.SDK_INT >= 28 || (appCompatTextClassifierHelper = this.mTextClassifierHelper) == null) { getSuperCaller().setTextClassifier(textClassifier); } else { appCompatTextClassifierHelper.setTextClassifier(textClassifier); } } @Override // android.widget.TextView @NonNull @RequiresApi(api = 26) public TextClassifier getTextClassifier() { AppCompatTextClassifierHelper appCompatTextClassifierHelper; if (Build.VERSION.SDK_INT >= 28 || (appCompatTextClassifierHelper = this.mTextClassifierHelper) == null) { return getSuperCaller().getTextClassifier(); } return appCompatTextClassifierHelper.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 @Nullable public ContentInfoCompat onReceiveContent(@NonNull ContentInfoCompat contentInfoCompat) { return this.mDefaultOnReceiveContentListener.onReceiveContent(this, contentInfoCompat); } @Override // android.widget.TextView public void setKeyListener(@Nullable 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(@Nullable Drawable drawable, @Nullable Drawable drawable2, @Nullable Drawable drawable3, @Nullable Drawable drawable4) { super.setCompoundDrawables(drawable, drawable2, drawable3, drawable4); AppCompatTextHelper appCompatTextHelper = this.mTextHelper; if (appCompatTextHelper != null) { appCompatTextHelper.onSetCompoundDrawables(); } } @Override // android.widget.TextView public void setCompoundDrawablesRelative(@Nullable Drawable drawable, @Nullable Drawable drawable2, @Nullable Drawable drawable3, @Nullable Drawable drawable4) { super.setCompoundDrawablesRelative(drawable, drawable2, drawable3, drawable4); AppCompatTextHelper appCompatTextHelper = this.mTextHelper; if (appCompatTextHelper != null) { appCompatTextHelper.onSetCompoundDrawables(); } } @Override // androidx.core.widget.TintableCompoundDrawablesView @Nullable @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public ColorStateList getSupportCompoundDrawablesTintList() { return this.mTextHelper.getCompoundDrawableTintList(); } @Override // androidx.core.widget.TintableCompoundDrawablesView @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public void setSupportCompoundDrawablesTintList(@Nullable ColorStateList colorStateList) { this.mTextHelper.setCompoundDrawableTintList(colorStateList); this.mTextHelper.applyCompoundDrawablesTints(); } @Override // androidx.core.widget.TintableCompoundDrawablesView @Nullable @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public PorterDuff.Mode getSupportCompoundDrawablesTintMode() { return this.mTextHelper.getCompoundDrawableTintMode(); } @Override // androidx.core.widget.TintableCompoundDrawablesView @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public void setSupportCompoundDrawablesTintMode(@Nullable PorterDuff.Mode mode) { this.mTextHelper.setCompoundDrawableTintMode(mode); this.mTextHelper.applyCompoundDrawablesTints(); } @RequiresApi(api = 26) public class SuperCaller { public SuperCaller() { } @Nullable public TextClassifier getTextClassifier() { return AppCompatEditText.super.getTextClassifier(); } public void setTextClassifier(TextClassifier textClassifier) { AppCompatEditText.super.setTextClassifier(textClassifier); } } }