Rabbit-R1/android (non root)/java/sources/com/google/android/material/datepicker/CalendarItemStyle.java
2024-05-21 17:08:36 -04:00

94 lines
5.1 KiB
Java

package com.google.android.material.datepicker;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.RippleDrawable;
import android.widget.TextView;
import androidx.core.util.Preconditions;
import androidx.core.view.ViewCompat;
import com.google.android.material.R;
import com.google.android.material.resources.MaterialResources;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
/* loaded from: classes2.dex */
final class CalendarItemStyle {
private final ColorStateList backgroundColor;
private final Rect insets;
private final ShapeAppearanceModel itemShape;
private final ColorStateList strokeColor;
private final int strokeWidth;
private final ColorStateList textColor;
private CalendarItemStyle(ColorStateList colorStateList, ColorStateList colorStateList2, ColorStateList colorStateList3, int i, ShapeAppearanceModel shapeAppearanceModel, Rect rect) {
Preconditions.checkArgumentNonnegative(rect.left);
Preconditions.checkArgumentNonnegative(rect.top);
Preconditions.checkArgumentNonnegative(rect.right);
Preconditions.checkArgumentNonnegative(rect.bottom);
this.insets = rect;
this.textColor = colorStateList2;
this.backgroundColor = colorStateList;
this.strokeColor = colorStateList3;
this.strokeWidth = i;
this.itemShape = shapeAppearanceModel;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static CalendarItemStyle create(Context context, int i) {
Preconditions.checkArgument(i != 0, "Cannot create a CalendarItemStyle with a styleResId of 0");
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(i, R.styleable.MaterialCalendarItem);
Rect rect = new Rect(obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialCalendarItem_android_insetLeft, 0), obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialCalendarItem_android_insetTop, 0), obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialCalendarItem_android_insetRight, 0), obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialCalendarItem_android_insetBottom, 0));
ColorStateList colorStateList = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.MaterialCalendarItem_itemFillColor);
ColorStateList colorStateList2 = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.MaterialCalendarItem_itemTextColor);
ColorStateList colorStateList3 = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.MaterialCalendarItem_itemStrokeColor);
int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.MaterialCalendarItem_itemStrokeWidth, 0);
ShapeAppearanceModel build = ShapeAppearanceModel.builder(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendarItem_itemShapeAppearance, 0), obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendarItem_itemShapeAppearanceOverlay, 0)).build();
obtainStyledAttributes.recycle();
return new CalendarItemStyle(colorStateList, colorStateList2, colorStateList3, dimensionPixelSize, build, rect);
}
/* JADX INFO: Access modifiers changed from: package-private */
public void styleItem(TextView textView) {
styleItem(textView, null, null);
}
/* JADX INFO: Access modifiers changed from: package-private */
public void styleItem(TextView textView, ColorStateList colorStateList, ColorStateList colorStateList2) {
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable();
MaterialShapeDrawable materialShapeDrawable2 = new MaterialShapeDrawable();
materialShapeDrawable.setShapeAppearanceModel(this.itemShape);
materialShapeDrawable2.setShapeAppearanceModel(this.itemShape);
if (colorStateList == null) {
colorStateList = this.backgroundColor;
}
materialShapeDrawable.setFillColor(colorStateList);
materialShapeDrawable.setStroke(this.strokeWidth, this.strokeColor);
if (colorStateList2 == null) {
colorStateList2 = this.textColor;
}
textView.setTextColor(colorStateList2);
ViewCompat.setBackground(textView, new InsetDrawable((Drawable) new RippleDrawable(this.textColor.withAlpha(30), materialShapeDrawable, materialShapeDrawable2), this.insets.left, this.insets.top, this.insets.right, this.insets.bottom));
}
int getLeftInset() {
return this.insets.left;
}
int getRightInset() {
return this.insets.right;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getTopInset() {
return this.insets.top;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getBottomInset() {
return this.insets.bottom;
}
}