71 lines
3 KiB
Java
71 lines
3 KiB
Java
|
package androidx.appcompat.widget;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.ActionMode;
|
||
|
import android.view.inputmethod.EditorInfo;
|
||
|
import android.view.inputmethod.InputConnection;
|
||
|
import android.widget.CheckedTextView;
|
||
|
import androidx.annotation.DrawableRes;
|
||
|
import androidx.annotation.NonNull;
|
||
|
import androidx.annotation.Nullable;
|
||
|
import androidx.appcompat.content.res.AppCompatResources;
|
||
|
import androidx.core.widget.TextViewCompat;
|
||
|
public class AppCompatCheckedTextView extends CheckedTextView {
|
||
|
private static final int[] TINT_ATTRS = {16843016};
|
||
|
private final AppCompatTextHelper mTextHelper;
|
||
|
|
||
|
public AppCompatCheckedTextView(@NonNull Context context) {
|
||
|
this(context, null);
|
||
|
}
|
||
|
|
||
|
public AppCompatCheckedTextView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
||
|
this(context, attributeSet, 16843720);
|
||
|
}
|
||
|
|
||
|
public AppCompatCheckedTextView(@NonNull Context context, @Nullable 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();
|
||
|
TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(getContext(), attributeSet, TINT_ATTRS, i, 0);
|
||
|
setCheckMarkDrawable(obtainStyledAttributes.getDrawable(0));
|
||
|
obtainStyledAttributes.recycle();
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.CheckedTextView, android.widget.TextView, android.view.View
|
||
|
public void drawableStateChanged() {
|
||
|
super.drawableStateChanged();
|
||
|
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
|
||
|
if (appCompatTextHelper != null) {
|
||
|
appCompatTextHelper.applyCompoundDrawablesTints();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.TextView, android.view.View
|
||
|
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
||
|
return AppCompatHintHelper.onCreateInputConnection(super.onCreateInputConnection(editorInfo), editorInfo, this);
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.CheckedTextView
|
||
|
public void setCheckMarkDrawable(@DrawableRes int i) {
|
||
|
setCheckMarkDrawable(AppCompatResources.getDrawable(getContext(), i));
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.TextView
|
||
|
public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
|
||
|
super.setCustomSelectionActionModeCallback(TextViewCompat.wrapCustomSelectionActionModeCallback(this, callback));
|
||
|
}
|
||
|
|
||
|
@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);
|
||
|
}
|
||
|
}
|
||
|
}
|