Initial commit
This commit is contained in:
260
sources/androidx/appcompat/widget/AppCompatButton.java
Normal file
260
sources/androidx/appcompat/widget/AppCompatButton.java
Normal file
@@ -0,0 +1,260 @@
|
||||
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.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.Button;
|
||||
import androidx.appcompat.R$attr;
|
||||
import androidx.core.view.TintableBackgroundView;
|
||||
import androidx.core.widget.AutoSizeableTextView;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AppCompatButton extends Button implements TintableBackgroundView, AutoSizeableTextView {
|
||||
private final AppCompatBackgroundHelper a;
|
||||
private final AppCompatTextHelper b;
|
||||
|
||||
public AppCompatButton(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
@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 // 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.view.View
|
||||
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||||
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||||
accessibilityEvent.setClassName(Button.class.getName());
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||||
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||||
accessibilityNodeInfo.setClassName(Button.class.getName());
|
||||
}
|
||||
|
||||
@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
|
||||
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));
|
||||
}
|
||||
|
||||
public void setSupportAllCaps(boolean z) {
|
||||
AppCompatTextHelper appCompatTextHelper = this.b;
|
||||
if (appCompatTextHelper != null) {
|
||||
appCompatTextHelper.a(z);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@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 AppCompatButton(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, R$attr.buttonStyle);
|
||||
}
|
||||
|
||||
public AppCompatButton(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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user