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

253 lines
11 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.util.AttributeSet;
import android.view.ActionMode;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.CheckedTextView;
import androidx.appcompat.R;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.view.TintableBackgroundView;
import androidx.core.widget.TextViewCompat;
import androidx.core.widget.TintableCheckedTextView;
import androidx.core.widget.TintableCompoundDrawablesView;
/* loaded from: classes.dex */
public class AppCompatCheckedTextView extends CheckedTextView implements TintableCheckedTextView, TintableBackgroundView, EmojiCompatConfigurationView, TintableCompoundDrawablesView {
private AppCompatEmojiTextHelper mAppCompatEmojiTextHelper;
private final AppCompatBackgroundHelper mBackgroundTintHelper;
private final AppCompatCheckedTextViewHelper mCheckedHelper;
private final AppCompatTextHelper mTextHelper;
public AppCompatCheckedTextView(Context context) {
this(context, null);
}
public AppCompatCheckedTextView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.checkedTextViewStyle);
}
public AppCompatCheckedTextView(Context context, AttributeSet attributeSet, int i) {
super(TintContextWrapper.wrap(context), attributeSet, i);
ThemeUtils.checkAppCompatTheme(this, getContext());
AppCompatTextHelper appCompatTextHelper = new AppCompatTextHelper(this);
this.mTextHelper = appCompatTextHelper;
appCompatTextHelper.loadFromAttributes(attributeSet, i);
appCompatTextHelper.applyCompoundDrawablesTints();
AppCompatBackgroundHelper appCompatBackgroundHelper = new AppCompatBackgroundHelper(this);
this.mBackgroundTintHelper = appCompatBackgroundHelper;
appCompatBackgroundHelper.loadFromAttributes(attributeSet, i);
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = new AppCompatCheckedTextViewHelper(this);
this.mCheckedHelper = appCompatCheckedTextViewHelper;
appCompatCheckedTextViewHelper.loadFromAttributes(attributeSet, i);
getEmojiTextViewHelper().loadFromAttributes(attributeSet, i);
}
@Override // android.widget.CheckedTextView
public void setCheckMarkDrawable(Drawable drawable) {
super.setCheckMarkDrawable(drawable);
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = this.mCheckedHelper;
if (appCompatCheckedTextViewHelper != null) {
appCompatCheckedTextViewHelper.onSetCheckMarkDrawable();
}
}
@Override // android.widget.CheckedTextView
public void setCheckMarkDrawable(int i) {
setCheckMarkDrawable(AppCompatResources.getDrawable(getContext(), i));
}
@Override // androidx.core.widget.TintableCheckedTextView
public void setSupportCheckMarkTintList(ColorStateList colorStateList) {
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = this.mCheckedHelper;
if (appCompatCheckedTextViewHelper != null) {
appCompatCheckedTextViewHelper.setSupportCheckMarkTintList(colorStateList);
}
}
@Override // androidx.core.widget.TintableCheckedTextView
public ColorStateList getSupportCheckMarkTintList() {
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = this.mCheckedHelper;
if (appCompatCheckedTextViewHelper != null) {
return appCompatCheckedTextViewHelper.getSupportCheckMarkTintList();
}
return null;
}
@Override // androidx.core.widget.TintableCheckedTextView
public void setSupportCheckMarkTintMode(PorterDuff.Mode mode) {
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = this.mCheckedHelper;
if (appCompatCheckedTextViewHelper != null) {
appCompatCheckedTextViewHelper.setSupportCheckMarkTintMode(mode);
}
}
@Override // androidx.core.widget.TintableCheckedTextView
public PorterDuff.Mode getSupportCheckMarkTintMode() {
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = this.mCheckedHelper;
if (appCompatCheckedTextViewHelper != null) {
return appCompatCheckedTextViewHelper.getSupportCheckMarkTintMode();
}
return null;
}
@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.view.View
public void setBackgroundDrawable(Drawable drawable) {
super.setBackgroundDrawable(drawable);
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.onSetBackgroundDrawable(drawable);
}
}
@Override // android.view.View
public void setBackgroundResource(int i) {
super.setBackgroundResource(i);
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.onSetBackgroundResource(i);
}
}
@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.CheckedTextView, android.widget.TextView, android.view.View
protected void drawableStateChanged() {
super.drawableStateChanged();
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.applyCompoundDrawablesTints();
}
AppCompatBackgroundHelper appCompatBackgroundHelper = this.mBackgroundTintHelper;
if (appCompatBackgroundHelper != null) {
appCompatBackgroundHelper.applySupportBackgroundTint();
}
AppCompatCheckedTextViewHelper appCompatCheckedTextViewHelper = this.mCheckedHelper;
if (appCompatCheckedTextViewHelper != null) {
appCompatCheckedTextViewHelper.applyCheckMarkTint();
}
}
@Override // android.widget.TextView, android.view.View
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
return AppCompatHintHelper.onCreateInputConnection(super.onCreateInputConnection(editorInfo), editorInfo, this);
}
@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 AppCompatEmojiTextHelper getEmojiTextViewHelper() {
if (this.mAppCompatEmojiTextHelper == null) {
this.mAppCompatEmojiTextHelper = new AppCompatEmojiTextHelper(this);
}
return this.mAppCompatEmojiTextHelper;
}
@Override // android.widget.TextView
public void setAllCaps(boolean z) {
super.setAllCaps(z);
getEmojiTextViewHelper().setAllCaps(z);
}
@Override // androidx.appcompat.widget.EmojiCompatConfigurationView
public void setEmojiCompatEnabled(boolean z) {
getEmojiTextViewHelper().setEnabled(z);
}
@Override // androidx.appcompat.widget.EmojiCompatConfigurationView
public boolean isEmojiCompatEnabled() {
return getEmojiTextViewHelper().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();
}
}