327 lines
11 KiB
Java
327 lines
11 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.R;
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Build;
|
|
import android.util.AttributeSet;
|
|
import android.view.ActionMode;
|
|
import android.view.inputmethod.EditorInfo;
|
|
import android.view.inputmethod.InputConnection;
|
|
import android.widget.TextView;
|
|
import androidx.core.text.PrecomputedTextCompat;
|
|
import androidx.core.view.TintableBackgroundView;
|
|
import androidx.core.widget.AutoSizeableTextView;
|
|
import androidx.core.widget.TextViewCompat;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.Future;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class AppCompatTextView extends TextView implements TintableBackgroundView, AutoSizeableTextView {
|
|
private final AppCompatBackgroundHelper a;
|
|
private final AppCompatTextHelper b;
|
|
private Future<PrecomputedTextCompat> c;
|
|
|
|
public AppCompatTextView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void d() {
|
|
Future<PrecomputedTextCompat> future = this.c;
|
|
if (future != null) {
|
|
try {
|
|
this.c = null;
|
|
TextViewCompat.a(this, future.get());
|
|
} catch (InterruptedException | ExecutionException unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView, android.view.View
|
|
protected void drawableStateChanged() {
|
|
super.drawableStateChanged();
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.a();
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a();
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int getAutoSizeMaxTextSize() {
|
|
if (AutoSizeableTextView.w) {
|
|
return super.getAutoSizeMaxTextSize();
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
return appCompatTextHelper.c();
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int getAutoSizeMinTextSize() {
|
|
if (AutoSizeableTextView.w) {
|
|
return super.getAutoSizeMinTextSize();
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
return appCompatTextHelper.d();
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int getAutoSizeStepGranularity() {
|
|
if (AutoSizeableTextView.w) {
|
|
return super.getAutoSizeStepGranularity();
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
return appCompatTextHelper.e();
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int[] getAutoSizeTextAvailableSizes() {
|
|
if (AutoSizeableTextView.w) {
|
|
return super.getAutoSizeTextAvailableSizes();
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
return appCompatTextHelper != null ? appCompatTextHelper.f() : new int[0];
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int getAutoSizeTextType() {
|
|
if (AutoSizeableTextView.w) {
|
|
return super.getAutoSizeTextType() == 1 ? 1 : 0;
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
return appCompatTextHelper.g();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int getFirstBaselineToTopHeight() {
|
|
return TextViewCompat.b(this);
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public int getLastBaselineToBottomHeight() {
|
|
return TextViewCompat.c(this);
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
public ColorStateList getSupportBackgroundTintList() {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
return appCompatBackgroundHelper.b();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
public PorterDuff.Mode getSupportBackgroundTintMode() {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
return appCompatBackgroundHelper.c();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public CharSequence getText() {
|
|
d();
|
|
return super.getText();
|
|
}
|
|
|
|
public PrecomputedTextCompat.Params getTextMetricsParamsCompat() {
|
|
return TextViewCompat.f(this);
|
|
}
|
|
|
|
@Override // android.widget.TextView, android.view.View
|
|
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
|
InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo);
|
|
AppCompatHintHelper.a(onCreateInputConnection, editorInfo, this);
|
|
return onCreateInputConnection;
|
|
}
|
|
|
|
@Override // android.widget.TextView, android.view.View
|
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
|
super.onLayout(z, i, i2, i3, i4);
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a(z, i, i2, i3, i4);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
d();
|
|
super.onMeasure(i, i2);
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
protected void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
super.onTextChanged(charSequence, i, i2, i3);
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper == null || AutoSizeableTextView.w || !appCompatTextHelper.h()) {
|
|
return;
|
|
}
|
|
this.b.b();
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setAutoSizeTextTypeUniformWithConfiguration(int i, int i2, int i3, int i4) throws IllegalArgumentException {
|
|
if (AutoSizeableTextView.w) {
|
|
super.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4);
|
|
return;
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a(i, i2, i3, i4);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setAutoSizeTextTypeUniformWithPresetSizes(int[] iArr, int i) throws IllegalArgumentException {
|
|
if (AutoSizeableTextView.w) {
|
|
super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i);
|
|
return;
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a(iArr, i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setAutoSizeTextTypeWithDefaults(int i) {
|
|
if (AutoSizeableTextView.w) {
|
|
super.setAutoSizeTextTypeWithDefaults(i);
|
|
return;
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setBackgroundDrawable(Drawable drawable) {
|
|
super.setBackgroundDrawable(drawable);
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.a(drawable);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setBackgroundResource(int i) {
|
|
super.setBackgroundResource(i);
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.a(i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setCustomSelectionActionModeCallback(ActionMode.Callback callback) {
|
|
super.setCustomSelectionActionModeCallback(TextViewCompat.a(this, callback));
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setFirstBaselineToTopHeight(int i) {
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
super.setFirstBaselineToTopHeight(i);
|
|
} else {
|
|
TextViewCompat.a(this, i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setLastBaselineToBottomHeight(int i) {
|
|
if (Build.VERSION.SDK_INT >= 28) {
|
|
super.setLastBaselineToBottomHeight(i);
|
|
} else {
|
|
TextViewCompat.b(this, i);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setLineHeight(int i) {
|
|
TextViewCompat.c(this, i);
|
|
}
|
|
|
|
public void setPrecomputedText(PrecomputedTextCompat precomputedTextCompat) {
|
|
TextViewCompat.a(this, precomputedTextCompat);
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
public void setSupportBackgroundTintList(ColorStateList colorStateList) {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.b(colorStateList);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.TintableBackgroundView
|
|
public void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
|
|
AppCompatBackgroundHelper appCompatBackgroundHelper = this.a;
|
|
if (appCompatBackgroundHelper != null) {
|
|
appCompatBackgroundHelper.a(mode);
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setTextAppearance(Context context, int i) {
|
|
super.setTextAppearance(context, i);
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a(context, i);
|
|
}
|
|
}
|
|
|
|
public void setTextFuture(Future<PrecomputedTextCompat> future) {
|
|
this.c = future;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setTextMetricsParamsCompat(PrecomputedTextCompat.Params params) {
|
|
TextViewCompat.a(this, params);
|
|
}
|
|
|
|
@Override // android.widget.TextView
|
|
public void setTextSize(int i, float f) {
|
|
if (AutoSizeableTextView.w) {
|
|
super.setTextSize(i, f);
|
|
return;
|
|
}
|
|
AppCompatTextHelper appCompatTextHelper = this.b;
|
|
if (appCompatTextHelper != null) {
|
|
appCompatTextHelper.a(i, f);
|
|
}
|
|
}
|
|
|
|
public AppCompatTextView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, R.attr.textViewStyle);
|
|
}
|
|
|
|
public AppCompatTextView(Context context, AttributeSet attributeSet, int i) {
|
|
super(TintContextWrapper.b(context), attributeSet, i);
|
|
this.a = new AppCompatBackgroundHelper(this);
|
|
this.a.a(attributeSet, i);
|
|
this.b = new AppCompatTextHelper(this);
|
|
this.b.a(attributeSet, i);
|
|
this.b.a();
|
|
}
|
|
}
|