Files
rr3-apk/decompiled/sources/androidx/appcompat/widget/AppCompatButton.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

418 lines
18 KiB
Java

package androidx.appcompat.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.InputFilter;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inspector.PropertyMapper;
import android.view.inspector.PropertyReader;
import android.widget.Button;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.appcompat.R;
import androidx.core.view.TintableBackgroundView;
import androidx.core.widget.AutoSizeableTextView;
import androidx.core.widget.TextViewCompat;
import androidx.core.widget.TintableCompoundDrawablesView;
import java.util.function.IntFunction;
/* loaded from: classes.dex */
public class AppCompatButton extends Button implements TintableBackgroundView, AutoSizeableTextView, TintableCompoundDrawablesView, EmojiCompatConfigurationView {
@NonNull
private AppCompatEmojiTextHelper mAppCompatEmojiTextHelper;
private final AppCompatBackgroundHelper mBackgroundTintHelper;
private final AppCompatTextHelper mTextHelper;
@RequiresApi(29)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public final class InspectionCompanion implements android.view.inspector.InspectionCompanion {
private int mAutoSizeMaxTextSizeId;
private int mAutoSizeMinTextSizeId;
private int mAutoSizeStepGranularityId;
private int mAutoSizeTextTypeId;
private int mBackgroundTintId;
private int mBackgroundTintModeId;
private int mDrawableTintId;
private int mDrawableTintModeId;
private boolean mPropertiesMapped = false;
public void mapProperties(@NonNull PropertyMapper propertyMapper) {
int mapInt;
int mapInt2;
int mapInt3;
int mapIntEnum;
int mapObject;
int mapObject2;
int mapObject3;
int mapObject4;
mapInt = propertyMapper.mapInt("autoSizeMaxTextSize", R.attr.autoSizeMaxTextSize);
this.mAutoSizeMaxTextSizeId = mapInt;
mapInt2 = propertyMapper.mapInt("autoSizeMinTextSize", R.attr.autoSizeMinTextSize);
this.mAutoSizeMinTextSizeId = mapInt2;
mapInt3 = propertyMapper.mapInt("autoSizeStepGranularity", R.attr.autoSizeStepGranularity);
this.mAutoSizeStepGranularityId = mapInt3;
mapIntEnum = propertyMapper.mapIntEnum("autoSizeTextType", R.attr.autoSizeTextType, new IntFunction<String>() { // from class: androidx.appcompat.widget.AppCompatButton.InspectionCompanion.1
@Override // java.util.function.IntFunction
public String apply(int i) {
return i != 0 ? i != 1 ? String.valueOf(i) : "uniform" : "none";
}
});
this.mAutoSizeTextTypeId = mapIntEnum;
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 AppCompatButton appCompatButton, @NonNull PropertyReader propertyReader) {
if (!this.mPropertiesMapped) {
throw AppCompatAutoCompleteTextView$InspectionCompanion$$ExternalSyntheticApiModelOutline2.m();
}
propertyReader.readInt(this.mAutoSizeMaxTextSizeId, appCompatButton.getAutoSizeMaxTextSize());
propertyReader.readInt(this.mAutoSizeMinTextSizeId, appCompatButton.getAutoSizeMinTextSize());
propertyReader.readInt(this.mAutoSizeStepGranularityId, appCompatButton.getAutoSizeStepGranularity());
propertyReader.readIntEnum(this.mAutoSizeTextTypeId, appCompatButton.getAutoSizeTextType());
propertyReader.readObject(this.mBackgroundTintId, appCompatButton.getBackgroundTintList());
propertyReader.readObject(this.mBackgroundTintModeId, appCompatButton.getBackgroundTintMode());
propertyReader.readObject(this.mDrawableTintId, appCompatButton.getCompoundDrawableTintList());
propertyReader.readObject(this.mDrawableTintModeId, appCompatButton.getCompoundDrawableTintMode());
}
}
public AppCompatButton(@NonNull Context context) {
this(context, null);
}
public AppCompatButton(@NonNull Context context, @Nullable AttributeSet attributeSet) {
this(context, attributeSet, R.attr.buttonStyle);
}
public AppCompatButton(@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();
getEmojiTextViewHelper().loadFromAttributes(attributeSet, i);
}
@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.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
public void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.onLayout(z, i, i2, i3, i4);
}
}
@Override // android.widget.TextView
public void setTextSize(int i, float f) {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
super.setTextSize(i, f);
return;
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.setTextSize(i, f);
}
}
@Override // android.widget.TextView
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
super.onTextChanged(charSequence, i, i2, i3);
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper == null || ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE || !appCompatTextHelper.isAutoSizeEnabled()) {
return;
}
this.mTextHelper.autoSizeText();
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void setAutoSizeTextTypeWithDefaults(int i) {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
super.setAutoSizeTextTypeWithDefaults(i);
return;
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.setAutoSizeTextTypeWithDefaults(i);
}
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void setAutoSizeTextTypeUniformWithConfiguration(int i, int i2, int i3, int i4) throws IllegalArgumentException {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
super.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4);
return;
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4);
}
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void setAutoSizeTextTypeUniformWithPresetSizes(@NonNull int[] iArr, int i) throws IllegalArgumentException {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i);
return;
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i);
}
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@SuppressLint({"WrongConstant"})
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public int getAutoSizeTextType() {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
return super.getAutoSizeTextType() == 1 ? 1 : 0;
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
return appCompatTextHelper.getAutoSizeTextType();
}
return 0;
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public int getAutoSizeStepGranularity() {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
return super.getAutoSizeStepGranularity();
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
return appCompatTextHelper.getAutoSizeStepGranularity();
}
return -1;
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public int getAutoSizeMinTextSize() {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
return super.getAutoSizeMinTextSize();
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
return appCompatTextHelper.getAutoSizeMinTextSize();
}
return -1;
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public int getAutoSizeMaxTextSize() {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
return super.getAutoSizeMaxTextSize();
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
return appCompatTextHelper.getAutoSizeMaxTextSize();
}
return -1;
}
@Override // android.widget.TextView, androidx.core.widget.AutoSizeableTextView
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public int[] getAutoSizeTextAvailableSizes() {
if (ViewUtils.SDK_LEVEL_SUPPORTS_AUTOSIZE) {
return super.getAutoSizeTextAvailableSizes();
}
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
return appCompatTextHelper != null ? appCompatTextHelper.getAutoSizeTextAvailableSizes() : new int[0];
}
public void setSupportAllCaps(boolean z) {
AppCompatTextHelper appCompatTextHelper = this.mTextHelper;
if (appCompatTextHelper != null) {
appCompatTextHelper.setAllCaps(z);
}
}
@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 // 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 ColorStateList getSupportCompoundDrawablesTintList() {
return this.mTextHelper.getCompoundDrawableTintList();
}
@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();
}
@Override // androidx.core.widget.TintableCompoundDrawablesView
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public PorterDuff.Mode getSupportCompoundDrawablesTintMode() {
return this.mTextHelper.getCompoundDrawableTintMode();
}
@Override // android.widget.TextView
public void setFilters(@NonNull InputFilter[] inputFilterArr) {
super.setFilters(getEmojiTextViewHelper().getFilters(inputFilterArr));
}
@NonNull
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();
}
}