89 lines
3.7 KiB
Java
89 lines
3.7 KiB
Java
package com.google.android.material.internal;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.util.AttributeSet;
|
|
import androidx.appcompat.widget.TintTypedArray;
|
|
import com.google.android.material.R$attr;
|
|
import com.google.android.material.R$styleable;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class ThemeEnforcement {
|
|
private static final int[] a = {R$attr.colorPrimary};
|
|
private static final int[] b = {R$attr.colorSecondary};
|
|
|
|
private static void a(Context context, AttributeSet attributeSet, int i, int i2) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.ThemeEnforcement, i, i2);
|
|
boolean z = obtainStyledAttributes.getBoolean(R$styleable.ThemeEnforcement_enforceMaterialTheme, false);
|
|
obtainStyledAttributes.recycle();
|
|
if (z) {
|
|
b(context);
|
|
}
|
|
a(context);
|
|
}
|
|
|
|
private static boolean b(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, i, i2);
|
|
for (int i3 : iArr2) {
|
|
if (obtainStyledAttributes.getResourceId(i3, -1) == -1) {
|
|
obtainStyledAttributes.recycle();
|
|
return false;
|
|
}
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
return true;
|
|
}
|
|
|
|
public static TypedArray c(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
|
|
a(context, attributeSet, i, i2);
|
|
a(context, attributeSet, iArr, i, i2, iArr2);
|
|
return context.obtainStyledAttributes(attributeSet, iArr, i, i2);
|
|
}
|
|
|
|
public static TintTypedArray d(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
|
|
a(context, attributeSet, i, i2);
|
|
a(context, attributeSet, iArr, i, i2, iArr2);
|
|
return TintTypedArray.a(context, attributeSet, iArr, i, i2);
|
|
}
|
|
|
|
public static void b(Context context) {
|
|
a(context, b, "Theme.MaterialComponents");
|
|
}
|
|
|
|
private static void a(Context context, AttributeSet attributeSet, int[] iArr, int i, int i2, int... iArr2) {
|
|
boolean z;
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.ThemeEnforcement, i, i2);
|
|
if (!obtainStyledAttributes.getBoolean(R$styleable.ThemeEnforcement_enforceTextAppearance, false)) {
|
|
obtainStyledAttributes.recycle();
|
|
return;
|
|
}
|
|
if (iArr2 != null && iArr2.length != 0) {
|
|
z = b(context, attributeSet, iArr, i, i2, iArr2);
|
|
} else {
|
|
z = obtainStyledAttributes.getResourceId(R$styleable.ThemeEnforcement_android_textAppearance, -1) != -1;
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
if (!z) {
|
|
throw new IllegalArgumentException("This component requires that you specify a valid TextAppearance attribute. Update your app theme to inherit from Theme.MaterialComponents (or a descendant).");
|
|
}
|
|
}
|
|
|
|
public static void a(Context context) {
|
|
a(context, a, "Theme.AppCompat");
|
|
}
|
|
|
|
private static boolean a(Context context, int[] iArr) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(iArr);
|
|
boolean hasValue = obtainStyledAttributes.hasValue(0);
|
|
obtainStyledAttributes.recycle();
|
|
return hasValue;
|
|
}
|
|
|
|
private static void a(Context context, int[] iArr, String str) {
|
|
if (a(context, iArr)) {
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("The style on this component requires your app theme to be " + str + " (or a descendant).");
|
|
}
|
|
}
|