ADD week 5
This commit is contained in:
		| @@ -0,0 +1,213 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Bundle; | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import androidx.core.util.ObjectsCompat; | ||||
| import java.util.Arrays; | ||||
| import java.util.Objects; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class CalendarConstraints implements Parcelable { | ||||
|     public static final Parcelable.Creator<CalendarConstraints> CREATOR = new Parcelable.Creator<CalendarConstraints>() { // from class: com.google.android.material.datepicker.CalendarConstraints.1 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public CalendarConstraints createFromParcel(Parcel parcel) { | ||||
|             return new CalendarConstraints((Month) parcel.readParcelable(Month.class.getClassLoader()), (Month) parcel.readParcelable(Month.class.getClassLoader()), (DateValidator) parcel.readParcelable(DateValidator.class.getClassLoader()), (Month) parcel.readParcelable(Month.class.getClassLoader()), parcel.readInt()); | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public CalendarConstraints[] newArray(int i) { | ||||
|             return new CalendarConstraints[i]; | ||||
|         } | ||||
|     }; | ||||
|     private final Month end; | ||||
|     private final int firstDayOfWeek; | ||||
|     private final int monthSpan; | ||||
|     private Month openAt; | ||||
|     private final Month start; | ||||
|     private final DateValidator validator; | ||||
|     private final int yearSpan; | ||||
|  | ||||
|     public interface DateValidator extends Parcelable { | ||||
|         boolean isValid(long j); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     public DateValidator getDateValidator() { | ||||
|         return this.validator; | ||||
|     } | ||||
|  | ||||
|     Month getEnd() { | ||||
|         return this.end; | ||||
|     } | ||||
|  | ||||
|     int getFirstDayOfWeek() { | ||||
|         return this.firstDayOfWeek; | ||||
|     } | ||||
|  | ||||
|     int getMonthSpan() { | ||||
|         return this.monthSpan; | ||||
|     } | ||||
|  | ||||
|     Month getOpenAt() { | ||||
|         return this.openAt; | ||||
|     } | ||||
|  | ||||
|     Month getStart() { | ||||
|         return this.start; | ||||
|     } | ||||
|  | ||||
|     int getYearSpan() { | ||||
|         return this.yearSpan; | ||||
|     } | ||||
|  | ||||
|     void setOpenAt(Month month) { | ||||
|         this.openAt = month; | ||||
|     } | ||||
|  | ||||
|     private CalendarConstraints(Month month, Month month2, DateValidator dateValidator, Month month3, int i) { | ||||
|         Objects.requireNonNull(month, "start cannot be null"); | ||||
|         Objects.requireNonNull(month2, "end cannot be null"); | ||||
|         Objects.requireNonNull(dateValidator, "validator cannot be null"); | ||||
|         this.start = month; | ||||
|         this.end = month2; | ||||
|         this.openAt = month3; | ||||
|         this.firstDayOfWeek = i; | ||||
|         this.validator = dateValidator; | ||||
|         if (month3 != null && month.compareTo(month3) > 0) { | ||||
|             throw new IllegalArgumentException("start Month cannot be after current Month"); | ||||
|         } | ||||
|         if (month3 != null && month3.compareTo(month2) > 0) { | ||||
|             throw new IllegalArgumentException("current Month cannot be after end Month"); | ||||
|         } | ||||
|         if (i < 0 || i > UtcDates.getUtcCalendar().getMaximum(7)) { | ||||
|             throw new IllegalArgumentException("firstDayOfWeek is not valid"); | ||||
|         } | ||||
|         this.monthSpan = month.monthsUntil(month2) + 1; | ||||
|         this.yearSpan = (month2.year - month.year) + 1; | ||||
|     } | ||||
|  | ||||
|     boolean isWithinBounds(long j) { | ||||
|         if (this.start.getDay(1) <= j) { | ||||
|             Month month = this.end; | ||||
|             if (j <= month.getDay(month.daysInMonth)) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public long getStartMs() { | ||||
|         return this.start.timeInMillis; | ||||
|     } | ||||
|  | ||||
|     public long getEndMs() { | ||||
|         return this.end.timeInMillis; | ||||
|     } | ||||
|  | ||||
|     public Long getOpenAtMs() { | ||||
|         Month month = this.openAt; | ||||
|         if (month == null) { | ||||
|             return null; | ||||
|         } | ||||
|         return Long.valueOf(month.timeInMillis); | ||||
|     } | ||||
|  | ||||
|     public boolean equals(Object obj) { | ||||
|         if (this == obj) { | ||||
|             return true; | ||||
|         } | ||||
|         if (!(obj instanceof CalendarConstraints)) { | ||||
|             return false; | ||||
|         } | ||||
|         CalendarConstraints calendarConstraints = (CalendarConstraints) obj; | ||||
|         return this.start.equals(calendarConstraints.start) && this.end.equals(calendarConstraints.end) && ObjectsCompat.equals(this.openAt, calendarConstraints.openAt) && this.firstDayOfWeek == calendarConstraints.firstDayOfWeek && this.validator.equals(calendarConstraints.validator); | ||||
|     } | ||||
|  | ||||
|     public int hashCode() { | ||||
|         return Arrays.hashCode(new Object[]{this.start, this.end, this.openAt, Integer.valueOf(this.firstDayOfWeek), this.validator}); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeParcelable(this.start, 0); | ||||
|         parcel.writeParcelable(this.end, 0); | ||||
|         parcel.writeParcelable(this.openAt, 0); | ||||
|         parcel.writeParcelable(this.validator, 0); | ||||
|         parcel.writeInt(this.firstDayOfWeek); | ||||
|     } | ||||
|  | ||||
|     Month clamp(Month month) { | ||||
|         return month.compareTo(this.start) < 0 ? this.start : month.compareTo(this.end) > 0 ? this.end : month; | ||||
|     } | ||||
|  | ||||
|     public static final class Builder { | ||||
|         private static final String DEEP_COPY_VALIDATOR_KEY = "DEEP_COPY_VALIDATOR_KEY"; | ||||
|         private long end; | ||||
|         private int firstDayOfWeek; | ||||
|         private Long openAt; | ||||
|         private long start; | ||||
|         private DateValidator validator; | ||||
|         static final long DEFAULT_START = UtcDates.canonicalYearMonthDay(Month.create(1900, 0).timeInMillis); | ||||
|         static final long DEFAULT_END = UtcDates.canonicalYearMonthDay(Month.create(2100, 11).timeInMillis); | ||||
|  | ||||
|         public Builder setEnd(long j) { | ||||
|             this.end = j; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder setFirstDayOfWeek(int i) { | ||||
|             this.firstDayOfWeek = i; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder setStart(long j) { | ||||
|             this.start = j; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder() { | ||||
|             this.start = DEFAULT_START; | ||||
|             this.end = DEFAULT_END; | ||||
|             this.validator = DateValidatorPointForward.from(Long.MIN_VALUE); | ||||
|         } | ||||
|  | ||||
|         Builder(CalendarConstraints calendarConstraints) { | ||||
|             this.start = DEFAULT_START; | ||||
|             this.end = DEFAULT_END; | ||||
|             this.validator = DateValidatorPointForward.from(Long.MIN_VALUE); | ||||
|             this.start = calendarConstraints.start.timeInMillis; | ||||
|             this.end = calendarConstraints.end.timeInMillis; | ||||
|             this.openAt = Long.valueOf(calendarConstraints.openAt.timeInMillis); | ||||
|             this.firstDayOfWeek = calendarConstraints.firstDayOfWeek; | ||||
|             this.validator = calendarConstraints.validator; | ||||
|         } | ||||
|  | ||||
|         public Builder setOpenAt(long j) { | ||||
|             this.openAt = Long.valueOf(j); | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder setValidator(DateValidator dateValidator) { | ||||
|             Objects.requireNonNull(dateValidator, "validator cannot be null"); | ||||
|             this.validator = dateValidator; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public CalendarConstraints build() { | ||||
|             Bundle bundle = new Bundle(); | ||||
|             bundle.putParcelable(DEEP_COPY_VALIDATOR_KEY, this.validator); | ||||
|             Month create = Month.create(this.start); | ||||
|             Month create2 = Month.create(this.end); | ||||
|             DateValidator dateValidator = (DateValidator) bundle.getParcelable(DEEP_COPY_VALIDATOR_KEY); | ||||
|             Long l = this.openAt; | ||||
|             return new CalendarConstraints(create, create2, dateValidator, l == null ? null : Month.create(l.longValue()), this.firstDayOfWeek); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,89 @@ | ||||
| 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: classes.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; | ||||
|     } | ||||
|  | ||||
|     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); | ||||
|     } | ||||
|  | ||||
|     void styleItem(TextView textView) { | ||||
|         styleItem(textView, null, null); | ||||
|     } | ||||
|  | ||||
|     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; | ||||
|     } | ||||
|  | ||||
|     int getTopInset() { | ||||
|         return this.insets.top; | ||||
|     } | ||||
|  | ||||
|     int getBottomInset() { | ||||
|         return this.insets.bottom; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.content.res.TypedArray; | ||||
| import android.graphics.Paint; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.resources.MaterialAttributes; | ||||
| import com.google.android.material.resources.MaterialResources; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| final class CalendarStyle { | ||||
|     final CalendarItemStyle day; | ||||
|     final CalendarItemStyle invalidDay; | ||||
|     final Paint rangeFill; | ||||
|     final CalendarItemStyle selectedDay; | ||||
|     final CalendarItemStyle selectedYear; | ||||
|     final CalendarItemStyle todayDay; | ||||
|     final CalendarItemStyle todayYear; | ||||
|     final CalendarItemStyle year; | ||||
|  | ||||
|     CalendarStyle(Context context) { | ||||
|         TypedArray obtainStyledAttributes = context.obtainStyledAttributes(MaterialAttributes.resolveOrThrow(context, R.attr.materialCalendarStyle, MaterialCalendar.class.getCanonicalName()), R.styleable.MaterialCalendar); | ||||
|         this.day = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_dayStyle, 0)); | ||||
|         this.invalidDay = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_dayInvalidStyle, 0)); | ||||
|         this.selectedDay = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_daySelectedStyle, 0)); | ||||
|         this.todayDay = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_dayTodayStyle, 0)); | ||||
|         ColorStateList colorStateList = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.MaterialCalendar_rangeFillColor); | ||||
|         this.year = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_yearStyle, 0)); | ||||
|         this.selectedYear = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_yearSelectedStyle, 0)); | ||||
|         this.todayYear = CalendarItemStyle.create(context, obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendar_yearTodayStyle, 0)); | ||||
|         Paint paint = new Paint(); | ||||
|         this.rangeFill = paint; | ||||
|         paint.setColor(colorStateList.getDefaultColor()); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,121 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import androidx.core.util.Preconditions; | ||||
| import com.google.android.material.datepicker.CalendarConstraints; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class CompositeDateValidator implements CalendarConstraints.DateValidator { | ||||
|     private static final int COMPARATOR_ALL_ID = 2; | ||||
|     private static final int COMPARATOR_ANY_ID = 1; | ||||
|     private final Operator operator; | ||||
|     private final List<CalendarConstraints.DateValidator> validators; | ||||
|     private static final Operator ANY_OPERATOR = new Operator() { // from class: com.google.android.material.datepicker.CompositeDateValidator.1 | ||||
|         @Override // com.google.android.material.datepicker.CompositeDateValidator.Operator | ||||
|         public int getId() { | ||||
|             return 1; | ||||
|         } | ||||
|  | ||||
|         @Override // com.google.android.material.datepicker.CompositeDateValidator.Operator | ||||
|         public boolean isValid(List<CalendarConstraints.DateValidator> list, long j) { | ||||
|             for (CalendarConstraints.DateValidator dateValidator : list) { | ||||
|                 if (dateValidator != null && dateValidator.isValid(j)) { | ||||
|                     return true; | ||||
|                 } | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
|     }; | ||||
|     private static final Operator ALL_OPERATOR = new Operator() { // from class: com.google.android.material.datepicker.CompositeDateValidator.2 | ||||
|         @Override // com.google.android.material.datepicker.CompositeDateValidator.Operator | ||||
|         public int getId() { | ||||
|             return 2; | ||||
|         } | ||||
|  | ||||
|         @Override // com.google.android.material.datepicker.CompositeDateValidator.Operator | ||||
|         public boolean isValid(List<CalendarConstraints.DateValidator> list, long j) { | ||||
|             for (CalendarConstraints.DateValidator dateValidator : list) { | ||||
|                 if (dateValidator != null && !dateValidator.isValid(j)) { | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|     }; | ||||
|     public static final Parcelable.Creator<CompositeDateValidator> CREATOR = new Parcelable.Creator<CompositeDateValidator>() { // from class: com.google.android.material.datepicker.CompositeDateValidator.3 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public CompositeDateValidator createFromParcel(Parcel parcel) { | ||||
|             Operator operator; | ||||
|             ArrayList readArrayList = parcel.readArrayList(CalendarConstraints.DateValidator.class.getClassLoader()); | ||||
|             int readInt = parcel.readInt(); | ||||
|             if (readInt == 2) { | ||||
|                 operator = CompositeDateValidator.ALL_OPERATOR; | ||||
|             } else if (readInt == 1) { | ||||
|                 operator = CompositeDateValidator.ANY_OPERATOR; | ||||
|             } else { | ||||
|                 operator = CompositeDateValidator.ALL_OPERATOR; | ||||
|             } | ||||
|             return new CompositeDateValidator((List) Preconditions.checkNotNull(readArrayList), operator); | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public CompositeDateValidator[] newArray(int i) { | ||||
|             return new CompositeDateValidator[i]; | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     private interface Operator { | ||||
|         int getId(); | ||||
|  | ||||
|         boolean isValid(List<CalendarConstraints.DateValidator> list, long j); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     private CompositeDateValidator(List<CalendarConstraints.DateValidator> list, Operator operator) { | ||||
|         this.validators = list; | ||||
|         this.operator = operator; | ||||
|     } | ||||
|  | ||||
|     public static CalendarConstraints.DateValidator allOf(List<CalendarConstraints.DateValidator> list) { | ||||
|         return new CompositeDateValidator(list, ALL_OPERATOR); | ||||
|     } | ||||
|  | ||||
|     public static CalendarConstraints.DateValidator anyOf(List<CalendarConstraints.DateValidator> list) { | ||||
|         return new CompositeDateValidator(list, ANY_OPERATOR); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.CalendarConstraints.DateValidator | ||||
|     public boolean isValid(long j) { | ||||
|         return this.operator.isValid(this.validators, j); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeList(this.validators); | ||||
|         parcel.writeInt(this.operator.getId()); | ||||
|     } | ||||
|  | ||||
|     public boolean equals(Object obj) { | ||||
|         if (this == obj) { | ||||
|             return true; | ||||
|         } | ||||
|         if (!(obj instanceof CompositeDateValidator)) { | ||||
|             return false; | ||||
|         } | ||||
|         CompositeDateValidator compositeDateValidator = (CompositeDateValidator) obj; | ||||
|         return this.validators.equals(compositeDateValidator.validators) && this.operator.getId() == compositeDateValidator.operator.getId(); | ||||
|     } | ||||
|  | ||||
|     public int hashCode() { | ||||
|         return this.validators.hashCode(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,118 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.text.Editable; | ||||
| import android.text.TextUtils; | ||||
| import android.view.View; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.internal.TextWatcherAdapter; | ||||
| import com.google.android.material.textfield.TextInputLayout; | ||||
| import java.text.DateFormat; | ||||
| import java.text.ParseException; | ||||
| import java.util.Date; | ||||
| import java.util.Locale; | ||||
| import kotlin.text.Typography; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| abstract class DateFormatTextWatcher extends TextWatcherAdapter { | ||||
|     private final CalendarConstraints constraints; | ||||
|     private final DateFormat dateFormat; | ||||
|     private final String formatHint; | ||||
|     private int lastLength = 0; | ||||
|     private final String outOfRange; | ||||
|     private final Runnable setErrorCallback; | ||||
|     private Runnable setRangeErrorCallback; | ||||
|     private final TextInputLayout textInputLayout; | ||||
|  | ||||
|     void onInvalidDate() { | ||||
|     } | ||||
|  | ||||
|     abstract void onValidDate(Long l); | ||||
|  | ||||
|     DateFormatTextWatcher(final String str, DateFormat dateFormat, TextInputLayout textInputLayout, CalendarConstraints calendarConstraints) { | ||||
|         this.formatHint = str; | ||||
|         this.dateFormat = dateFormat; | ||||
|         this.textInputLayout = textInputLayout; | ||||
|         this.constraints = calendarConstraints; | ||||
|         this.outOfRange = textInputLayout.getContext().getString(R.string.mtrl_picker_out_of_range); | ||||
|         this.setErrorCallback = new Runnable() { // from class: com.google.android.material.datepicker.DateFormatTextWatcher$$ExternalSyntheticLambda0 | ||||
|             @Override // java.lang.Runnable | ||||
|             public final void run() { | ||||
|                 DateFormatTextWatcher.this.m241x5657fb8e(str); | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     /* renamed from: lambda$new$0$com-google-android-material-datepicker-DateFormatTextWatcher, reason: not valid java name */ | ||||
|     /* synthetic */ void m241x5657fb8e(String str) { | ||||
|         TextInputLayout textInputLayout = this.textInputLayout; | ||||
|         DateFormat dateFormat = this.dateFormat; | ||||
|         Context context = textInputLayout.getContext(); | ||||
|         textInputLayout.setError(context.getString(R.string.mtrl_picker_invalid_format) + "\n" + String.format(context.getString(R.string.mtrl_picker_invalid_format_use), sanitizeDateString(str)) + "\n" + String.format(context.getString(R.string.mtrl_picker_invalid_format_example), sanitizeDateString(dateFormat.format(new Date(UtcDates.getTodayCalendar().getTimeInMillis()))))); | ||||
|         onInvalidDate(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher | ||||
|     public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { | ||||
|         this.textInputLayout.removeCallbacks(this.setErrorCallback); | ||||
|         this.textInputLayout.removeCallbacks(this.setRangeErrorCallback); | ||||
|         this.textInputLayout.setError(null); | ||||
|         onValidDate(null); | ||||
|         if (TextUtils.isEmpty(charSequence) || charSequence.length() < this.formatHint.length()) { | ||||
|             return; | ||||
|         } | ||||
|         try { | ||||
|             Date parse = this.dateFormat.parse(charSequence.toString()); | ||||
|             this.textInputLayout.setError(null); | ||||
|             long time = parse.getTime(); | ||||
|             if (this.constraints.getDateValidator().isValid(time) && this.constraints.isWithinBounds(time)) { | ||||
|                 onValidDate(Long.valueOf(parse.getTime())); | ||||
|                 return; | ||||
|             } | ||||
|             Runnable createRangeErrorCallback = createRangeErrorCallback(time); | ||||
|             this.setRangeErrorCallback = createRangeErrorCallback; | ||||
|             runValidation(this.textInputLayout, createRangeErrorCallback); | ||||
|         } catch (ParseException unused) { | ||||
|             runValidation(this.textInputLayout, this.setErrorCallback); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher | ||||
|     public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { | ||||
|         this.lastLength = charSequence.length(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher | ||||
|     public void afterTextChanged(Editable editable) { | ||||
|         if (!Locale.getDefault().getLanguage().equals(Locale.KOREAN.getLanguage()) && editable.length() != 0 && editable.length() < this.formatHint.length() && editable.length() >= this.lastLength) { | ||||
|             char charAt = this.formatHint.charAt(editable.length()); | ||||
|             if (Character.isDigit(charAt)) { | ||||
|                 return; | ||||
|             } | ||||
|             editable.append(charAt); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private Runnable createRangeErrorCallback(final long j) { | ||||
|         return new Runnable() { // from class: com.google.android.material.datepicker.DateFormatTextWatcher$$ExternalSyntheticLambda1 | ||||
|             @Override // java.lang.Runnable | ||||
|             public final void run() { | ||||
|                 DateFormatTextWatcher.this.m240x14d77527(j); | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     /* renamed from: lambda$createRangeErrorCallback$1$com-google-android-material-datepicker-DateFormatTextWatcher, reason: not valid java name */ | ||||
|     /* synthetic */ void m240x14d77527(long j) { | ||||
|         this.textInputLayout.setError(String.format(this.outOfRange, sanitizeDateString(DateStrings.getDateString(j)))); | ||||
|         onInvalidDate(); | ||||
|     } | ||||
|  | ||||
|     private String sanitizeDateString(String str) { | ||||
|         return str.replace(' ', Typography.nbsp); | ||||
|     } | ||||
|  | ||||
|     public void runValidation(View view, Runnable runnable) { | ||||
|         view.post(runnable); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,77 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.os.Bundle; | ||||
| import android.os.Parcelable; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.EditText; | ||||
| import androidx.core.util.Pair; | ||||
| import com.google.android.material.datepicker.DateSelector; | ||||
| import com.google.android.material.internal.ViewUtils; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Collection; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public interface DateSelector<S> extends Parcelable { | ||||
|     int getDefaultThemeResId(Context context); | ||||
|  | ||||
|     int getDefaultTitleResId(); | ||||
|  | ||||
|     String getError(); | ||||
|  | ||||
|     Collection<Long> getSelectedDays(); | ||||
|  | ||||
|     Collection<Pair<Long, Long>> getSelectedRanges(); | ||||
|  | ||||
|     S getSelection(); | ||||
|  | ||||
|     String getSelectionContentDescription(Context context); | ||||
|  | ||||
|     String getSelectionDisplayString(Context context); | ||||
|  | ||||
|     boolean isSelectionComplete(); | ||||
|  | ||||
|     View onCreateTextInputView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle, CalendarConstraints calendarConstraints, OnSelectionChangedListener<S> onSelectionChangedListener); | ||||
|  | ||||
|     void select(long j); | ||||
|  | ||||
|     void setSelection(S s); | ||||
|  | ||||
|     void setTextInputFormat(SimpleDateFormat simpleDateFormat); | ||||
|  | ||||
|     /* renamed from: com.google.android.material.datepicker.DateSelector$-CC, reason: invalid class name */ | ||||
|     public final /* synthetic */ class CC { | ||||
|         public static void showKeyboardWithAutoHideBehavior(final EditText... editTextArr) { | ||||
|             if (editTextArr.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
|             View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() { // from class: com.google.android.material.datepicker.DateSelector$$ExternalSyntheticLambda0 | ||||
|                 @Override // android.view.View.OnFocusChangeListener | ||||
|                 public final void onFocusChange(View view, boolean z) { | ||||
|                     DateSelector.CC.lambda$showKeyboardWithAutoHideBehavior$0(editTextArr, view, z); | ||||
|                 } | ||||
|             }; | ||||
|             for (EditText editText : editTextArr) { | ||||
|                 editText.setOnFocusChangeListener(onFocusChangeListener); | ||||
|             } | ||||
|             final EditText editText2 = editTextArr[0]; | ||||
|             editText2.postDelayed(new Runnable() { // from class: com.google.android.material.datepicker.DateSelector$$ExternalSyntheticLambda1 | ||||
|                 @Override // java.lang.Runnable | ||||
|                 public final void run() { | ||||
|                     ViewUtils.requestFocusAndShowKeyboard(editText2, false); | ||||
|                 } | ||||
|             }, 100L); | ||||
|         } | ||||
|  | ||||
|         public static /* synthetic */ void lambda$showKeyboardWithAutoHideBehavior$0(EditText[] editTextArr, View view, boolean z) { | ||||
|             for (EditText editText : editTextArr) { | ||||
|                 if (editText.hasFocus()) { | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|             ViewUtils.hideKeyboard(view, false); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,155 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.os.Build; | ||||
| import android.text.format.DateUtils; | ||||
| import androidx.core.util.Pair; | ||||
| import com.google.android.material.R; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Calendar; | ||||
| import java.util.Date; | ||||
| import java.util.Locale; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class DateStrings { | ||||
|     private DateStrings() { | ||||
|     } | ||||
|  | ||||
|     static String getYearMonth(long j) { | ||||
|         String format; | ||||
|         if (Build.VERSION.SDK_INT >= 24) { | ||||
|             format = UtcDates.getYearMonthFormat(Locale.getDefault()).format(new Date(j)); | ||||
|             return format; | ||||
|         } | ||||
|         return DateUtils.formatDateTime(null, j, 8228); | ||||
|     } | ||||
|  | ||||
|     static String getYearMonthDay(long j) { | ||||
|         return getYearMonthDay(j, Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static String getYearMonthDay(long j, Locale locale) { | ||||
|         String format; | ||||
|         if (Build.VERSION.SDK_INT >= 24) { | ||||
|             format = UtcDates.getYearAbbrMonthDayFormat(locale).format(new Date(j)); | ||||
|             return format; | ||||
|         } | ||||
|         return UtcDates.getMediumFormat(locale).format(new Date(j)); | ||||
|     } | ||||
|  | ||||
|     static String getMonthDay(long j) { | ||||
|         return getMonthDay(j, Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static String getMonthDay(long j, Locale locale) { | ||||
|         String format; | ||||
|         if (Build.VERSION.SDK_INT >= 24) { | ||||
|             format = UtcDates.getAbbrMonthDayFormat(locale).format(new Date(j)); | ||||
|             return format; | ||||
|         } | ||||
|         return UtcDates.getMediumNoYear(locale).format(new Date(j)); | ||||
|     } | ||||
|  | ||||
|     static String getMonthDayOfWeekDay(long j) { | ||||
|         return getMonthDayOfWeekDay(j, Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static String getMonthDayOfWeekDay(long j, Locale locale) { | ||||
|         String format; | ||||
|         if (Build.VERSION.SDK_INT >= 24) { | ||||
|             format = UtcDates.getMonthWeekdayDayFormat(locale).format(new Date(j)); | ||||
|             return format; | ||||
|         } | ||||
|         return UtcDates.getFullFormat(locale).format(new Date(j)); | ||||
|     } | ||||
|  | ||||
|     static String getYearMonthDayOfWeekDay(long j) { | ||||
|         return getYearMonthDayOfWeekDay(j, Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static String getYearMonthDayOfWeekDay(long j, Locale locale) { | ||||
|         String format; | ||||
|         if (Build.VERSION.SDK_INT >= 24) { | ||||
|             format = UtcDates.getYearMonthWeekdayDayFormat(locale).format(new Date(j)); | ||||
|             return format; | ||||
|         } | ||||
|         return UtcDates.getFullFormat(locale).format(new Date(j)); | ||||
|     } | ||||
|  | ||||
|     static String getOptionalYearMonthDayOfWeekDay(long j) { | ||||
|         if (isDateWithinCurrentYear(j)) { | ||||
|             return getMonthDayOfWeekDay(j); | ||||
|         } | ||||
|         return getYearMonthDayOfWeekDay(j); | ||||
|     } | ||||
|  | ||||
|     static String getDateString(long j) { | ||||
|         return getDateString(j, null); | ||||
|     } | ||||
|  | ||||
|     static String getDateString(long j, SimpleDateFormat simpleDateFormat) { | ||||
|         if (simpleDateFormat != null) { | ||||
|             return simpleDateFormat.format(new Date(j)); | ||||
|         } | ||||
|         if (isDateWithinCurrentYear(j)) { | ||||
|             return getMonthDay(j); | ||||
|         } | ||||
|         return getYearMonthDay(j); | ||||
|     } | ||||
|  | ||||
|     private static boolean isDateWithinCurrentYear(long j) { | ||||
|         Calendar todayCalendar = UtcDates.getTodayCalendar(); | ||||
|         Calendar utcCalendar = UtcDates.getUtcCalendar(); | ||||
|         utcCalendar.setTimeInMillis(j); | ||||
|         return todayCalendar.get(1) == utcCalendar.get(1); | ||||
|     } | ||||
|  | ||||
|     static Pair<String, String> getDateRangeString(Long l, Long l2) { | ||||
|         return getDateRangeString(l, l2, null); | ||||
|     } | ||||
|  | ||||
|     static Pair<String, String> getDateRangeString(Long l, Long l2, SimpleDateFormat simpleDateFormat) { | ||||
|         if (l == null && l2 == null) { | ||||
|             return Pair.create(null, null); | ||||
|         } | ||||
|         if (l == null) { | ||||
|             return Pair.create(null, getDateString(l2.longValue(), simpleDateFormat)); | ||||
|         } | ||||
|         if (l2 == null) { | ||||
|             return Pair.create(getDateString(l.longValue(), simpleDateFormat), null); | ||||
|         } | ||||
|         Calendar todayCalendar = UtcDates.getTodayCalendar(); | ||||
|         Calendar utcCalendar = UtcDates.getUtcCalendar(); | ||||
|         utcCalendar.setTimeInMillis(l.longValue()); | ||||
|         Calendar utcCalendar2 = UtcDates.getUtcCalendar(); | ||||
|         utcCalendar2.setTimeInMillis(l2.longValue()); | ||||
|         if (simpleDateFormat != null) { | ||||
|             return Pair.create(simpleDateFormat.format(new Date(l.longValue())), simpleDateFormat.format(new Date(l2.longValue()))); | ||||
|         } | ||||
|         if (utcCalendar.get(1) == utcCalendar2.get(1)) { | ||||
|             if (utcCalendar.get(1) == todayCalendar.get(1)) { | ||||
|                 return Pair.create(getMonthDay(l.longValue(), Locale.getDefault()), getMonthDay(l2.longValue(), Locale.getDefault())); | ||||
|             } | ||||
|             return Pair.create(getMonthDay(l.longValue(), Locale.getDefault()), getYearMonthDay(l2.longValue(), Locale.getDefault())); | ||||
|         } | ||||
|         return Pair.create(getYearMonthDay(l.longValue(), Locale.getDefault()), getYearMonthDay(l2.longValue(), Locale.getDefault())); | ||||
|     } | ||||
|  | ||||
|     static String getDayContentDescription(Context context, long j, boolean z, boolean z2, boolean z3) { | ||||
|         String optionalYearMonthDayOfWeekDay = getOptionalYearMonthDayOfWeekDay(j); | ||||
|         if (z) { | ||||
|             optionalYearMonthDayOfWeekDay = String.format(context.getString(R.string.mtrl_picker_today_description), optionalYearMonthDayOfWeekDay); | ||||
|         } | ||||
|         if (z2) { | ||||
|             return String.format(context.getString(R.string.mtrl_picker_start_date_description), optionalYearMonthDayOfWeekDay); | ||||
|         } | ||||
|         return z3 ? String.format(context.getString(R.string.mtrl_picker_end_date_description), optionalYearMonthDayOfWeekDay) : optionalYearMonthDayOfWeekDay; | ||||
|     } | ||||
|  | ||||
|     static String getYearContentDescription(Context context, int i) { | ||||
|         if (UtcDates.getTodayCalendar().get(1) == i) { | ||||
|             return String.format(context.getString(R.string.mtrl_picker_navigate_to_current_year_description), Integer.valueOf(i)); | ||||
|         } | ||||
|         return String.format(context.getString(R.string.mtrl_picker_navigate_to_year_description), Integer.valueOf(i)); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,62 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import com.google.android.material.datepicker.CalendarConstraints; | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class DateValidatorPointBackward implements CalendarConstraints.DateValidator { | ||||
|     public static final Parcelable.Creator<DateValidatorPointBackward> CREATOR = new Parcelable.Creator<DateValidatorPointBackward>() { // from class: com.google.android.material.datepicker.DateValidatorPointBackward.1 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public DateValidatorPointBackward createFromParcel(Parcel parcel) { | ||||
|             return new DateValidatorPointBackward(parcel.readLong()); | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public DateValidatorPointBackward[] newArray(int i) { | ||||
|             return new DateValidatorPointBackward[i]; | ||||
|         } | ||||
|     }; | ||||
|     private final long point; | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.CalendarConstraints.DateValidator | ||||
|     public boolean isValid(long j) { | ||||
|         return j <= this.point; | ||||
|     } | ||||
|  | ||||
|     private DateValidatorPointBackward(long j) { | ||||
|         this.point = j; | ||||
|     } | ||||
|  | ||||
|     public static DateValidatorPointBackward before(long j) { | ||||
|         return new DateValidatorPointBackward(j); | ||||
|     } | ||||
|  | ||||
|     public static DateValidatorPointBackward now() { | ||||
|         return before(UtcDates.getTodayCalendar().getTimeInMillis()); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeLong(this.point); | ||||
|     } | ||||
|  | ||||
|     public boolean equals(Object obj) { | ||||
|         if (this == obj) { | ||||
|             return true; | ||||
|         } | ||||
|         return (obj instanceof DateValidatorPointBackward) && this.point == ((DateValidatorPointBackward) obj).point; | ||||
|     } | ||||
|  | ||||
|     public int hashCode() { | ||||
|         return Arrays.hashCode(new Object[]{Long.valueOf(this.point)}); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,62 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import com.google.android.material.datepicker.CalendarConstraints; | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class DateValidatorPointForward implements CalendarConstraints.DateValidator { | ||||
|     public static final Parcelable.Creator<DateValidatorPointForward> CREATOR = new Parcelable.Creator<DateValidatorPointForward>() { // from class: com.google.android.material.datepicker.DateValidatorPointForward.1 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public DateValidatorPointForward createFromParcel(Parcel parcel) { | ||||
|             return new DateValidatorPointForward(parcel.readLong()); | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public DateValidatorPointForward[] newArray(int i) { | ||||
|             return new DateValidatorPointForward[i]; | ||||
|         } | ||||
|     }; | ||||
|     private final long point; | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.CalendarConstraints.DateValidator | ||||
|     public boolean isValid(long j) { | ||||
|         return j >= this.point; | ||||
|     } | ||||
|  | ||||
|     private DateValidatorPointForward(long j) { | ||||
|         this.point = j; | ||||
|     } | ||||
|  | ||||
|     public static DateValidatorPointForward from(long j) { | ||||
|         return new DateValidatorPointForward(j); | ||||
|     } | ||||
|  | ||||
|     public static DateValidatorPointForward now() { | ||||
|         return from(UtcDates.getTodayCalendar().getTimeInMillis()); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeLong(this.point); | ||||
|     } | ||||
|  | ||||
|     public boolean equals(Object obj) { | ||||
|         if (this == obj) { | ||||
|             return true; | ||||
|         } | ||||
|         return (obj instanceof DateValidatorPointForward) && this.point == ((DateValidatorPointForward) obj).point; | ||||
|     } | ||||
|  | ||||
|     public int hashCode() { | ||||
|         return Arrays.hashCode(new Object[]{Long.valueOf(this.point)}); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,40 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Parcelable; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public abstract class DayViewDecorator implements Parcelable { | ||||
|     public ColorStateList getBackgroundColor(Context context, int i, int i2, int i3, boolean z, boolean z2) { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public Drawable getCompoundDrawableBottom(Context context, int i, int i2, int i3, boolean z, boolean z2) { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public Drawable getCompoundDrawableLeft(Context context, int i, int i2, int i3, boolean z, boolean z2) { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public Drawable getCompoundDrawableRight(Context context, int i, int i2, int i3, boolean z, boolean z2) { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public Drawable getCompoundDrawableTop(Context context, int i, int i2, int i3, boolean z, boolean z2) { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public CharSequence getContentDescription(Context context, int i, int i2, int i3, boolean z, boolean z2, CharSequence charSequence) { | ||||
|         return charSequence; | ||||
|     } | ||||
|  | ||||
|     public ColorStateList getTextColor(Context context, int i, int i2, int i3, boolean z, boolean z2) { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     public void initialize(Context context) { | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,74 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Build; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.BaseAdapter; | ||||
| import android.widget.TextView; | ||||
| import com.google.android.material.R; | ||||
| import java.util.Calendar; | ||||
| import java.util.Locale; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class DaysOfWeekAdapter extends BaseAdapter { | ||||
|     private static final int CALENDAR_DAY_STYLE; | ||||
|     private static final int NARROW_FORMAT = 4; | ||||
|     private final Calendar calendar; | ||||
|     private final int daysInWeek; | ||||
|     private final int firstDayOfWeek; | ||||
|  | ||||
|     static { | ||||
|         CALENDAR_DAY_STYLE = Build.VERSION.SDK_INT >= 26 ? 4 : 1; | ||||
|     } | ||||
|  | ||||
|     private int positionToDayOfWeek(int i) { | ||||
|         int i2 = i + this.firstDayOfWeek; | ||||
|         int i3 = this.daysInWeek; | ||||
|         return i2 > i3 ? i2 - i3 : i2; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public int getCount() { | ||||
|         return this.daysInWeek; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public long getItemId(int i) { | ||||
|         return 0L; | ||||
|     } | ||||
|  | ||||
|     public DaysOfWeekAdapter() { | ||||
|         Calendar utcCalendar = UtcDates.getUtcCalendar(); | ||||
|         this.calendar = utcCalendar; | ||||
|         this.daysInWeek = utcCalendar.getMaximum(7); | ||||
|         this.firstDayOfWeek = utcCalendar.getFirstDayOfWeek(); | ||||
|     } | ||||
|  | ||||
|     public DaysOfWeekAdapter(int i) { | ||||
|         Calendar utcCalendar = UtcDates.getUtcCalendar(); | ||||
|         this.calendar = utcCalendar; | ||||
|         this.daysInWeek = utcCalendar.getMaximum(7); | ||||
|         this.firstDayOfWeek = i; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public Integer getItem(int i) { | ||||
|         if (i >= this.daysInWeek) { | ||||
|             return null; | ||||
|         } | ||||
|         return Integer.valueOf(positionToDayOfWeek(i)); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public View getView(int i, View view, ViewGroup viewGroup) { | ||||
|         TextView textView = (TextView) view; | ||||
|         if (view == null) { | ||||
|             textView = (TextView) LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mtrl_calendar_day_of_week, viewGroup, false); | ||||
|         } | ||||
|         this.calendar.set(7, positionToDayOfWeek(i)); | ||||
|         textView.setText(this.calendar.getDisplayName(7, CALENDAR_DAY_STYLE, textView.getResources().getConfiguration().locale)); | ||||
|         textView.setContentDescription(String.format(viewGroup.getContext().getString(R.string.mtrl_picker_day_of_week_column_header), this.calendar.getDisplayName(7, 2, Locale.getDefault()))); | ||||
|         return textView; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,395 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.Resources; | ||||
| import android.graphics.Canvas; | ||||
| import android.os.Bundle; | ||||
| import android.view.ContextThemeWrapper; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.GridView; | ||||
| import android.widget.ListAdapter; | ||||
| import androidx.core.util.Pair; | ||||
| import androidx.core.view.AccessibilityDelegateCompat; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; | ||||
| import androidx.recyclerview.widget.GridLayoutManager; | ||||
| import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.PagerSnapHelper; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.button.MaterialButton; | ||||
| import java.util.Calendar; | ||||
| import java.util.Iterator; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class MaterialCalendar<S> extends PickerFragment<S> { | ||||
|     private static final String CALENDAR_CONSTRAINTS_KEY = "CALENDAR_CONSTRAINTS_KEY"; | ||||
|     private static final String CURRENT_MONTH_KEY = "CURRENT_MONTH_KEY"; | ||||
|     private static final String DAY_VIEW_DECORATOR_KEY = "DAY_VIEW_DECORATOR_KEY"; | ||||
|     private static final String GRID_SELECTOR_KEY = "GRID_SELECTOR_KEY"; | ||||
|     private static final int SMOOTH_SCROLL_MAX = 3; | ||||
|     private static final String THEME_RES_ID_KEY = "THEME_RES_ID_KEY"; | ||||
|     private CalendarConstraints calendarConstraints; | ||||
|     private CalendarSelector calendarSelector; | ||||
|     private CalendarStyle calendarStyle; | ||||
|     private Month current; | ||||
|     private DateSelector<S> dateSelector; | ||||
|     private View dayFrame; | ||||
|     private DayViewDecorator dayViewDecorator; | ||||
|     private View monthNext; | ||||
|     private View monthPrev; | ||||
|     private RecyclerView recyclerView; | ||||
|     private int themeResId; | ||||
|     private View yearFrame; | ||||
|     private RecyclerView yearSelector; | ||||
|     static final Object MONTHS_VIEW_GROUP_TAG = "MONTHS_VIEW_GROUP_TAG"; | ||||
|     static final Object NAVIGATION_PREV_TAG = "NAVIGATION_PREV_TAG"; | ||||
|     static final Object NAVIGATION_NEXT_TAG = "NAVIGATION_NEXT_TAG"; | ||||
|     static final Object SELECTOR_TOGGLE_TAG = "SELECTOR_TOGGLE_TAG"; | ||||
|  | ||||
|     enum CalendarSelector { | ||||
|         DAY, | ||||
|         YEAR | ||||
|     } | ||||
|  | ||||
|     interface OnDayClickListener { | ||||
|         void onDayClick(long j); | ||||
|     } | ||||
|  | ||||
|     CalendarConstraints getCalendarConstraints() { | ||||
|         return this.calendarConstraints; | ||||
|     } | ||||
|  | ||||
|     CalendarStyle getCalendarStyle() { | ||||
|         return this.calendarStyle; | ||||
|     } | ||||
|  | ||||
|     Month getCurrentMonth() { | ||||
|         return this.current; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.PickerFragment | ||||
|     public DateSelector<S> getDateSelector() { | ||||
|         return this.dateSelector; | ||||
|     } | ||||
|  | ||||
|     public static <T> MaterialCalendar<T> newInstance(DateSelector<T> dateSelector, int i, CalendarConstraints calendarConstraints) { | ||||
|         return newInstance(dateSelector, i, calendarConstraints, null); | ||||
|     } | ||||
|  | ||||
|     public static <T> MaterialCalendar<T> newInstance(DateSelector<T> dateSelector, int i, CalendarConstraints calendarConstraints, DayViewDecorator dayViewDecorator) { | ||||
|         MaterialCalendar<T> materialCalendar = new MaterialCalendar<>(); | ||||
|         Bundle bundle = new Bundle(); | ||||
|         bundle.putInt(THEME_RES_ID_KEY, i); | ||||
|         bundle.putParcelable(GRID_SELECTOR_KEY, dateSelector); | ||||
|         bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, calendarConstraints); | ||||
|         bundle.putParcelable(DAY_VIEW_DECORATOR_KEY, dayViewDecorator); | ||||
|         bundle.putParcelable(CURRENT_MONTH_KEY, calendarConstraints.getOpenAt()); | ||||
|         materialCalendar.setArguments(bundle); | ||||
|         return materialCalendar; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public void onSaveInstanceState(Bundle bundle) { | ||||
|         super.onSaveInstanceState(bundle); | ||||
|         bundle.putInt(THEME_RES_ID_KEY, this.themeResId); | ||||
|         bundle.putParcelable(GRID_SELECTOR_KEY, this.dateSelector); | ||||
|         bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, this.calendarConstraints); | ||||
|         bundle.putParcelable(DAY_VIEW_DECORATOR_KEY, this.dayViewDecorator); | ||||
|         bundle.putParcelable(CURRENT_MONTH_KEY, this.current); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public void onCreate(Bundle bundle) { | ||||
|         super.onCreate(bundle); | ||||
|         if (bundle == null) { | ||||
|             bundle = getArguments(); | ||||
|         } | ||||
|         this.themeResId = bundle.getInt(THEME_RES_ID_KEY); | ||||
|         this.dateSelector = (DateSelector) bundle.getParcelable(GRID_SELECTOR_KEY); | ||||
|         this.calendarConstraints = (CalendarConstraints) bundle.getParcelable(CALENDAR_CONSTRAINTS_KEY); | ||||
|         this.dayViewDecorator = (DayViewDecorator) bundle.getParcelable(DAY_VIEW_DECORATOR_KEY); | ||||
|         this.current = (Month) bundle.getParcelable(CURRENT_MONTH_KEY); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { | ||||
|         int i; | ||||
|         final int i2; | ||||
|         ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getContext(), this.themeResId); | ||||
|         this.calendarStyle = new CalendarStyle(contextThemeWrapper); | ||||
|         LayoutInflater cloneInContext = layoutInflater.cloneInContext(contextThemeWrapper); | ||||
|         Month start = this.calendarConstraints.getStart(); | ||||
|         if (MaterialDatePicker.isFullscreen(contextThemeWrapper)) { | ||||
|             i = R.layout.mtrl_calendar_vertical; | ||||
|             i2 = 1; | ||||
|         } else { | ||||
|             i = R.layout.mtrl_calendar_horizontal; | ||||
|             i2 = 0; | ||||
|         } | ||||
|         View inflate = cloneInContext.inflate(i, viewGroup, false); | ||||
|         inflate.setMinimumHeight(getDialogPickerHeight(requireContext())); | ||||
|         GridView gridView = (GridView) inflate.findViewById(R.id.mtrl_calendar_days_of_week); | ||||
|         ViewCompat.setAccessibilityDelegate(gridView, new AccessibilityDelegateCompat() { // from class: com.google.android.material.datepicker.MaterialCalendar.1 | ||||
|             @Override // androidx.core.view.AccessibilityDelegateCompat | ||||
|             public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { | ||||
|                 super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); | ||||
|                 accessibilityNodeInfoCompat.setCollectionInfo(null); | ||||
|             } | ||||
|         }); | ||||
|         int firstDayOfWeek = this.calendarConstraints.getFirstDayOfWeek(); | ||||
|         gridView.setAdapter((ListAdapter) (firstDayOfWeek > 0 ? new DaysOfWeekAdapter(firstDayOfWeek) : new DaysOfWeekAdapter())); | ||||
|         gridView.setNumColumns(start.daysInWeek); | ||||
|         gridView.setEnabled(false); | ||||
|         this.recyclerView = (RecyclerView) inflate.findViewById(R.id.mtrl_calendar_months); | ||||
|         this.recyclerView.setLayoutManager(new SmoothCalendarLayoutManager(getContext(), i2, false) { // from class: com.google.android.material.datepicker.MaterialCalendar.2 | ||||
|             @Override // androidx.recyclerview.widget.LinearLayoutManager | ||||
|             protected void calculateExtraLayoutSpace(RecyclerView.State state, int[] iArr) { | ||||
|                 if (i2 == 0) { | ||||
|                     iArr[0] = MaterialCalendar.this.recyclerView.getWidth(); | ||||
|                     iArr[1] = MaterialCalendar.this.recyclerView.getWidth(); | ||||
|                 } else { | ||||
|                     iArr[0] = MaterialCalendar.this.recyclerView.getHeight(); | ||||
|                     iArr[1] = MaterialCalendar.this.recyclerView.getHeight(); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|         this.recyclerView.setTag(MONTHS_VIEW_GROUP_TAG); | ||||
|         MonthsPagerAdapter monthsPagerAdapter = new MonthsPagerAdapter(contextThemeWrapper, this.dateSelector, this.calendarConstraints, this.dayViewDecorator, new OnDayClickListener() { // from class: com.google.android.material.datepicker.MaterialCalendar.3 | ||||
|             /* JADX WARN: Multi-variable type inference failed */ | ||||
|             @Override // com.google.android.material.datepicker.MaterialCalendar.OnDayClickListener | ||||
|             public void onDayClick(long j) { | ||||
|                 if (MaterialCalendar.this.calendarConstraints.getDateValidator().isValid(j)) { | ||||
|                     MaterialCalendar.this.dateSelector.select(j); | ||||
|                     Iterator<OnSelectionChangedListener<S>> it = MaterialCalendar.this.onSelectionChangedListeners.iterator(); | ||||
|                     while (it.hasNext()) { | ||||
|                         it.next().onSelectionChanged(MaterialCalendar.this.dateSelector.getSelection()); | ||||
|                     } | ||||
|                     MaterialCalendar.this.recyclerView.getAdapter().notifyDataSetChanged(); | ||||
|                     if (MaterialCalendar.this.yearSelector != null) { | ||||
|                         MaterialCalendar.this.yearSelector.getAdapter().notifyDataSetChanged(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|         this.recyclerView.setAdapter(monthsPagerAdapter); | ||||
|         int integer = contextThemeWrapper.getResources().getInteger(R.integer.mtrl_calendar_year_selector_span); | ||||
|         RecyclerView recyclerView = (RecyclerView) inflate.findViewById(R.id.mtrl_calendar_year_selector_frame); | ||||
|         this.yearSelector = recyclerView; | ||||
|         if (recyclerView != null) { | ||||
|             recyclerView.setHasFixedSize(true); | ||||
|             this.yearSelector.setLayoutManager(new GridLayoutManager((Context) contextThemeWrapper, integer, 1, false)); | ||||
|             this.yearSelector.setAdapter(new YearGridAdapter(this)); | ||||
|             this.yearSelector.addItemDecoration(createItemDecoration()); | ||||
|         } | ||||
|         if (inflate.findViewById(R.id.month_navigation_fragment_toggle) != null) { | ||||
|             addActionsToMonthNavigation(inflate, monthsPagerAdapter); | ||||
|         } | ||||
|         if (!MaterialDatePicker.isFullscreen(contextThemeWrapper)) { | ||||
|             new PagerSnapHelper().attachToRecyclerView(this.recyclerView); | ||||
|         } | ||||
|         this.recyclerView.scrollToPosition(monthsPagerAdapter.getPosition(this.current)); | ||||
|         setUpForAccessibility(); | ||||
|         return inflate; | ||||
|     } | ||||
|  | ||||
|     private void setUpForAccessibility() { | ||||
|         ViewCompat.setAccessibilityDelegate(this.recyclerView, new AccessibilityDelegateCompat() { // from class: com.google.android.material.datepicker.MaterialCalendar.4 | ||||
|             @Override // androidx.core.view.AccessibilityDelegateCompat | ||||
|             public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { | ||||
|                 super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); | ||||
|                 accessibilityNodeInfoCompat.setScrollable(false); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     private RecyclerView.ItemDecoration createItemDecoration() { | ||||
|         return new RecyclerView.ItemDecoration() { // from class: com.google.android.material.datepicker.MaterialCalendar.5 | ||||
|             private final Calendar startItem = UtcDates.getUtcCalendar(); | ||||
|             private final Calendar endItem = UtcDates.getUtcCalendar(); | ||||
|  | ||||
|             @Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration | ||||
|             public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) { | ||||
|                 int width; | ||||
|                 if ((recyclerView.getAdapter() instanceof YearGridAdapter) && (recyclerView.getLayoutManager() instanceof GridLayoutManager)) { | ||||
|                     YearGridAdapter yearGridAdapter = (YearGridAdapter) recyclerView.getAdapter(); | ||||
|                     GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager(); | ||||
|                     for (Pair<Long, Long> pair : MaterialCalendar.this.dateSelector.getSelectedRanges()) { | ||||
|                         if (pair.first != null && pair.second != null) { | ||||
|                             this.startItem.setTimeInMillis(pair.first.longValue()); | ||||
|                             this.endItem.setTimeInMillis(pair.second.longValue()); | ||||
|                             int positionForYear = yearGridAdapter.getPositionForYear(this.startItem.get(1)); | ||||
|                             int positionForYear2 = yearGridAdapter.getPositionForYear(this.endItem.get(1)); | ||||
|                             View findViewByPosition = gridLayoutManager.findViewByPosition(positionForYear); | ||||
|                             View findViewByPosition2 = gridLayoutManager.findViewByPosition(positionForYear2); | ||||
|                             int spanCount = positionForYear / gridLayoutManager.getSpanCount(); | ||||
|                             int spanCount2 = positionForYear2 / gridLayoutManager.getSpanCount(); | ||||
|                             int i = spanCount; | ||||
|                             while (i <= spanCount2) { | ||||
|                                 View findViewByPosition3 = gridLayoutManager.findViewByPosition(gridLayoutManager.getSpanCount() * i); | ||||
|                                 if (findViewByPosition3 != null) { | ||||
|                                     int top = findViewByPosition3.getTop() + MaterialCalendar.this.calendarStyle.year.getTopInset(); | ||||
|                                     int bottom = findViewByPosition3.getBottom() - MaterialCalendar.this.calendarStyle.year.getBottomInset(); | ||||
|                                     int left = (i != spanCount || findViewByPosition == null) ? 0 : findViewByPosition.getLeft() + (findViewByPosition.getWidth() / 2); | ||||
|                                     if (i == spanCount2 && findViewByPosition2 != null) { | ||||
|                                         width = findViewByPosition2.getLeft() + (findViewByPosition2.getWidth() / 2); | ||||
|                                     } else { | ||||
|                                         width = recyclerView.getWidth(); | ||||
|                                     } | ||||
|                                     canvas.drawRect(left, top, width, bottom, MaterialCalendar.this.calendarStyle.rangeFill); | ||||
|                                 } | ||||
|                                 i++; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     void setCurrentMonth(Month month) { | ||||
|         MonthsPagerAdapter monthsPagerAdapter = (MonthsPagerAdapter) this.recyclerView.getAdapter(); | ||||
|         int position = monthsPagerAdapter.getPosition(month); | ||||
|         int position2 = position - monthsPagerAdapter.getPosition(this.current); | ||||
|         boolean z = Math.abs(position2) > 3; | ||||
|         boolean z2 = position2 > 0; | ||||
|         this.current = month; | ||||
|         if (z && z2) { | ||||
|             this.recyclerView.scrollToPosition(position - 3); | ||||
|             postSmoothRecyclerViewScroll(position); | ||||
|         } else if (z) { | ||||
|             this.recyclerView.scrollToPosition(position + 3); | ||||
|             postSmoothRecyclerViewScroll(position); | ||||
|         } else { | ||||
|             postSmoothRecyclerViewScroll(position); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static int getDayHeight(Context context) { | ||||
|         return context.getResources().getDimensionPixelSize(R.dimen.mtrl_calendar_day_height); | ||||
|     } | ||||
|  | ||||
|     void setSelector(CalendarSelector calendarSelector) { | ||||
|         this.calendarSelector = calendarSelector; | ||||
|         if (calendarSelector == CalendarSelector.YEAR) { | ||||
|             this.yearSelector.getLayoutManager().scrollToPosition(((YearGridAdapter) this.yearSelector.getAdapter()).getPositionForYear(this.current.year)); | ||||
|             this.yearFrame.setVisibility(0); | ||||
|             this.dayFrame.setVisibility(8); | ||||
|             this.monthPrev.setVisibility(8); | ||||
|             this.monthNext.setVisibility(8); | ||||
|             return; | ||||
|         } | ||||
|         if (calendarSelector == CalendarSelector.DAY) { | ||||
|             this.yearFrame.setVisibility(8); | ||||
|             this.dayFrame.setVisibility(0); | ||||
|             this.monthPrev.setVisibility(0); | ||||
|             this.monthNext.setVisibility(0); | ||||
|             setCurrentMonth(this.current); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void toggleVisibleSelector() { | ||||
|         if (this.calendarSelector == CalendarSelector.YEAR) { | ||||
|             setSelector(CalendarSelector.DAY); | ||||
|         } else if (this.calendarSelector == CalendarSelector.DAY) { | ||||
|             setSelector(CalendarSelector.YEAR); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void addActionsToMonthNavigation(View view, final MonthsPagerAdapter monthsPagerAdapter) { | ||||
|         final MaterialButton materialButton = (MaterialButton) view.findViewById(R.id.month_navigation_fragment_toggle); | ||||
|         materialButton.setTag(SELECTOR_TOGGLE_TAG); | ||||
|         ViewCompat.setAccessibilityDelegate(materialButton, new AccessibilityDelegateCompat() { // from class: com.google.android.material.datepicker.MaterialCalendar.6 | ||||
|             @Override // androidx.core.view.AccessibilityDelegateCompat | ||||
|             public void onInitializeAccessibilityNodeInfo(View view2, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { | ||||
|                 String string; | ||||
|                 super.onInitializeAccessibilityNodeInfo(view2, accessibilityNodeInfoCompat); | ||||
|                 if (MaterialCalendar.this.dayFrame.getVisibility() == 0) { | ||||
|                     string = MaterialCalendar.this.getString(R.string.mtrl_picker_toggle_to_year_selection); | ||||
|                 } else { | ||||
|                     string = MaterialCalendar.this.getString(R.string.mtrl_picker_toggle_to_day_selection); | ||||
|                 } | ||||
|                 accessibilityNodeInfoCompat.setHintText(string); | ||||
|             } | ||||
|         }); | ||||
|         View findViewById = view.findViewById(R.id.month_navigation_previous); | ||||
|         this.monthPrev = findViewById; | ||||
|         findViewById.setTag(NAVIGATION_PREV_TAG); | ||||
|         View findViewById2 = view.findViewById(R.id.month_navigation_next); | ||||
|         this.monthNext = findViewById2; | ||||
|         findViewById2.setTag(NAVIGATION_NEXT_TAG); | ||||
|         this.yearFrame = view.findViewById(R.id.mtrl_calendar_year_selector_frame); | ||||
|         this.dayFrame = view.findViewById(R.id.mtrl_calendar_day_selector_frame); | ||||
|         setSelector(CalendarSelector.DAY); | ||||
|         materialButton.setText(this.current.getLongName()); | ||||
|         this.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { // from class: com.google.android.material.datepicker.MaterialCalendar.7 | ||||
|             @Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener | ||||
|             public void onScrolled(RecyclerView recyclerView, int i, int i2) { | ||||
|                 int findLastVisibleItemPosition; | ||||
|                 if (i < 0) { | ||||
|                     findLastVisibleItemPosition = MaterialCalendar.this.getLayoutManager().findFirstVisibleItemPosition(); | ||||
|                 } else { | ||||
|                     findLastVisibleItemPosition = MaterialCalendar.this.getLayoutManager().findLastVisibleItemPosition(); | ||||
|                 } | ||||
|                 MaterialCalendar.this.current = monthsPagerAdapter.getPageMonth(findLastVisibleItemPosition); | ||||
|                 materialButton.setText(monthsPagerAdapter.getPageTitle(findLastVisibleItemPosition)); | ||||
|             } | ||||
|  | ||||
|             @Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener | ||||
|             public void onScrollStateChanged(RecyclerView recyclerView, int i) { | ||||
|                 if (i == 0) { | ||||
|                     recyclerView.announceForAccessibility(materialButton.getText()); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|         materialButton.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.datepicker.MaterialCalendar.8 | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public void onClick(View view2) { | ||||
|                 MaterialCalendar.this.toggleVisibleSelector(); | ||||
|             } | ||||
|         }); | ||||
|         this.monthNext.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.datepicker.MaterialCalendar.9 | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public void onClick(View view2) { | ||||
|                 int findFirstVisibleItemPosition = MaterialCalendar.this.getLayoutManager().findFirstVisibleItemPosition() + 1; | ||||
|                 if (findFirstVisibleItemPosition < MaterialCalendar.this.recyclerView.getAdapter().getItemCount()) { | ||||
|                     MaterialCalendar.this.setCurrentMonth(monthsPagerAdapter.getPageMonth(findFirstVisibleItemPosition)); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|         this.monthPrev.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.datepicker.MaterialCalendar.10 | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public void onClick(View view2) { | ||||
|                 int findLastVisibleItemPosition = MaterialCalendar.this.getLayoutManager().findLastVisibleItemPosition() - 1; | ||||
|                 if (findLastVisibleItemPosition >= 0) { | ||||
|                     MaterialCalendar.this.setCurrentMonth(monthsPagerAdapter.getPageMonth(findLastVisibleItemPosition)); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     private void postSmoothRecyclerViewScroll(final int i) { | ||||
|         this.recyclerView.post(new Runnable() { // from class: com.google.android.material.datepicker.MaterialCalendar.11 | ||||
|             @Override // java.lang.Runnable | ||||
|             public void run() { | ||||
|                 MaterialCalendar.this.recyclerView.smoothScrollToPosition(i); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     private static int getDialogPickerHeight(Context context) { | ||||
|         Resources resources = context.getResources(); | ||||
|         return resources.getDimensionPixelSize(R.dimen.mtrl_calendar_navigation_height) + resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_navigation_top_padding) + resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_navigation_bottom_padding) + resources.getDimensionPixelSize(R.dimen.mtrl_calendar_days_of_week_height) + (MonthAdapter.MAXIMUM_WEEKS * resources.getDimensionPixelSize(R.dimen.mtrl_calendar_day_height)) + ((MonthAdapter.MAXIMUM_WEEKS - 1) * resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_month_vertical_padding)) + resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_bottom_padding); | ||||
|     } | ||||
|  | ||||
|     LinearLayoutManager getLayoutManager() { | ||||
|         return (LinearLayoutManager) this.recyclerView.getLayoutManager(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.PickerFragment | ||||
|     public boolean addOnSelectionChangedListener(OnSelectionChangedListener<S> onSelectionChangedListener) { | ||||
|         return super.addOnSelectionChangedListener(onSelectionChangedListener); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,228 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.graphics.Canvas; | ||||
| import android.graphics.Rect; | ||||
| import android.util.AttributeSet; | ||||
| import android.view.KeyEvent; | ||||
| import android.view.View; | ||||
| import android.widget.GridView; | ||||
| import android.widget.ListAdapter; | ||||
| import androidx.core.util.Pair; | ||||
| import androidx.core.view.AccessibilityDelegateCompat; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.internal.ViewUtils; | ||||
| import java.util.Calendar; | ||||
| import java.util.Iterator; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| final class MaterialCalendarGridView extends GridView { | ||||
|     private final Calendar dayCompute; | ||||
|     private final boolean nestedScrollable; | ||||
|  | ||||
|     public MaterialCalendarGridView(Context context) { | ||||
|         this(context, null); | ||||
|     } | ||||
|  | ||||
|     public MaterialCalendarGridView(Context context, AttributeSet attributeSet) { | ||||
|         this(context, attributeSet, 0); | ||||
|     } | ||||
|  | ||||
|     public MaterialCalendarGridView(Context context, AttributeSet attributeSet, int i) { | ||||
|         super(context, attributeSet, i); | ||||
|         this.dayCompute = UtcDates.getUtcCalendar(); | ||||
|         if (MaterialDatePicker.isFullscreen(getContext())) { | ||||
|             setNextFocusLeftId(R.id.cancel_button); | ||||
|             setNextFocusRightId(R.id.confirm_button); | ||||
|         } | ||||
|         this.nestedScrollable = MaterialDatePicker.isNestedScrollable(getContext()); | ||||
|         ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() { // from class: com.google.android.material.datepicker.MaterialCalendarGridView.1 | ||||
|             @Override // androidx.core.view.AccessibilityDelegateCompat | ||||
|             public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { | ||||
|                 super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat); | ||||
|                 accessibilityNodeInfoCompat.setCollectionInfo(null); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.AbsListView, android.view.ViewGroup, android.view.View | ||||
|     protected void onAttachedToWindow() { | ||||
|         super.onAttachedToWindow(); | ||||
|         getAdapter().notifyDataSetChanged(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.GridView, android.widget.AdapterView | ||||
|     public void setSelection(int i) { | ||||
|         if (i < getAdapter().firstPositionInMonth()) { | ||||
|             super.setSelection(getAdapter().firstPositionInMonth()); | ||||
|         } else { | ||||
|             super.setSelection(i); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.GridView, android.widget.AbsListView, android.view.View, android.view.KeyEvent.Callback | ||||
|     public boolean onKeyDown(int i, KeyEvent keyEvent) { | ||||
|         if (!super.onKeyDown(i, keyEvent)) { | ||||
|             return false; | ||||
|         } | ||||
|         if (getSelectedItemPosition() == -1 || getSelectedItemPosition() >= getAdapter().firstPositionInMonth()) { | ||||
|             return true; | ||||
|         } | ||||
|         if (19 != i) { | ||||
|             return false; | ||||
|         } | ||||
|         setSelection(getAdapter().firstPositionInMonth()); | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.GridView, android.widget.AdapterView | ||||
|     public ListAdapter getAdapter2() { | ||||
|         return (MonthAdapter) super.getAdapter(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.AdapterView | ||||
|     public final void setAdapter(ListAdapter listAdapter) { | ||||
|         if (!(listAdapter instanceof MonthAdapter)) { | ||||
|             throw new IllegalArgumentException(String.format("%1$s must have its Adapter set to a %2$s", MaterialCalendarGridView.class.getCanonicalName(), MonthAdapter.class.getCanonicalName())); | ||||
|         } | ||||
|         super.setAdapter(listAdapter); | ||||
|     } | ||||
|  | ||||
|     @Override // android.view.View | ||||
|     protected final void onDraw(Canvas canvas) { | ||||
|         int dayToPosition; | ||||
|         int horizontalMidPoint; | ||||
|         int dayToPosition2; | ||||
|         int horizontalMidPoint2; | ||||
|         int i; | ||||
|         int i2; | ||||
|         int left; | ||||
|         int left2; | ||||
|         MaterialCalendarGridView materialCalendarGridView = this; | ||||
|         super.onDraw(canvas); | ||||
|         MonthAdapter adapter = getAdapter(); | ||||
|         DateSelector<?> dateSelector = adapter.dateSelector; | ||||
|         CalendarStyle calendarStyle = adapter.calendarStyle; | ||||
|         int max = Math.max(adapter.firstPositionInMonth(), getFirstVisiblePosition()); | ||||
|         int min = Math.min(adapter.lastPositionInMonth(), getLastVisiblePosition()); | ||||
|         Long item = adapter.getItem(max); | ||||
|         Long item2 = adapter.getItem(min); | ||||
|         Iterator<Pair<Long, Long>> it = dateSelector.getSelectedRanges().iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             Pair<Long, Long> next = it.next(); | ||||
|             if (next.first == null) { | ||||
|                 materialCalendarGridView = this; | ||||
|             } else if (next.second != null) { | ||||
|                 long longValue = next.first.longValue(); | ||||
|                 long longValue2 = next.second.longValue(); | ||||
|                 if (!skipMonth(item, item2, Long.valueOf(longValue), Long.valueOf(longValue2))) { | ||||
|                     boolean isLayoutRtl = ViewUtils.isLayoutRtl(this); | ||||
|                     if (longValue < item.longValue()) { | ||||
|                         if (adapter.isFirstInRow(max)) { | ||||
|                             left2 = 0; | ||||
|                         } else if (!isLayoutRtl) { | ||||
|                             left2 = materialCalendarGridView.getChildAtPosition(max - 1).getRight(); | ||||
|                         } else { | ||||
|                             left2 = materialCalendarGridView.getChildAtPosition(max - 1).getLeft(); | ||||
|                         } | ||||
|                         horizontalMidPoint = left2; | ||||
|                         dayToPosition = max; | ||||
|                     } else { | ||||
|                         materialCalendarGridView.dayCompute.setTimeInMillis(longValue); | ||||
|                         dayToPosition = adapter.dayToPosition(materialCalendarGridView.dayCompute.get(5)); | ||||
|                         horizontalMidPoint = horizontalMidPoint(materialCalendarGridView.getChildAtPosition(dayToPosition)); | ||||
|                     } | ||||
|                     if (longValue2 > item2.longValue()) { | ||||
|                         if (adapter.isLastInRow(min)) { | ||||
|                             left = getWidth(); | ||||
|                         } else if (!isLayoutRtl) { | ||||
|                             left = materialCalendarGridView.getChildAtPosition(min).getRight(); | ||||
|                         } else { | ||||
|                             left = materialCalendarGridView.getChildAtPosition(min).getLeft(); | ||||
|                         } | ||||
|                         horizontalMidPoint2 = left; | ||||
|                         dayToPosition2 = min; | ||||
|                     } else { | ||||
|                         materialCalendarGridView.dayCompute.setTimeInMillis(longValue2); | ||||
|                         dayToPosition2 = adapter.dayToPosition(materialCalendarGridView.dayCompute.get(5)); | ||||
|                         horizontalMidPoint2 = horizontalMidPoint(materialCalendarGridView.getChildAtPosition(dayToPosition2)); | ||||
|                     } | ||||
|                     int itemId = (int) adapter.getItemId(dayToPosition); | ||||
|                     int i3 = max; | ||||
|                     int i4 = min; | ||||
|                     int itemId2 = (int) adapter.getItemId(dayToPosition2); | ||||
|                     while (itemId <= itemId2) { | ||||
|                         int numColumns = getNumColumns() * itemId; | ||||
|                         MonthAdapter monthAdapter = adapter; | ||||
|                         int numColumns2 = (numColumns + getNumColumns()) - 1; | ||||
|                         View childAtPosition = materialCalendarGridView.getChildAtPosition(numColumns); | ||||
|                         int top = childAtPosition.getTop() + calendarStyle.day.getTopInset(); | ||||
|                         Iterator<Pair<Long, Long>> it2 = it; | ||||
|                         int bottom = childAtPosition.getBottom() - calendarStyle.day.getBottomInset(); | ||||
|                         if (!isLayoutRtl) { | ||||
|                             i = numColumns > dayToPosition ? 0 : horizontalMidPoint; | ||||
|                             i2 = dayToPosition2 > numColumns2 ? getWidth() : horizontalMidPoint2; | ||||
|                         } else { | ||||
|                             int i5 = dayToPosition2 > numColumns2 ? 0 : horizontalMidPoint2; | ||||
|                             int width = numColumns > dayToPosition ? getWidth() : horizontalMidPoint; | ||||
|                             i = i5; | ||||
|                             i2 = width; | ||||
|                         } | ||||
|                         canvas.drawRect(i, top, i2, bottom, calendarStyle.rangeFill); | ||||
|                         itemId++; | ||||
|                         materialCalendarGridView = this; | ||||
|                         itemId2 = itemId2; | ||||
|                         adapter = monthAdapter; | ||||
|                         it = it2; | ||||
|                     } | ||||
|                     materialCalendarGridView = this; | ||||
|                     max = i3; | ||||
|                     min = i4; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.GridView, android.widget.AbsListView, android.view.View | ||||
|     public void onMeasure(int i, int i2) { | ||||
|         if (this.nestedScrollable) { | ||||
|             super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(ViewCompat.MEASURED_SIZE_MASK, Integer.MIN_VALUE)); | ||||
|             getLayoutParams().height = getMeasuredHeight(); | ||||
|             return; | ||||
|         } | ||||
|         super.onMeasure(i, i2); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.GridView, android.widget.AbsListView, android.view.View | ||||
|     protected void onFocusChanged(boolean z, int i, Rect rect) { | ||||
|         if (z) { | ||||
|             gainFocus(i, rect); | ||||
|         } else { | ||||
|             super.onFocusChanged(false, i, rect); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void gainFocus(int i, Rect rect) { | ||||
|         if (i == 33) { | ||||
|             setSelection(getAdapter().lastPositionInMonth()); | ||||
|         } else if (i == 130) { | ||||
|             setSelection(getAdapter().firstPositionInMonth()); | ||||
|         } else { | ||||
|             super.onFocusChanged(true, i, rect); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private View getChildAtPosition(int i) { | ||||
|         return getChildAt(i - getFirstVisiblePosition()); | ||||
|     } | ||||
|  | ||||
|     private static boolean skipMonth(Long l, Long l2, Long l3, Long l4) { | ||||
|         return l == null || l2 == null || l3 == null || l4 == null || l3.longValue() > l2.longValue() || l4.longValue() < l.longValue(); | ||||
|     } | ||||
|  | ||||
|     private static int horizontalMidPoint(View view) { | ||||
|         return view.getLeft() + (view.getWidth() / 2); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,697 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.app.Dialog; | ||||
| import android.content.Context; | ||||
| import android.content.DialogInterface; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.content.res.Resources; | ||||
| import android.content.res.TypedArray; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.graphics.drawable.InsetDrawable; | ||||
| import android.graphics.drawable.StateListDrawable; | ||||
| import android.os.Bundle; | ||||
| import android.text.TextUtils; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.view.Window; | ||||
| import android.widget.Button; | ||||
| import android.widget.LinearLayout; | ||||
| import android.widget.TextView; | ||||
| import androidx.appcompat.content.res.AppCompatResources; | ||||
| import androidx.core.util.Pair; | ||||
| import androidx.core.view.OnApplyWindowInsetsListener; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import androidx.core.view.WindowInsetsCompat; | ||||
| import androidx.fragment.app.DialogFragment; | ||||
| import androidx.fragment.app.FragmentTransaction; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.datepicker.CalendarConstraints; | ||||
| import com.google.android.material.dialog.InsetDialogOnTouchListener; | ||||
| import com.google.android.material.internal.CheckableImageButton; | ||||
| import com.google.android.material.internal.EdgeToEdgeUtils; | ||||
| import com.google.android.material.internal.ViewUtils; | ||||
| import com.google.android.material.resources.MaterialAttributes; | ||||
| import com.google.android.material.shape.MaterialShapeDrawable; | ||||
| import java.lang.annotation.Retention; | ||||
| import java.lang.annotation.RetentionPolicy; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Iterator; | ||||
| import java.util.LinkedHashSet; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class MaterialDatePicker<S> extends DialogFragment { | ||||
|     private static final String CALENDAR_CONSTRAINTS_KEY = "CALENDAR_CONSTRAINTS_KEY"; | ||||
|     private static final String DATE_SELECTOR_KEY = "DATE_SELECTOR_KEY"; | ||||
|     private static final String DAY_VIEW_DECORATOR_KEY = "DAY_VIEW_DECORATOR_KEY"; | ||||
|     public static final int INPUT_MODE_CALENDAR = 0; | ||||
|     private static final String INPUT_MODE_KEY = "INPUT_MODE_KEY"; | ||||
|     public static final int INPUT_MODE_TEXT = 1; | ||||
|     private static final String NEGATIVE_BUTTON_CONTENT_DESCRIPTION_KEY = "NEGATIVE_BUTTON_CONTENT_DESCRIPTION_KEY"; | ||||
|     private static final String NEGATIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY = "NEGATIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY"; | ||||
|     private static final String NEGATIVE_BUTTON_TEXT_KEY = "NEGATIVE_BUTTON_TEXT_KEY"; | ||||
|     private static final String NEGATIVE_BUTTON_TEXT_RES_ID_KEY = "NEGATIVE_BUTTON_TEXT_RES_ID_KEY"; | ||||
|     private static final String OVERRIDE_THEME_RES_ID = "OVERRIDE_THEME_RES_ID"; | ||||
|     private static final String POSITIVE_BUTTON_CONTENT_DESCRIPTION_KEY = "POSITIVE_BUTTON_CONTENT_DESCRIPTION_KEY"; | ||||
|     private static final String POSITIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY = "POSITIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY"; | ||||
|     private static final String POSITIVE_BUTTON_TEXT_KEY = "POSITIVE_BUTTON_TEXT_KEY"; | ||||
|     private static final String POSITIVE_BUTTON_TEXT_RES_ID_KEY = "POSITIVE_BUTTON_TEXT_RES_ID_KEY"; | ||||
|     private static final String TITLE_TEXT_KEY = "TITLE_TEXT_KEY"; | ||||
|     private static final String TITLE_TEXT_RES_ID_KEY = "TITLE_TEXT_RES_ID_KEY"; | ||||
|     private MaterialShapeDrawable background; | ||||
|     private MaterialCalendar<S> calendar; | ||||
|     private CalendarConstraints calendarConstraints; | ||||
|     private Button confirmButton; | ||||
|     private DateSelector<S> dateSelector; | ||||
|     private DayViewDecorator dayViewDecorator; | ||||
|     private boolean edgeToEdgeEnabled; | ||||
|     private CharSequence fullTitleText; | ||||
|     private boolean fullscreen; | ||||
|     private TextView headerSelectionText; | ||||
|     private TextView headerTitleTextView; | ||||
|     private CheckableImageButton headerToggleButton; | ||||
|     private int inputMode; | ||||
|     private CharSequence negativeButtonContentDescription; | ||||
|     private int negativeButtonContentDescriptionResId; | ||||
|     private CharSequence negativeButtonText; | ||||
|     private int negativeButtonTextResId; | ||||
|     private int overrideThemeResId; | ||||
|     private PickerFragment<S> pickerFragment; | ||||
|     private CharSequence positiveButtonContentDescription; | ||||
|     private int positiveButtonContentDescriptionResId; | ||||
|     private CharSequence positiveButtonText; | ||||
|     private int positiveButtonTextResId; | ||||
|     private CharSequence singleLineTitleText; | ||||
|     private CharSequence titleText; | ||||
|     private int titleTextResId; | ||||
|     static final Object CONFIRM_BUTTON_TAG = "CONFIRM_BUTTON_TAG"; | ||||
|     static final Object CANCEL_BUTTON_TAG = "CANCEL_BUTTON_TAG"; | ||||
|     static final Object TOGGLE_BUTTON_TAG = "TOGGLE_BUTTON_TAG"; | ||||
|     private final LinkedHashSet<MaterialPickerOnPositiveButtonClickListener<? super S>> onPositiveButtonClickListeners = new LinkedHashSet<>(); | ||||
|     private final LinkedHashSet<View.OnClickListener> onNegativeButtonClickListeners = new LinkedHashSet<>(); | ||||
|     private final LinkedHashSet<DialogInterface.OnCancelListener> onCancelListeners = new LinkedHashSet<>(); | ||||
|     private final LinkedHashSet<DialogInterface.OnDismissListener> onDismissListeners = new LinkedHashSet<>(); | ||||
|  | ||||
|     @Retention(RetentionPolicy.SOURCE) | ||||
|     public @interface InputMode { | ||||
|     } | ||||
|  | ||||
|     public int getInputMode() { | ||||
|         return this.inputMode; | ||||
|     } | ||||
|  | ||||
|     public static long todayInUtcMilliseconds() { | ||||
|         return UtcDates.getTodayCalendar().getTimeInMillis(); | ||||
|     } | ||||
|  | ||||
|     public static long thisMonthInUtcMilliseconds() { | ||||
|         return Month.current().timeInMillis; | ||||
|     } | ||||
|  | ||||
|     public String getHeaderText() { | ||||
|         return getDateSelector().getSelectionDisplayString(getContext()); | ||||
|     } | ||||
|  | ||||
|     static <S> MaterialDatePicker<S> newInstance(Builder<S> builder) { | ||||
|         MaterialDatePicker<S> materialDatePicker = new MaterialDatePicker<>(); | ||||
|         Bundle bundle = new Bundle(); | ||||
|         bundle.putInt(OVERRIDE_THEME_RES_ID, builder.overrideThemeResId); | ||||
|         bundle.putParcelable(DATE_SELECTOR_KEY, builder.dateSelector); | ||||
|         bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, builder.calendarConstraints); | ||||
|         bundle.putParcelable(DAY_VIEW_DECORATOR_KEY, builder.dayViewDecorator); | ||||
|         bundle.putInt(TITLE_TEXT_RES_ID_KEY, builder.titleTextResId); | ||||
|         bundle.putCharSequence(TITLE_TEXT_KEY, builder.titleText); | ||||
|         bundle.putInt(INPUT_MODE_KEY, builder.inputMode); | ||||
|         bundle.putInt(POSITIVE_BUTTON_TEXT_RES_ID_KEY, builder.positiveButtonTextResId); | ||||
|         bundle.putCharSequence(POSITIVE_BUTTON_TEXT_KEY, builder.positiveButtonText); | ||||
|         bundle.putInt(POSITIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY, builder.positiveButtonContentDescriptionResId); | ||||
|         bundle.putCharSequence(POSITIVE_BUTTON_CONTENT_DESCRIPTION_KEY, builder.positiveButtonContentDescription); | ||||
|         bundle.putInt(NEGATIVE_BUTTON_TEXT_RES_ID_KEY, builder.negativeButtonTextResId); | ||||
|         bundle.putCharSequence(NEGATIVE_BUTTON_TEXT_KEY, builder.negativeButtonText); | ||||
|         bundle.putInt(NEGATIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY, builder.negativeButtonContentDescriptionResId); | ||||
|         bundle.putCharSequence(NEGATIVE_BUTTON_CONTENT_DESCRIPTION_KEY, builder.negativeButtonContentDescription); | ||||
|         materialDatePicker.setArguments(bundle); | ||||
|         return materialDatePicker; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment | ||||
|     public final void onSaveInstanceState(Bundle bundle) { | ||||
|         super.onSaveInstanceState(bundle); | ||||
|         bundle.putInt(OVERRIDE_THEME_RES_ID, this.overrideThemeResId); | ||||
|         bundle.putParcelable(DATE_SELECTOR_KEY, this.dateSelector); | ||||
|         CalendarConstraints.Builder builder = new CalendarConstraints.Builder(this.calendarConstraints); | ||||
|         MaterialCalendar<S> materialCalendar = this.calendar; | ||||
|         Month currentMonth = materialCalendar == null ? null : materialCalendar.getCurrentMonth(); | ||||
|         if (currentMonth != null) { | ||||
|             builder.setOpenAt(currentMonth.timeInMillis); | ||||
|         } | ||||
|         bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, builder.build()); | ||||
|         bundle.putParcelable(DAY_VIEW_DECORATOR_KEY, this.dayViewDecorator); | ||||
|         bundle.putInt(TITLE_TEXT_RES_ID_KEY, this.titleTextResId); | ||||
|         bundle.putCharSequence(TITLE_TEXT_KEY, this.titleText); | ||||
|         bundle.putInt(INPUT_MODE_KEY, this.inputMode); | ||||
|         bundle.putInt(POSITIVE_BUTTON_TEXT_RES_ID_KEY, this.positiveButtonTextResId); | ||||
|         bundle.putCharSequence(POSITIVE_BUTTON_TEXT_KEY, this.positiveButtonText); | ||||
|         bundle.putInt(POSITIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY, this.positiveButtonContentDescriptionResId); | ||||
|         bundle.putCharSequence(POSITIVE_BUTTON_CONTENT_DESCRIPTION_KEY, this.positiveButtonContentDescription); | ||||
|         bundle.putInt(NEGATIVE_BUTTON_TEXT_RES_ID_KEY, this.negativeButtonTextResId); | ||||
|         bundle.putCharSequence(NEGATIVE_BUTTON_TEXT_KEY, this.negativeButtonText); | ||||
|         bundle.putInt(NEGATIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY, this.negativeButtonContentDescriptionResId); | ||||
|         bundle.putCharSequence(NEGATIVE_BUTTON_CONTENT_DESCRIPTION_KEY, this.negativeButtonContentDescription); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment | ||||
|     public final void onCreate(Bundle bundle) { | ||||
|         super.onCreate(bundle); | ||||
|         if (bundle == null) { | ||||
|             bundle = getArguments(); | ||||
|         } | ||||
|         this.overrideThemeResId = bundle.getInt(OVERRIDE_THEME_RES_ID); | ||||
|         this.dateSelector = (DateSelector) bundle.getParcelable(DATE_SELECTOR_KEY); | ||||
|         this.calendarConstraints = (CalendarConstraints) bundle.getParcelable(CALENDAR_CONSTRAINTS_KEY); | ||||
|         this.dayViewDecorator = (DayViewDecorator) bundle.getParcelable(DAY_VIEW_DECORATOR_KEY); | ||||
|         this.titleTextResId = bundle.getInt(TITLE_TEXT_RES_ID_KEY); | ||||
|         this.titleText = bundle.getCharSequence(TITLE_TEXT_KEY); | ||||
|         this.inputMode = bundle.getInt(INPUT_MODE_KEY); | ||||
|         this.positiveButtonTextResId = bundle.getInt(POSITIVE_BUTTON_TEXT_RES_ID_KEY); | ||||
|         this.positiveButtonText = bundle.getCharSequence(POSITIVE_BUTTON_TEXT_KEY); | ||||
|         this.positiveButtonContentDescriptionResId = bundle.getInt(POSITIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY); | ||||
|         this.positiveButtonContentDescription = bundle.getCharSequence(POSITIVE_BUTTON_CONTENT_DESCRIPTION_KEY); | ||||
|         this.negativeButtonTextResId = bundle.getInt(NEGATIVE_BUTTON_TEXT_RES_ID_KEY); | ||||
|         this.negativeButtonText = bundle.getCharSequence(NEGATIVE_BUTTON_TEXT_KEY); | ||||
|         this.negativeButtonContentDescriptionResId = bundle.getInt(NEGATIVE_BUTTON_CONTENT_DESCRIPTION_RES_ID_KEY); | ||||
|         this.negativeButtonContentDescription = bundle.getCharSequence(NEGATIVE_BUTTON_CONTENT_DESCRIPTION_KEY); | ||||
|         CharSequence charSequence = this.titleText; | ||||
|         if (charSequence == null) { | ||||
|             charSequence = requireContext().getResources().getText(this.titleTextResId); | ||||
|         } | ||||
|         this.fullTitleText = charSequence; | ||||
|         this.singleLineTitleText = getFirstLineBySeparator(charSequence); | ||||
|     } | ||||
|  | ||||
|     private int getThemeResId(Context context) { | ||||
|         int i = this.overrideThemeResId; | ||||
|         return i != 0 ? i : getDateSelector().getDefaultThemeResId(context); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment | ||||
|     public final Dialog onCreateDialog(Bundle bundle) { | ||||
|         Dialog dialog = new Dialog(requireContext(), getThemeResId(requireContext())); | ||||
|         Context context = dialog.getContext(); | ||||
|         this.fullscreen = isFullscreen(context); | ||||
|         this.background = new MaterialShapeDrawable(context, null, R.attr.materialCalendarStyle, R.style.Widget_MaterialComponents_MaterialCalendar); | ||||
|         TypedArray obtainStyledAttributes = context.obtainStyledAttributes(null, R.styleable.MaterialCalendar, R.attr.materialCalendarStyle, R.style.Widget_MaterialComponents_MaterialCalendar); | ||||
|         int color = obtainStyledAttributes.getColor(R.styleable.MaterialCalendar_backgroundTint, 0); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         this.background.initializeElevationOverlay(context); | ||||
|         this.background.setFillColor(ColorStateList.valueOf(color)); | ||||
|         this.background.setElevation(ViewCompat.getElevation(dialog.getWindow().getDecorView())); | ||||
|         return dialog; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { | ||||
|         View inflate = layoutInflater.inflate(this.fullscreen ? R.layout.mtrl_picker_fullscreen : R.layout.mtrl_picker_dialog, viewGroup); | ||||
|         Context context = inflate.getContext(); | ||||
|         DayViewDecorator dayViewDecorator = this.dayViewDecorator; | ||||
|         if (dayViewDecorator != null) { | ||||
|             dayViewDecorator.initialize(context); | ||||
|         } | ||||
|         if (this.fullscreen) { | ||||
|             inflate.findViewById(R.id.mtrl_calendar_frame).setLayoutParams(new LinearLayout.LayoutParams(getPaddedPickerWidth(context), -2)); | ||||
|         } else { | ||||
|             inflate.findViewById(R.id.mtrl_calendar_main_pane).setLayoutParams(new LinearLayout.LayoutParams(getPaddedPickerWidth(context), -1)); | ||||
|         } | ||||
|         TextView textView = (TextView) inflate.findViewById(R.id.mtrl_picker_header_selection_text); | ||||
|         this.headerSelectionText = textView; | ||||
|         ViewCompat.setAccessibilityLiveRegion(textView, 1); | ||||
|         this.headerToggleButton = (CheckableImageButton) inflate.findViewById(R.id.mtrl_picker_header_toggle); | ||||
|         this.headerTitleTextView = (TextView) inflate.findViewById(R.id.mtrl_picker_title_text); | ||||
|         initHeaderToggle(context); | ||||
|         this.confirmButton = (Button) inflate.findViewById(R.id.confirm_button); | ||||
|         if (getDateSelector().isSelectionComplete()) { | ||||
|             this.confirmButton.setEnabled(true); | ||||
|         } else { | ||||
|             this.confirmButton.setEnabled(false); | ||||
|         } | ||||
|         this.confirmButton.setTag(CONFIRM_BUTTON_TAG); | ||||
|         CharSequence charSequence = this.positiveButtonText; | ||||
|         if (charSequence != null) { | ||||
|             this.confirmButton.setText(charSequence); | ||||
|         } else { | ||||
|             int i = this.positiveButtonTextResId; | ||||
|             if (i != 0) { | ||||
|                 this.confirmButton.setText(i); | ||||
|             } | ||||
|         } | ||||
|         CharSequence charSequence2 = this.positiveButtonContentDescription; | ||||
|         if (charSequence2 != null) { | ||||
|             this.confirmButton.setContentDescription(charSequence2); | ||||
|         } else if (this.positiveButtonContentDescriptionResId != 0) { | ||||
|             this.confirmButton.setContentDescription(getContext().getResources().getText(this.positiveButtonContentDescriptionResId)); | ||||
|         } | ||||
|         this.confirmButton.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.datepicker.MaterialDatePicker.1 | ||||
|             /* JADX WARN: Multi-variable type inference failed */ | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public void onClick(View view) { | ||||
|                 Iterator it = MaterialDatePicker.this.onPositiveButtonClickListeners.iterator(); | ||||
|                 while (it.hasNext()) { | ||||
|                     ((MaterialPickerOnPositiveButtonClickListener) it.next()).onPositiveButtonClick(MaterialDatePicker.this.getSelection()); | ||||
|                 } | ||||
|                 MaterialDatePicker.this.dismiss(); | ||||
|             } | ||||
|         }); | ||||
|         Button button = (Button) inflate.findViewById(R.id.cancel_button); | ||||
|         button.setTag(CANCEL_BUTTON_TAG); | ||||
|         CharSequence charSequence3 = this.negativeButtonText; | ||||
|         if (charSequence3 != null) { | ||||
|             button.setText(charSequence3); | ||||
|         } else { | ||||
|             int i2 = this.negativeButtonTextResId; | ||||
|             if (i2 != 0) { | ||||
|                 button.setText(i2); | ||||
|             } | ||||
|         } | ||||
|         CharSequence charSequence4 = this.negativeButtonContentDescription; | ||||
|         if (charSequence4 != null) { | ||||
|             button.setContentDescription(charSequence4); | ||||
|         } else if (this.negativeButtonContentDescriptionResId != 0) { | ||||
|             button.setContentDescription(getContext().getResources().getText(this.negativeButtonContentDescriptionResId)); | ||||
|         } | ||||
|         button.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.datepicker.MaterialDatePicker.2 | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public void onClick(View view) { | ||||
|                 Iterator it = MaterialDatePicker.this.onNegativeButtonClickListeners.iterator(); | ||||
|                 while (it.hasNext()) { | ||||
|                     ((View.OnClickListener) it.next()).onClick(view); | ||||
|                 } | ||||
|                 MaterialDatePicker.this.dismiss(); | ||||
|             } | ||||
|         }); | ||||
|         return inflate; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment | ||||
|     public void onStart() { | ||||
|         super.onStart(); | ||||
|         Window window = requireDialog().getWindow(); | ||||
|         if (this.fullscreen) { | ||||
|             window.setLayout(-1, -1); | ||||
|             window.setBackgroundDrawable(this.background); | ||||
|             enableEdgeToEdgeIfNeeded(window); | ||||
|         } else { | ||||
|             window.setLayout(-2, -2); | ||||
|             int dimensionPixelOffset = getResources().getDimensionPixelOffset(R.dimen.mtrl_calendar_dialog_background_inset); | ||||
|             Rect rect = new Rect(dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset); | ||||
|             window.setBackgroundDrawable(new InsetDrawable((Drawable) this.background, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset, dimensionPixelOffset)); | ||||
|             window.getDecorView().setOnTouchListener(new InsetDialogOnTouchListener(requireDialog(), rect)); | ||||
|         } | ||||
|         startPickerFragment(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment | ||||
|     public void onStop() { | ||||
|         this.pickerFragment.clearOnSelectionChangedListeners(); | ||||
|         super.onStop(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnCancelListener | ||||
|     public final void onCancel(DialogInterface dialogInterface) { | ||||
|         Iterator<DialogInterface.OnCancelListener> it = this.onCancelListeners.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             it.next().onCancel(dialogInterface); | ||||
|         } | ||||
|         super.onCancel(dialogInterface); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnDismissListener | ||||
|     public final void onDismiss(DialogInterface dialogInterface) { | ||||
|         Iterator<DialogInterface.OnDismissListener> it = this.onDismissListeners.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             it.next().onDismiss(dialogInterface); | ||||
|         } | ||||
|         ViewGroup viewGroup = (ViewGroup) getView(); | ||||
|         if (viewGroup != null) { | ||||
|             viewGroup.removeAllViews(); | ||||
|         } | ||||
|         super.onDismiss(dialogInterface); | ||||
|     } | ||||
|  | ||||
|     public final S getSelection() { | ||||
|         return getDateSelector().getSelection(); | ||||
|     } | ||||
|  | ||||
|     private void enableEdgeToEdgeIfNeeded(Window window) { | ||||
|         if (this.edgeToEdgeEnabled) { | ||||
|             return; | ||||
|         } | ||||
|         final View findViewById = requireView().findViewById(R.id.fullscreen_header); | ||||
|         EdgeToEdgeUtils.applyEdgeToEdge(window, true, ViewUtils.getBackgroundColor(findViewById), null); | ||||
|         final int paddingTop = findViewById.getPaddingTop(); | ||||
|         final int i = findViewById.getLayoutParams().height; | ||||
|         ViewCompat.setOnApplyWindowInsetsListener(findViewById, new OnApplyWindowInsetsListener() { // from class: com.google.android.material.datepicker.MaterialDatePicker.3 | ||||
|             @Override // androidx.core.view.OnApplyWindowInsetsListener | ||||
|             public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) { | ||||
|                 int i2 = windowInsetsCompat.getInsets(WindowInsetsCompat.Type.systemBars()).top; | ||||
|                 if (i >= 0) { | ||||
|                     findViewById.getLayoutParams().height = i + i2; | ||||
|                     View view2 = findViewById; | ||||
|                     view2.setLayoutParams(view2.getLayoutParams()); | ||||
|                 } | ||||
|                 View view3 = findViewById; | ||||
|                 view3.setPadding(view3.getPaddingLeft(), paddingTop + i2, findViewById.getPaddingRight(), findViewById.getPaddingBottom()); | ||||
|                 return windowInsetsCompat; | ||||
|             } | ||||
|         }); | ||||
|         this.edgeToEdgeEnabled = true; | ||||
|     } | ||||
|  | ||||
|     private void updateTitle() { | ||||
|         this.headerTitleTextView.setText((this.inputMode == 1 && isLandscape()) ? this.singleLineTitleText : this.fullTitleText); | ||||
|     } | ||||
|  | ||||
|     void updateHeader(String str) { | ||||
|         this.headerSelectionText.setContentDescription(getHeaderContentDescription()); | ||||
|         this.headerSelectionText.setText(str); | ||||
|     } | ||||
|  | ||||
|     private String getHeaderContentDescription() { | ||||
|         return getDateSelector().getSelectionContentDescription(requireContext()); | ||||
|     } | ||||
|  | ||||
|     private void startPickerFragment() { | ||||
|         int themeResId = getThemeResId(requireContext()); | ||||
|         MaterialTextInputPicker newInstance = MaterialCalendar.newInstance(getDateSelector(), themeResId, this.calendarConstraints, this.dayViewDecorator); | ||||
|         this.calendar = newInstance; | ||||
|         if (this.inputMode == 1) { | ||||
|             newInstance = MaterialTextInputPicker.newInstance(getDateSelector(), themeResId, this.calendarConstraints); | ||||
|         } | ||||
|         this.pickerFragment = newInstance; | ||||
|         updateTitle(); | ||||
|         updateHeader(getHeaderText()); | ||||
|         FragmentTransaction beginTransaction = getChildFragmentManager().beginTransaction(); | ||||
|         beginTransaction.replace(R.id.mtrl_calendar_frame, this.pickerFragment); | ||||
|         beginTransaction.commitNow(); | ||||
|         this.pickerFragment.addOnSelectionChangedListener(new OnSelectionChangedListener<S>() { // from class: com.google.android.material.datepicker.MaterialDatePicker.4 | ||||
|             @Override // com.google.android.material.datepicker.OnSelectionChangedListener | ||||
|             public void onSelectionChanged(S s) { | ||||
|                 MaterialDatePicker materialDatePicker = MaterialDatePicker.this; | ||||
|                 materialDatePicker.updateHeader(materialDatePicker.getHeaderText()); | ||||
|                 MaterialDatePicker.this.confirmButton.setEnabled(MaterialDatePicker.this.getDateSelector().isSelectionComplete()); | ||||
|             } | ||||
|  | ||||
|             @Override // com.google.android.material.datepicker.OnSelectionChangedListener | ||||
|             public void onIncompleteSelectionChanged() { | ||||
|                 MaterialDatePicker.this.confirmButton.setEnabled(false); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     private void initHeaderToggle(Context context) { | ||||
|         this.headerToggleButton.setTag(TOGGLE_BUTTON_TAG); | ||||
|         this.headerToggleButton.setImageDrawable(createHeaderToggleDrawable(context)); | ||||
|         this.headerToggleButton.setChecked(this.inputMode != 0); | ||||
|         ViewCompat.setAccessibilityDelegate(this.headerToggleButton, null); | ||||
|         updateToggleContentDescription(this.headerToggleButton); | ||||
|         this.headerToggleButton.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.datepicker.MaterialDatePicker$$ExternalSyntheticLambda0 | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public final void onClick(View view) { | ||||
|                 MaterialDatePicker.this.m242x8a93f18a(view); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     /* renamed from: lambda$initHeaderToggle$0$com-google-android-material-datepicker-MaterialDatePicker, reason: not valid java name */ | ||||
|     /* synthetic */ void m242x8a93f18a(View view) { | ||||
|         this.confirmButton.setEnabled(getDateSelector().isSelectionComplete()); | ||||
|         this.headerToggleButton.toggle(); | ||||
|         this.inputMode = this.inputMode == 1 ? 0 : 1; | ||||
|         updateToggleContentDescription(this.headerToggleButton); | ||||
|         startPickerFragment(); | ||||
|     } | ||||
|  | ||||
|     private void updateToggleContentDescription(CheckableImageButton checkableImageButton) { | ||||
|         String string; | ||||
|         if (this.inputMode == 1) { | ||||
|             string = checkableImageButton.getContext().getString(R.string.mtrl_picker_toggle_to_calendar_input_mode); | ||||
|         } else { | ||||
|             string = checkableImageButton.getContext().getString(R.string.mtrl_picker_toggle_to_text_input_mode); | ||||
|         } | ||||
|         this.headerToggleButton.setContentDescription(string); | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public DateSelector<S> getDateSelector() { | ||||
|         if (this.dateSelector == null) { | ||||
|             this.dateSelector = (DateSelector) getArguments().getParcelable(DATE_SELECTOR_KEY); | ||||
|         } | ||||
|         return this.dateSelector; | ||||
|     } | ||||
|  | ||||
|     private static Drawable createHeaderToggleDrawable(Context context) { | ||||
|         StateListDrawable stateListDrawable = new StateListDrawable(); | ||||
|         stateListDrawable.addState(new int[]{android.R.attr.state_checked}, AppCompatResources.getDrawable(context, R.drawable.material_ic_calendar_black_24dp)); | ||||
|         stateListDrawable.addState(new int[0], AppCompatResources.getDrawable(context, R.drawable.material_ic_edit_black_24dp)); | ||||
|         return stateListDrawable; | ||||
|     } | ||||
|  | ||||
|     private static CharSequence getFirstLineBySeparator(CharSequence charSequence) { | ||||
|         if (charSequence == null) { | ||||
|             return null; | ||||
|         } | ||||
|         String[] split = TextUtils.split(String.valueOf(charSequence), "\n"); | ||||
|         return split.length > 1 ? split[0] : charSequence; | ||||
|     } | ||||
|  | ||||
|     private boolean isLandscape() { | ||||
|         return getResources().getConfiguration().orientation == 2; | ||||
|     } | ||||
|  | ||||
|     static boolean isFullscreen(Context context) { | ||||
|         return readMaterialCalendarStyleBoolean(context, android.R.attr.windowFullscreen); | ||||
|     } | ||||
|  | ||||
|     static boolean isNestedScrollable(Context context) { | ||||
|         return readMaterialCalendarStyleBoolean(context, R.attr.nestedScrollable); | ||||
|     } | ||||
|  | ||||
|     static boolean readMaterialCalendarStyleBoolean(Context context, int i) { | ||||
|         TypedArray obtainStyledAttributes = context.obtainStyledAttributes(MaterialAttributes.resolveOrThrow(context, R.attr.materialCalendarStyle, MaterialCalendar.class.getCanonicalName()), new int[]{i}); | ||||
|         boolean z = obtainStyledAttributes.getBoolean(0, false); | ||||
|         obtainStyledAttributes.recycle(); | ||||
|         return z; | ||||
|     } | ||||
|  | ||||
|     private static int getPaddedPickerWidth(Context context) { | ||||
|         Resources resources = context.getResources(); | ||||
|         int dimensionPixelOffset = resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_content_padding); | ||||
|         int i = Month.current().daysInWeek; | ||||
|         return (dimensionPixelOffset * 2) + (resources.getDimensionPixelSize(R.dimen.mtrl_calendar_day_width) * i) + ((i - 1) * resources.getDimensionPixelOffset(R.dimen.mtrl_calendar_month_horizontal_padding)); | ||||
|     } | ||||
|  | ||||
|     public boolean addOnPositiveButtonClickListener(MaterialPickerOnPositiveButtonClickListener<? super S> materialPickerOnPositiveButtonClickListener) { | ||||
|         return this.onPositiveButtonClickListeners.add(materialPickerOnPositiveButtonClickListener); | ||||
|     } | ||||
|  | ||||
|     public boolean removeOnPositiveButtonClickListener(MaterialPickerOnPositiveButtonClickListener<? super S> materialPickerOnPositiveButtonClickListener) { | ||||
|         return this.onPositiveButtonClickListeners.remove(materialPickerOnPositiveButtonClickListener); | ||||
|     } | ||||
|  | ||||
|     public void clearOnPositiveButtonClickListeners() { | ||||
|         this.onPositiveButtonClickListeners.clear(); | ||||
|     } | ||||
|  | ||||
|     public boolean addOnNegativeButtonClickListener(View.OnClickListener onClickListener) { | ||||
|         return this.onNegativeButtonClickListeners.add(onClickListener); | ||||
|     } | ||||
|  | ||||
|     public boolean removeOnNegativeButtonClickListener(View.OnClickListener onClickListener) { | ||||
|         return this.onNegativeButtonClickListeners.remove(onClickListener); | ||||
|     } | ||||
|  | ||||
|     public void clearOnNegativeButtonClickListeners() { | ||||
|         this.onNegativeButtonClickListeners.clear(); | ||||
|     } | ||||
|  | ||||
|     public boolean addOnCancelListener(DialogInterface.OnCancelListener onCancelListener) { | ||||
|         return this.onCancelListeners.add(onCancelListener); | ||||
|     } | ||||
|  | ||||
|     public boolean removeOnCancelListener(DialogInterface.OnCancelListener onCancelListener) { | ||||
|         return this.onCancelListeners.remove(onCancelListener); | ||||
|     } | ||||
|  | ||||
|     public void clearOnCancelListeners() { | ||||
|         this.onCancelListeners.clear(); | ||||
|     } | ||||
|  | ||||
|     public boolean addOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { | ||||
|         return this.onDismissListeners.add(onDismissListener); | ||||
|     } | ||||
|  | ||||
|     public boolean removeOnDismissListener(DialogInterface.OnDismissListener onDismissListener) { | ||||
|         return this.onDismissListeners.remove(onDismissListener); | ||||
|     } | ||||
|  | ||||
|     public void clearOnDismissListeners() { | ||||
|         this.onDismissListeners.clear(); | ||||
|     } | ||||
|  | ||||
|     public static final class Builder<S> { | ||||
|         CalendarConstraints calendarConstraints; | ||||
|         final DateSelector<S> dateSelector; | ||||
|         DayViewDecorator dayViewDecorator; | ||||
|         int overrideThemeResId = 0; | ||||
|         int titleTextResId = 0; | ||||
|         CharSequence titleText = null; | ||||
|         int positiveButtonTextResId = 0; | ||||
|         CharSequence positiveButtonText = null; | ||||
|         int positiveButtonContentDescriptionResId = 0; | ||||
|         CharSequence positiveButtonContentDescription = null; | ||||
|         int negativeButtonTextResId = 0; | ||||
|         CharSequence negativeButtonText = null; | ||||
|         int negativeButtonContentDescriptionResId = 0; | ||||
|         CharSequence negativeButtonContentDescription = null; | ||||
|         S selection = null; | ||||
|         int inputMode = 0; | ||||
|  | ||||
|         public Builder<S> setCalendarConstraints(CalendarConstraints calendarConstraints) { | ||||
|             this.calendarConstraints = calendarConstraints; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setDayViewDecorator(DayViewDecorator dayViewDecorator) { | ||||
|             this.dayViewDecorator = dayViewDecorator; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setInputMode(int i) { | ||||
|             this.inputMode = i; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setNegativeButtonContentDescription(int i) { | ||||
|             this.negativeButtonContentDescriptionResId = i; | ||||
|             this.negativeButtonContentDescription = null; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setNegativeButtonContentDescription(CharSequence charSequence) { | ||||
|             this.negativeButtonContentDescription = charSequence; | ||||
|             this.negativeButtonContentDescriptionResId = 0; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setNegativeButtonText(int i) { | ||||
|             this.negativeButtonTextResId = i; | ||||
|             this.negativeButtonText = null; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setNegativeButtonText(CharSequence charSequence) { | ||||
|             this.negativeButtonText = charSequence; | ||||
|             this.negativeButtonTextResId = 0; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setPositiveButtonContentDescription(int i) { | ||||
|             this.positiveButtonContentDescriptionResId = i; | ||||
|             this.positiveButtonContentDescription = null; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setPositiveButtonContentDescription(CharSequence charSequence) { | ||||
|             this.positiveButtonContentDescription = charSequence; | ||||
|             this.positiveButtonContentDescriptionResId = 0; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setPositiveButtonText(int i) { | ||||
|             this.positiveButtonTextResId = i; | ||||
|             this.positiveButtonText = null; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setPositiveButtonText(CharSequence charSequence) { | ||||
|             this.positiveButtonText = charSequence; | ||||
|             this.positiveButtonTextResId = 0; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setSelection(S s) { | ||||
|             this.selection = s; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setTheme(int i) { | ||||
|             this.overrideThemeResId = i; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setTitleText(int i) { | ||||
|             this.titleTextResId = i; | ||||
|             this.titleText = null; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setTitleText(CharSequence charSequence) { | ||||
|             this.titleText = charSequence; | ||||
|             this.titleTextResId = 0; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         private Builder(DateSelector<S> dateSelector) { | ||||
|             this.dateSelector = dateSelector; | ||||
|         } | ||||
|  | ||||
|         public static <S> Builder<S> customDatePicker(DateSelector<S> dateSelector) { | ||||
|             return new Builder<>(dateSelector); | ||||
|         } | ||||
|  | ||||
|         public static Builder<Long> datePicker() { | ||||
|             return new Builder<>(new SingleDateSelector()); | ||||
|         } | ||||
|  | ||||
|         public static Builder<Pair<Long, Long>> dateRangePicker() { | ||||
|             return new Builder<>(new RangeDateSelector()); | ||||
|         } | ||||
|  | ||||
|         public Builder<S> setTextInputFormat(SimpleDateFormat simpleDateFormat) { | ||||
|             this.dateSelector.setTextInputFormat(simpleDateFormat); | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public MaterialDatePicker<S> build() { | ||||
|             if (this.calendarConstraints == null) { | ||||
|                 this.calendarConstraints = new CalendarConstraints.Builder().build(); | ||||
|             } | ||||
|             if (this.titleTextResId == 0) { | ||||
|                 this.titleTextResId = this.dateSelector.getDefaultTitleResId(); | ||||
|             } | ||||
|             S s = this.selection; | ||||
|             if (s != null) { | ||||
|                 this.dateSelector.setSelection(s); | ||||
|             } | ||||
|             if (this.calendarConstraints.getOpenAt() == null) { | ||||
|                 this.calendarConstraints.setOpenAt(createDefaultOpenAt()); | ||||
|             } | ||||
|             return MaterialDatePicker.newInstance(this); | ||||
|         } | ||||
|  | ||||
|         private Month createDefaultOpenAt() { | ||||
|             if (!this.dateSelector.getSelectedDays().isEmpty()) { | ||||
|                 Month create = Month.create(this.dateSelector.getSelectedDays().iterator().next().longValue()); | ||||
|                 if (monthInValidRange(create, this.calendarConstraints)) { | ||||
|                     return create; | ||||
|                 } | ||||
|             } | ||||
|             Month current = Month.current(); | ||||
|             return monthInValidRange(current, this.calendarConstraints) ? current : this.calendarConstraints.getStart(); | ||||
|         } | ||||
|  | ||||
|         private static boolean monthInValidRange(Month month, CalendarConstraints calendarConstraints) { | ||||
|             return month.compareTo(calendarConstraints.getStart()) >= 0 && month.compareTo(calendarConstraints.getEnd()) <= 0; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,6 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public interface MaterialPickerOnPositiveButtonClickListener<S> { | ||||
|     void onPositiveButtonClick(S s); | ||||
| } | ||||
| @@ -0,0 +1,52 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.app.DatePickerDialog; | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.Rect; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.os.Bundle; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.dialog.InsetDialogOnTouchListener; | ||||
| import com.google.android.material.dialog.MaterialDialogs; | ||||
| import com.google.android.material.resources.MaterialAttributes; | ||||
| import com.google.android.material.shape.MaterialShapeDrawable; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class MaterialStyledDatePickerDialog extends DatePickerDialog { | ||||
|     private static final int DEF_STYLE_ATTR = 16843612; | ||||
|     private static final int DEF_STYLE_RES = R.style.MaterialAlertDialog_MaterialComponents_Picker_Date_Spinner; | ||||
|     private final Drawable background; | ||||
|     private final Rect backgroundInsets; | ||||
|  | ||||
|     public MaterialStyledDatePickerDialog(Context context) { | ||||
|         this(context, 0); | ||||
|     } | ||||
|  | ||||
|     public MaterialStyledDatePickerDialog(Context context, int i) { | ||||
|         this(context, i, null, -1, -1, -1); | ||||
|     } | ||||
|  | ||||
|     public MaterialStyledDatePickerDialog(Context context, DatePickerDialog.OnDateSetListener onDateSetListener, int i, int i2, int i3) { | ||||
|         this(context, 0, onDateSetListener, i, i2, i3); | ||||
|     } | ||||
|  | ||||
|     public MaterialStyledDatePickerDialog(Context context, int i, DatePickerDialog.OnDateSetListener onDateSetListener, int i2, int i3, int i4) { | ||||
|         super(context, i, onDateSetListener, i2, i3, i4); | ||||
|         Context context2 = getContext(); | ||||
|         int resolveOrThrow = MaterialAttributes.resolveOrThrow(getContext(), R.attr.colorSurface, getClass().getCanonicalName()); | ||||
|         int i5 = DEF_STYLE_RES; | ||||
|         MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(context2, null, 16843612, i5); | ||||
|         materialShapeDrawable.setFillColor(ColorStateList.valueOf(resolveOrThrow)); | ||||
|         Rect dialogBackgroundInsets = MaterialDialogs.getDialogBackgroundInsets(context2, 16843612, i5); | ||||
|         this.backgroundInsets = dialogBackgroundInsets; | ||||
|         this.background = MaterialDialogs.insetDrawable(materialShapeDrawable, dialogBackgroundInsets); | ||||
|     } | ||||
|  | ||||
|     @Override // android.app.AlertDialog, android.app.Dialog | ||||
|     protected void onCreate(Bundle bundle) { | ||||
|         super.onCreate(bundle); | ||||
|         getWindow().setBackgroundDrawable(this.background); | ||||
|         getWindow().getDecorView().setOnTouchListener(new InsetDialogOnTouchListener(this, this.backgroundInsets)); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,77 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Bundle; | ||||
| import android.view.ContextThemeWrapper; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import java.util.Iterator; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class MaterialTextInputPicker<S> extends PickerFragment<S> { | ||||
|     private static final String CALENDAR_CONSTRAINTS_KEY = "CALENDAR_CONSTRAINTS_KEY"; | ||||
|     private static final String DATE_SELECTOR_KEY = "DATE_SELECTOR_KEY"; | ||||
|     private static final String THEME_RES_ID_KEY = "THEME_RES_ID_KEY"; | ||||
|     private CalendarConstraints calendarConstraints; | ||||
|     private DateSelector<S> dateSelector; | ||||
|     private int themeResId; | ||||
|  | ||||
|     static <T> MaterialTextInputPicker<T> newInstance(DateSelector<T> dateSelector, int i, CalendarConstraints calendarConstraints) { | ||||
|         MaterialTextInputPicker<T> materialTextInputPicker = new MaterialTextInputPicker<>(); | ||||
|         Bundle bundle = new Bundle(); | ||||
|         bundle.putInt(THEME_RES_ID_KEY, i); | ||||
|         bundle.putParcelable(DATE_SELECTOR_KEY, dateSelector); | ||||
|         bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, calendarConstraints); | ||||
|         materialTextInputPicker.setArguments(bundle); | ||||
|         return materialTextInputPicker; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public void onSaveInstanceState(Bundle bundle) { | ||||
|         super.onSaveInstanceState(bundle); | ||||
|         bundle.putInt(THEME_RES_ID_KEY, this.themeResId); | ||||
|         bundle.putParcelable(DATE_SELECTOR_KEY, this.dateSelector); | ||||
|         bundle.putParcelable(CALENDAR_CONSTRAINTS_KEY, this.calendarConstraints); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public void onCreate(Bundle bundle) { | ||||
|         super.onCreate(bundle); | ||||
|         if (bundle == null) { | ||||
|             bundle = getArguments(); | ||||
|         } | ||||
|         this.themeResId = bundle.getInt(THEME_RES_ID_KEY); | ||||
|         this.dateSelector = (DateSelector) bundle.getParcelable(DATE_SELECTOR_KEY); | ||||
|         this.calendarConstraints = (CalendarConstraints) bundle.getParcelable(CALENDAR_CONSTRAINTS_KEY); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.fragment.app.Fragment | ||||
|     public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { | ||||
|         return this.dateSelector.onCreateTextInputView(layoutInflater.cloneInContext(new ContextThemeWrapper(getContext(), this.themeResId)), viewGroup, bundle, this.calendarConstraints, new OnSelectionChangedListener<S>() { // from class: com.google.android.material.datepicker.MaterialTextInputPicker.1 | ||||
|             @Override // com.google.android.material.datepicker.OnSelectionChangedListener | ||||
|             public void onSelectionChanged(S s) { | ||||
|                 Iterator<OnSelectionChangedListener<S>> it = MaterialTextInputPicker.this.onSelectionChangedListeners.iterator(); | ||||
|                 while (it.hasNext()) { | ||||
|                     it.next().onSelectionChanged(s); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             @Override // com.google.android.material.datepicker.OnSelectionChangedListener | ||||
|             public void onIncompleteSelectionChanged() { | ||||
|                 Iterator<OnSelectionChangedListener<S>> it = MaterialTextInputPicker.this.onSelectionChangedListeners.iterator(); | ||||
|                 while (it.hasNext()) { | ||||
|                     it.next().onIncompleteSelectionChanged(); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.PickerFragment | ||||
|     public DateSelector<S> getDateSelector() { | ||||
|         DateSelector<S> dateSelector = this.dateSelector; | ||||
|         if (dateSelector != null) { | ||||
|             return dateSelector; | ||||
|         } | ||||
|         throw new IllegalStateException("dateSelector should not be null. Use MaterialTextInputPicker#newInstance() to create this fragment with a DateSelector, and call this method after the fragment has been created."); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,135 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import java.util.Arrays; | ||||
| import java.util.Calendar; | ||||
| import java.util.GregorianCalendar; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| final class Month implements Comparable<Month>, Parcelable { | ||||
|     public static final Parcelable.Creator<Month> CREATOR = new Parcelable.Creator<Month>() { // from class: com.google.android.material.datepicker.Month.1 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public Month createFromParcel(Parcel parcel) { | ||||
|             return Month.create(parcel.readInt(), parcel.readInt()); | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public Month[] newArray(int i) { | ||||
|             return new Month[i]; | ||||
|         } | ||||
|     }; | ||||
|     final int daysInMonth; | ||||
|     final int daysInWeek; | ||||
|     private final Calendar firstOfMonth; | ||||
|     private String longName; | ||||
|     final int month; | ||||
|     final long timeInMillis; | ||||
|     final int year; | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     private Month(Calendar calendar) { | ||||
|         calendar.set(5, 1); | ||||
|         Calendar dayCopy = UtcDates.getDayCopy(calendar); | ||||
|         this.firstOfMonth = dayCopy; | ||||
|         this.month = dayCopy.get(2); | ||||
|         this.year = dayCopy.get(1); | ||||
|         this.daysInWeek = dayCopy.getMaximum(7); | ||||
|         this.daysInMonth = dayCopy.getActualMaximum(5); | ||||
|         this.timeInMillis = dayCopy.getTimeInMillis(); | ||||
|     } | ||||
|  | ||||
|     static Month create(long j) { | ||||
|         Calendar utcCalendar = UtcDates.getUtcCalendar(); | ||||
|         utcCalendar.setTimeInMillis(j); | ||||
|         return new Month(utcCalendar); | ||||
|     } | ||||
|  | ||||
|     static Month create(int i, int i2) { | ||||
|         Calendar utcCalendar = UtcDates.getUtcCalendar(); | ||||
|         utcCalendar.set(1, i); | ||||
|         utcCalendar.set(2, i2); | ||||
|         return new Month(utcCalendar); | ||||
|     } | ||||
|  | ||||
|     static Month current() { | ||||
|         return new Month(UtcDates.getTodayCalendar()); | ||||
|     } | ||||
|  | ||||
|     int daysFromStartOfWeekToFirstOfMonth(int i) { | ||||
|         int i2 = this.firstOfMonth.get(7); | ||||
|         if (i <= 0) { | ||||
|             i = this.firstOfMonth.getFirstDayOfWeek(); | ||||
|         } | ||||
|         int i3 = i2 - i; | ||||
|         return i3 < 0 ? i3 + this.daysInWeek : i3; | ||||
|     } | ||||
|  | ||||
|     public boolean equals(Object obj) { | ||||
|         if (this == obj) { | ||||
|             return true; | ||||
|         } | ||||
|         if (!(obj instanceof Month)) { | ||||
|             return false; | ||||
|         } | ||||
|         Month month = (Month) obj; | ||||
|         return this.month == month.month && this.year == month.year; | ||||
|     } | ||||
|  | ||||
|     public int hashCode() { | ||||
|         return Arrays.hashCode(new Object[]{Integer.valueOf(this.month), Integer.valueOf(this.year)}); | ||||
|     } | ||||
|  | ||||
|     @Override // java.lang.Comparable | ||||
|     public int compareTo(Month month) { | ||||
|         return this.firstOfMonth.compareTo(month.firstOfMonth); | ||||
|     } | ||||
|  | ||||
|     int monthsUntil(Month month) { | ||||
|         if (this.firstOfMonth instanceof GregorianCalendar) { | ||||
|             return ((month.year - this.year) * 12) + (month.month - this.month); | ||||
|         } | ||||
|         throw new IllegalArgumentException("Only Gregorian calendars are supported."); | ||||
|     } | ||||
|  | ||||
|     long getStableId() { | ||||
|         return this.firstOfMonth.getTimeInMillis(); | ||||
|     } | ||||
|  | ||||
|     long getDay(int i) { | ||||
|         Calendar dayCopy = UtcDates.getDayCopy(this.firstOfMonth); | ||||
|         dayCopy.set(5, i); | ||||
|         return dayCopy.getTimeInMillis(); | ||||
|     } | ||||
|  | ||||
|     int getDayOfMonth(long j) { | ||||
|         Calendar dayCopy = UtcDates.getDayCopy(this.firstOfMonth); | ||||
|         dayCopy.setTimeInMillis(j); | ||||
|         return dayCopy.get(5); | ||||
|     } | ||||
|  | ||||
|     Month monthsLater(int i) { | ||||
|         Calendar dayCopy = UtcDates.getDayCopy(this.firstOfMonth); | ||||
|         dayCopy.add(2, i); | ||||
|         return new Month(dayCopy); | ||||
|     } | ||||
|  | ||||
|     String getLongName() { | ||||
|         if (this.longName == null) { | ||||
|             this.longName = DateStrings.getYearMonth(this.firstOfMonth.getTimeInMillis()); | ||||
|         } | ||||
|         return this.longName; | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeInt(this.year); | ||||
|         parcel.writeInt(this.month); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,225 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.ColorStateList; | ||||
| import android.graphics.drawable.Drawable; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.BaseAdapter; | ||||
| import android.widget.TextView; | ||||
| import androidx.core.util.Pair; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.timepicker.TimeModel; | ||||
| import java.util.Collection; | ||||
| import java.util.Iterator; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class MonthAdapter extends BaseAdapter { | ||||
|     private static final int NO_DAY_NUMBER = -1; | ||||
|     final CalendarConstraints calendarConstraints; | ||||
|     CalendarStyle calendarStyle; | ||||
|     final DateSelector<?> dateSelector; | ||||
|     final DayViewDecorator dayViewDecorator; | ||||
|     final Month month; | ||||
|     private Collection<Long> previouslySelectedDates; | ||||
|     static final int MAXIMUM_WEEKS = UtcDates.getUtcCalendar().getMaximum(4); | ||||
|     private static final int MAXIMUM_GRID_CELLS = (UtcDates.getUtcCalendar().getMaximum(5) + UtcDates.getUtcCalendar().getMaximum(7)) - 1; | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public int getCount() { | ||||
|         return MAXIMUM_GRID_CELLS; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.BaseAdapter, android.widget.Adapter | ||||
|     public boolean hasStableIds() { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     MonthAdapter(Month month, DateSelector<?> dateSelector, CalendarConstraints calendarConstraints, DayViewDecorator dayViewDecorator) { | ||||
|         this.month = month; | ||||
|         this.dateSelector = dateSelector; | ||||
|         this.calendarConstraints = calendarConstraints; | ||||
|         this.dayViewDecorator = dayViewDecorator; | ||||
|         this.previouslySelectedDates = dateSelector.getSelectedDays(); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public Long getItem(int i) { | ||||
|         if (i < firstPositionInMonth() || i > lastPositionInMonth()) { | ||||
|             return null; | ||||
|         } | ||||
|         return Long.valueOf(this.month.getDay(positionToDay(i))); | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public long getItemId(int i) { | ||||
|         return i / this.month.daysInWeek; | ||||
|     } | ||||
|  | ||||
|     @Override // android.widget.Adapter | ||||
|     public TextView getView(int i, View view, ViewGroup viewGroup) { | ||||
|         int i2; | ||||
|         initializeStyles(viewGroup.getContext()); | ||||
|         TextView textView = (TextView) view; | ||||
|         if (view == null) { | ||||
|             textView = (TextView) LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mtrl_calendar_day, viewGroup, false); | ||||
|         } | ||||
|         int firstPositionInMonth = i - firstPositionInMonth(); | ||||
|         if (firstPositionInMonth < 0 || firstPositionInMonth >= this.month.daysInMonth) { | ||||
|             textView.setVisibility(8); | ||||
|             textView.setEnabled(false); | ||||
|             i2 = -1; | ||||
|         } else { | ||||
|             i2 = firstPositionInMonth + 1; | ||||
|             textView.setTag(this.month); | ||||
|             textView.setText(String.format(textView.getResources().getConfiguration().locale, TimeModel.NUMBER_FORMAT, Integer.valueOf(i2))); | ||||
|             textView.setVisibility(0); | ||||
|             textView.setEnabled(true); | ||||
|         } | ||||
|         Long item = getItem(i); | ||||
|         if (item == null) { | ||||
|             return textView; | ||||
|         } | ||||
|         updateSelectedState(textView, item.longValue(), i2); | ||||
|         return textView; | ||||
|     } | ||||
|  | ||||
|     public void updateSelectedStates(MaterialCalendarGridView materialCalendarGridView) { | ||||
|         Iterator<Long> it = this.previouslySelectedDates.iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             updateSelectedStateForDate(materialCalendarGridView, it.next().longValue()); | ||||
|         } | ||||
|         DateSelector<?> dateSelector = this.dateSelector; | ||||
|         if (dateSelector != null) { | ||||
|             Iterator<Long> it2 = dateSelector.getSelectedDays().iterator(); | ||||
|             while (it2.hasNext()) { | ||||
|                 updateSelectedStateForDate(materialCalendarGridView, it2.next().longValue()); | ||||
|             } | ||||
|             this.previouslySelectedDates = this.dateSelector.getSelectedDays(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void updateSelectedStateForDate(MaterialCalendarGridView materialCalendarGridView, long j) { | ||||
|         if (Month.create(j).equals(this.month)) { | ||||
|             int dayOfMonth = this.month.getDayOfMonth(j); | ||||
|             updateSelectedState((TextView) materialCalendarGridView.getChildAt(materialCalendarGridView.getAdapter().dayToPosition(dayOfMonth) - materialCalendarGridView.getFirstVisiblePosition()), j, dayOfMonth); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void updateSelectedState(TextView textView, long j, int i) { | ||||
|         CalendarItemStyle calendarItemStyle; | ||||
|         boolean z; | ||||
|         CalendarItemStyle calendarItemStyle2; | ||||
|         if (textView == null) { | ||||
|             return; | ||||
|         } | ||||
|         Context context = textView.getContext(); | ||||
|         String dayContentDescription = getDayContentDescription(context, j); | ||||
|         textView.setContentDescription(dayContentDescription); | ||||
|         boolean isValid = this.calendarConstraints.getDateValidator().isValid(j); | ||||
|         if (isValid) { | ||||
|             textView.setEnabled(true); | ||||
|             boolean isSelected = isSelected(j); | ||||
|             textView.setSelected(isSelected); | ||||
|             if (isSelected) { | ||||
|                 calendarItemStyle2 = this.calendarStyle.selectedDay; | ||||
|             } else if (isToday(j)) { | ||||
|                 calendarItemStyle2 = this.calendarStyle.todayDay; | ||||
|             } else { | ||||
|                 calendarItemStyle2 = this.calendarStyle.day; | ||||
|             } | ||||
|             calendarItemStyle = calendarItemStyle2; | ||||
|             z = isSelected; | ||||
|         } else { | ||||
|             textView.setEnabled(false); | ||||
|             calendarItemStyle = this.calendarStyle.invalidDay; | ||||
|             z = false; | ||||
|         } | ||||
|         if (this.dayViewDecorator != null && i != -1) { | ||||
|             int i2 = this.month.year; | ||||
|             int i3 = this.month.month; | ||||
|             ColorStateList backgroundColor = this.dayViewDecorator.getBackgroundColor(context, i2, i3, i, isValid, z); | ||||
|             boolean z2 = z; | ||||
|             calendarItemStyle.styleItem(textView, backgroundColor, this.dayViewDecorator.getTextColor(context, i2, i3, i, isValid, z2)); | ||||
|             Drawable compoundDrawableLeft = this.dayViewDecorator.getCompoundDrawableLeft(context, i2, i3, i, isValid, z2); | ||||
|             Drawable compoundDrawableTop = this.dayViewDecorator.getCompoundDrawableTop(context, i2, i3, i, isValid, z2); | ||||
|             Drawable compoundDrawableRight = this.dayViewDecorator.getCompoundDrawableRight(context, i2, i3, i, isValid, z2); | ||||
|             boolean z3 = z; | ||||
|             textView.setCompoundDrawables(compoundDrawableLeft, compoundDrawableTop, compoundDrawableRight, this.dayViewDecorator.getCompoundDrawableBottom(context, i2, i3, i, isValid, z3)); | ||||
|             textView.setContentDescription(this.dayViewDecorator.getContentDescription(context, i2, i3, i, isValid, z3, dayContentDescription)); | ||||
|             return; | ||||
|         } | ||||
|         calendarItemStyle.styleItem(textView); | ||||
|     } | ||||
|  | ||||
|     private String getDayContentDescription(Context context, long j) { | ||||
|         return DateStrings.getDayContentDescription(context, j, isToday(j), isStartOfRange(j), isEndOfRange(j)); | ||||
|     } | ||||
|  | ||||
|     private boolean isToday(long j) { | ||||
|         return UtcDates.getTodayCalendar().getTimeInMillis() == j; | ||||
|     } | ||||
|  | ||||
|     boolean isStartOfRange(long j) { | ||||
|         for (Pair<Long, Long> pair : this.dateSelector.getSelectedRanges()) { | ||||
|             if (pair.first != null && pair.first.longValue() == j) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     boolean isEndOfRange(long j) { | ||||
|         for (Pair<Long, Long> pair : this.dateSelector.getSelectedRanges()) { | ||||
|             if (pair.second != null && pair.second.longValue() == j) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     private boolean isSelected(long j) { | ||||
|         Iterator<Long> it = this.dateSelector.getSelectedDays().iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             if (UtcDates.canonicalYearMonthDay(j) == UtcDates.canonicalYearMonthDay(it.next().longValue())) { | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     private void initializeStyles(Context context) { | ||||
|         if (this.calendarStyle == null) { | ||||
|             this.calendarStyle = new CalendarStyle(context); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     int firstPositionInMonth() { | ||||
|         return this.month.daysFromStartOfWeekToFirstOfMonth(this.calendarConstraints.getFirstDayOfWeek()); | ||||
|     } | ||||
|  | ||||
|     int lastPositionInMonth() { | ||||
|         return (firstPositionInMonth() + this.month.daysInMonth) - 1; | ||||
|     } | ||||
|  | ||||
|     int positionToDay(int i) { | ||||
|         return (i - firstPositionInMonth()) + 1; | ||||
|     } | ||||
|  | ||||
|     int dayToPosition(int i) { | ||||
|         return firstPositionInMonth() + (i - 1); | ||||
|     } | ||||
|  | ||||
|     boolean withinMonth(int i) { | ||||
|         return i >= firstPositionInMonth() && i <= lastPositionInMonth(); | ||||
|     } | ||||
|  | ||||
|     boolean isFirstInRow(int i) { | ||||
|         return i % this.month.daysInWeek == 0; | ||||
|     } | ||||
|  | ||||
|     boolean isLastInRow(int i) { | ||||
|         return (i + 1) % this.month.daysInWeek == 0; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,113 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.AdapterView; | ||||
| import android.widget.LinearLayout; | ||||
| import android.widget.ListAdapter; | ||||
| import android.widget.TextView; | ||||
| import androidx.core.view.ViewCompat; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.datepicker.MaterialCalendar; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class MonthsPagerAdapter extends RecyclerView.Adapter<ViewHolder> { | ||||
|     private final CalendarConstraints calendarConstraints; | ||||
|     private final DateSelector<?> dateSelector; | ||||
|     private final DayViewDecorator dayViewDecorator; | ||||
|     private final int itemHeight; | ||||
|     private final MaterialCalendar.OnDayClickListener onDayClickListener; | ||||
|  | ||||
|     MonthsPagerAdapter(Context context, DateSelector<?> dateSelector, CalendarConstraints calendarConstraints, DayViewDecorator dayViewDecorator, MaterialCalendar.OnDayClickListener onDayClickListener) { | ||||
|         Month start = calendarConstraints.getStart(); | ||||
|         Month end = calendarConstraints.getEnd(); | ||||
|         Month openAt = calendarConstraints.getOpenAt(); | ||||
|         if (start.compareTo(openAt) > 0) { | ||||
|             throw new IllegalArgumentException("firstPage cannot be after currentPage"); | ||||
|         } | ||||
|         if (openAt.compareTo(end) > 0) { | ||||
|             throw new IllegalArgumentException("currentPage cannot be after lastPage"); | ||||
|         } | ||||
|         this.itemHeight = (MonthAdapter.MAXIMUM_WEEKS * MaterialCalendar.getDayHeight(context)) + (MaterialDatePicker.isFullscreen(context) ? MaterialCalendar.getDayHeight(context) : 0); | ||||
|         this.calendarConstraints = calendarConstraints; | ||||
|         this.dateSelector = dateSelector; | ||||
|         this.dayViewDecorator = dayViewDecorator; | ||||
|         this.onDayClickListener = onDayClickListener; | ||||
|         setHasStableIds(true); | ||||
|     } | ||||
|  | ||||
|     public static class ViewHolder extends RecyclerView.ViewHolder { | ||||
|         final MaterialCalendarGridView monthGrid; | ||||
|         final TextView monthTitle; | ||||
|  | ||||
|         ViewHolder(LinearLayout linearLayout, boolean z) { | ||||
|             super(linearLayout); | ||||
|             TextView textView = (TextView) linearLayout.findViewById(R.id.month_title); | ||||
|             this.monthTitle = textView; | ||||
|             ViewCompat.setAccessibilityHeading(textView, true); | ||||
|             this.monthGrid = (MaterialCalendarGridView) linearLayout.findViewById(R.id.month_grid); | ||||
|             if (z) { | ||||
|                 return; | ||||
|             } | ||||
|             textView.setVisibility(8); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { | ||||
|         LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mtrl_calendar_month_labeled, viewGroup, false); | ||||
|         if (MaterialDatePicker.isFullscreen(viewGroup.getContext())) { | ||||
|             linearLayout.setLayoutParams(new RecyclerView.LayoutParams(-1, this.itemHeight)); | ||||
|             return new ViewHolder(linearLayout, true); | ||||
|         } | ||||
|         return new ViewHolder(linearLayout, false); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public void onBindViewHolder(ViewHolder viewHolder, int i) { | ||||
|         Month monthsLater = this.calendarConstraints.getStart().monthsLater(i); | ||||
|         viewHolder.monthTitle.setText(monthsLater.getLongName()); | ||||
|         final MaterialCalendarGridView materialCalendarGridView = (MaterialCalendarGridView) viewHolder.monthGrid.findViewById(R.id.month_grid); | ||||
|         if (materialCalendarGridView.getAdapter() != null && monthsLater.equals(materialCalendarGridView.getAdapter().month)) { | ||||
|             materialCalendarGridView.invalidate(); | ||||
|             materialCalendarGridView.getAdapter().updateSelectedStates(materialCalendarGridView); | ||||
|         } else { | ||||
|             MonthAdapter monthAdapter = new MonthAdapter(monthsLater, this.dateSelector, this.calendarConstraints, this.dayViewDecorator); | ||||
|             materialCalendarGridView.setNumColumns(monthsLater.daysInWeek); | ||||
|             materialCalendarGridView.setAdapter((ListAdapter) monthAdapter); | ||||
|         } | ||||
|         materialCalendarGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { // from class: com.google.android.material.datepicker.MonthsPagerAdapter.1 | ||||
|             @Override // android.widget.AdapterView.OnItemClickListener | ||||
|             public void onItemClick(AdapterView<?> adapterView, View view, int i2, long j) { | ||||
|                 if (materialCalendarGridView.getAdapter().withinMonth(i2)) { | ||||
|                     MonthsPagerAdapter.this.onDayClickListener.onDayClick(materialCalendarGridView.getAdapter().getItem(i2).longValue()); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public long getItemId(int i) { | ||||
|         return this.calendarConstraints.getStart().monthsLater(i).getStableId(); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public int getItemCount() { | ||||
|         return this.calendarConstraints.getMonthSpan(); | ||||
|     } | ||||
|  | ||||
|     CharSequence getPageTitle(int i) { | ||||
|         return getPageMonth(i).getLongName(); | ||||
|     } | ||||
|  | ||||
|     Month getPageMonth(int i) { | ||||
|         return this.calendarConstraints.getStart().monthsLater(i); | ||||
|     } | ||||
|  | ||||
|     int getPosition(Month month) { | ||||
|         return this.calendarConstraints.getStart().monthsUntil(month); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,9 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public abstract class OnSelectionChangedListener<S> { | ||||
|     public void onIncompleteSelectionChanged() { | ||||
|     } | ||||
|  | ||||
|     public abstract void onSelectionChanged(S s); | ||||
| } | ||||
| @@ -0,0 +1,26 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import androidx.fragment.app.Fragment; | ||||
| import java.util.LinkedHashSet; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| abstract class PickerFragment<S> extends Fragment { | ||||
|     protected final LinkedHashSet<OnSelectionChangedListener<S>> onSelectionChangedListeners = new LinkedHashSet<>(); | ||||
|  | ||||
|     abstract DateSelector<S> getDateSelector(); | ||||
|  | ||||
|     PickerFragment() { | ||||
|     } | ||||
|  | ||||
|     boolean addOnSelectionChangedListener(OnSelectionChangedListener<S> onSelectionChangedListener) { | ||||
|         return this.onSelectionChangedListeners.add(onSelectionChangedListener); | ||||
|     } | ||||
|  | ||||
|     boolean removeOnSelectionChangedListener(OnSelectionChangedListener<S> onSelectionChangedListener) { | ||||
|         return this.onSelectionChangedListeners.remove(onSelectionChangedListener); | ||||
|     } | ||||
|  | ||||
|     void clearOnSelectionChangedListeners() { | ||||
|         this.onSelectionChangedListeners.clear(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,301 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.Resources; | ||||
| import android.os.Bundle; | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import android.text.TextUtils; | ||||
| import android.util.DisplayMetrics; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.EditText; | ||||
| import androidx.core.util.Pair; | ||||
| import androidx.core.util.Preconditions; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.datepicker.DateSelector; | ||||
| import com.google.android.material.internal.ManufacturerUtils; | ||||
| import com.google.android.material.resources.MaterialAttributes; | ||||
| import com.google.android.material.textfield.TextInputLayout; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class RangeDateSelector implements DateSelector<Pair<Long, Long>> { | ||||
|     public static final Parcelable.Creator<RangeDateSelector> CREATOR = new Parcelable.Creator<RangeDateSelector>() { // from class: com.google.android.material.datepicker.RangeDateSelector.3 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public RangeDateSelector createFromParcel(Parcel parcel) { | ||||
|             RangeDateSelector rangeDateSelector = new RangeDateSelector(); | ||||
|             rangeDateSelector.selectedStartItem = (Long) parcel.readValue(Long.class.getClassLoader()); | ||||
|             rangeDateSelector.selectedEndItem = (Long) parcel.readValue(Long.class.getClassLoader()); | ||||
|             return rangeDateSelector; | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public RangeDateSelector[] newArray(int i) { | ||||
|             return new RangeDateSelector[i]; | ||||
|         } | ||||
|     }; | ||||
|     private CharSequence error; | ||||
|     private String invalidRangeStartError; | ||||
|     private SimpleDateFormat textInputFormat; | ||||
|     private final String invalidRangeEndError = " "; | ||||
|     private Long selectedStartItem = null; | ||||
|     private Long selectedEndItem = null; | ||||
|     private Long proposedTextStart = null; | ||||
|     private Long proposedTextEnd = null; | ||||
|  | ||||
|     private boolean isValidRange(long j, long j2) { | ||||
|         return j <= j2; | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public void select(long j) { | ||||
|         Long l = this.selectedStartItem; | ||||
|         if (l == null) { | ||||
|             this.selectedStartItem = Long.valueOf(j); | ||||
|         } else if (this.selectedEndItem == null && isValidRange(l.longValue(), j)) { | ||||
|             this.selectedEndItem = Long.valueOf(j); | ||||
|         } else { | ||||
|             this.selectedEndItem = null; | ||||
|             this.selectedStartItem = Long.valueOf(j); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public boolean isSelectionComplete() { | ||||
|         Long l = this.selectedStartItem; | ||||
|         return (l == null || this.selectedEndItem == null || !isValidRange(l.longValue(), this.selectedEndItem.longValue())) ? false : true; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public void setSelection(Pair<Long, Long> pair) { | ||||
|         if (pair.first != null && pair.second != null) { | ||||
|             Preconditions.checkArgument(isValidRange(pair.first.longValue(), pair.second.longValue())); | ||||
|         } | ||||
|         this.selectedStartItem = pair.first == null ? null : Long.valueOf(UtcDates.canonicalYearMonthDay(pair.first.longValue())); | ||||
|         this.selectedEndItem = pair.second != null ? Long.valueOf(UtcDates.canonicalYearMonthDay(pair.second.longValue())) : null; | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Can't rename method to resolve collision */ | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public Pair<Long, Long> getSelection() { | ||||
|         return new Pair<>(this.selectedStartItem, this.selectedEndItem); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public Collection<Pair<Long, Long>> getSelectedRanges() { | ||||
|         ArrayList arrayList = new ArrayList(); | ||||
|         arrayList.add(new Pair(this.selectedStartItem, this.selectedEndItem)); | ||||
|         return arrayList; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public Collection<Long> getSelectedDays() { | ||||
|         ArrayList arrayList = new ArrayList(); | ||||
|         Long l = this.selectedStartItem; | ||||
|         if (l != null) { | ||||
|             arrayList.add(l); | ||||
|         } | ||||
|         Long l2 = this.selectedEndItem; | ||||
|         if (l2 != null) { | ||||
|             arrayList.add(l2); | ||||
|         } | ||||
|         return arrayList; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public int getDefaultThemeResId(Context context) { | ||||
|         int i; | ||||
|         Resources resources = context.getResources(); | ||||
|         DisplayMetrics displayMetrics = resources.getDisplayMetrics(); | ||||
|         if (Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels) > resources.getDimensionPixelSize(R.dimen.mtrl_calendar_maximum_default_fullscreen_minor_axis)) { | ||||
|             i = R.attr.materialCalendarTheme; | ||||
|         } else { | ||||
|             i = R.attr.materialCalendarFullscreenTheme; | ||||
|         } | ||||
|         return MaterialAttributes.resolveOrThrow(context, i, MaterialDatePicker.class.getCanonicalName()); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public String getSelectionDisplayString(Context context) { | ||||
|         Resources resources = context.getResources(); | ||||
|         Long l = this.selectedStartItem; | ||||
|         if (l == null && this.selectedEndItem == null) { | ||||
|             return resources.getString(R.string.mtrl_picker_range_header_unselected); | ||||
|         } | ||||
|         Long l2 = this.selectedEndItem; | ||||
|         if (l2 == null) { | ||||
|             return resources.getString(R.string.mtrl_picker_range_header_only_start_selected, DateStrings.getDateString(this.selectedStartItem.longValue())); | ||||
|         } | ||||
|         if (l == null) { | ||||
|             return resources.getString(R.string.mtrl_picker_range_header_only_end_selected, DateStrings.getDateString(this.selectedEndItem.longValue())); | ||||
|         } | ||||
|         Pair<String, String> dateRangeString = DateStrings.getDateRangeString(l, l2); | ||||
|         return resources.getString(R.string.mtrl_picker_range_header_selected, dateRangeString.first, dateRangeString.second); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public String getSelectionContentDescription(Context context) { | ||||
|         String str; | ||||
|         String str2; | ||||
|         Resources resources = context.getResources(); | ||||
|         Pair<String, String> dateRangeString = DateStrings.getDateRangeString(this.selectedStartItem, this.selectedEndItem); | ||||
|         if (dateRangeString.first == null) { | ||||
|             str = resources.getString(R.string.mtrl_picker_announce_current_selection_none); | ||||
|         } else { | ||||
|             str = dateRangeString.first; | ||||
|         } | ||||
|         if (dateRangeString.second == null) { | ||||
|             str2 = resources.getString(R.string.mtrl_picker_announce_current_selection_none); | ||||
|         } else { | ||||
|             str2 = dateRangeString.second; | ||||
|         } | ||||
|         return resources.getString(R.string.mtrl_picker_announce_current_range_selection, str, str2); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public String getError() { | ||||
|         if (TextUtils.isEmpty(this.error)) { | ||||
|             return null; | ||||
|         } | ||||
|         return this.error.toString(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public int getDefaultTitleResId() { | ||||
|         return R.string.mtrl_picker_range_header_title; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public void setTextInputFormat(SimpleDateFormat simpleDateFormat) { | ||||
|         if (simpleDateFormat != null) { | ||||
|             simpleDateFormat = (SimpleDateFormat) UtcDates.getNormalizedFormat(simpleDateFormat); | ||||
|         } | ||||
|         this.textInputFormat = simpleDateFormat; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public View onCreateTextInputView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle, CalendarConstraints calendarConstraints, final OnSelectionChangedListener<Pair<Long, Long>> onSelectionChangedListener) { | ||||
|         String defaultTextInputHint; | ||||
|         View inflate = layoutInflater.inflate(R.layout.mtrl_picker_text_input_date_range, viewGroup, false); | ||||
|         final TextInputLayout textInputLayout = (TextInputLayout) inflate.findViewById(R.id.mtrl_picker_text_input_range_start); | ||||
|         final TextInputLayout textInputLayout2 = (TextInputLayout) inflate.findViewById(R.id.mtrl_picker_text_input_range_end); | ||||
|         EditText editText = textInputLayout.getEditText(); | ||||
|         EditText editText2 = textInputLayout2.getEditText(); | ||||
|         if (ManufacturerUtils.isDateInputKeyboardMissingSeparatorCharacters()) { | ||||
|             editText.setInputType(17); | ||||
|             editText2.setInputType(17); | ||||
|         } | ||||
|         this.invalidRangeStartError = inflate.getResources().getString(R.string.mtrl_picker_invalid_range); | ||||
|         SimpleDateFormat simpleDateFormat = this.textInputFormat; | ||||
|         boolean z = simpleDateFormat != null; | ||||
|         if (!z) { | ||||
|             simpleDateFormat = UtcDates.getDefaultTextInputFormat(); | ||||
|         } | ||||
|         SimpleDateFormat simpleDateFormat2 = simpleDateFormat; | ||||
|         Long l = this.selectedStartItem; | ||||
|         if (l != null) { | ||||
|             editText.setText(simpleDateFormat2.format(l)); | ||||
|             this.proposedTextStart = this.selectedStartItem; | ||||
|         } | ||||
|         Long l2 = this.selectedEndItem; | ||||
|         if (l2 != null) { | ||||
|             editText2.setText(simpleDateFormat2.format(l2)); | ||||
|             this.proposedTextEnd = this.selectedEndItem; | ||||
|         } | ||||
|         if (z) { | ||||
|             defaultTextInputHint = simpleDateFormat2.toPattern(); | ||||
|         } else { | ||||
|             defaultTextInputHint = UtcDates.getDefaultTextInputHint(inflate.getResources(), simpleDateFormat2); | ||||
|         } | ||||
|         String str = defaultTextInputHint; | ||||
|         textInputLayout.setPlaceholderText(str); | ||||
|         textInputLayout2.setPlaceholderText(str); | ||||
|         editText.addTextChangedListener(new DateFormatTextWatcher(str, simpleDateFormat2, textInputLayout, calendarConstraints) { // from class: com.google.android.material.datepicker.RangeDateSelector.1 | ||||
|             @Override // com.google.android.material.datepicker.DateFormatTextWatcher | ||||
|             void onValidDate(Long l3) { | ||||
|                 RangeDateSelector.this.proposedTextStart = l3; | ||||
|                 RangeDateSelector.this.updateIfValidTextProposal(textInputLayout, textInputLayout2, onSelectionChangedListener); | ||||
|             } | ||||
|  | ||||
|             @Override // com.google.android.material.datepicker.DateFormatTextWatcher | ||||
|             void onInvalidDate() { | ||||
|                 RangeDateSelector.this.proposedTextStart = null; | ||||
|                 RangeDateSelector.this.updateIfValidTextProposal(textInputLayout, textInputLayout2, onSelectionChangedListener); | ||||
|             } | ||||
|         }); | ||||
|         editText2.addTextChangedListener(new DateFormatTextWatcher(str, simpleDateFormat2, textInputLayout2, calendarConstraints) { // from class: com.google.android.material.datepicker.RangeDateSelector.2 | ||||
|             @Override // com.google.android.material.datepicker.DateFormatTextWatcher | ||||
|             void onValidDate(Long l3) { | ||||
|                 RangeDateSelector.this.proposedTextEnd = l3; | ||||
|                 RangeDateSelector.this.updateIfValidTextProposal(textInputLayout, textInputLayout2, onSelectionChangedListener); | ||||
|             } | ||||
|  | ||||
|             @Override // com.google.android.material.datepicker.DateFormatTextWatcher | ||||
|             void onInvalidDate() { | ||||
|                 RangeDateSelector.this.proposedTextEnd = null; | ||||
|                 RangeDateSelector.this.updateIfValidTextProposal(textInputLayout, textInputLayout2, onSelectionChangedListener); | ||||
|             } | ||||
|         }); | ||||
|         DateSelector.CC.showKeyboardWithAutoHideBehavior(editText, editText2); | ||||
|         return inflate; | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public void updateIfValidTextProposal(TextInputLayout textInputLayout, TextInputLayout textInputLayout2, OnSelectionChangedListener<Pair<Long, Long>> onSelectionChangedListener) { | ||||
|         Long l = this.proposedTextStart; | ||||
|         if (l == null || this.proposedTextEnd == null) { | ||||
|             clearInvalidRange(textInputLayout, textInputLayout2); | ||||
|             onSelectionChangedListener.onIncompleteSelectionChanged(); | ||||
|         } else if (isValidRange(l.longValue(), this.proposedTextEnd.longValue())) { | ||||
|             this.selectedStartItem = this.proposedTextStart; | ||||
|             this.selectedEndItem = this.proposedTextEnd; | ||||
|             onSelectionChangedListener.onSelectionChanged(getSelection()); | ||||
|         } else { | ||||
|             setInvalidRange(textInputLayout, textInputLayout2); | ||||
|             onSelectionChangedListener.onIncompleteSelectionChanged(); | ||||
|         } | ||||
|         updateError(textInputLayout, textInputLayout2); | ||||
|     } | ||||
|  | ||||
|     private void updateError(TextInputLayout textInputLayout, TextInputLayout textInputLayout2) { | ||||
|         if (!TextUtils.isEmpty(textInputLayout.getError())) { | ||||
|             this.error = textInputLayout.getError(); | ||||
|         } else if (TextUtils.isEmpty(textInputLayout2.getError())) { | ||||
|             this.error = null; | ||||
|         } else { | ||||
|             this.error = textInputLayout2.getError(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void clearInvalidRange(TextInputLayout textInputLayout, TextInputLayout textInputLayout2) { | ||||
|         if (textInputLayout.getError() != null && this.invalidRangeStartError.contentEquals(textInputLayout.getError())) { | ||||
|             textInputLayout.setError(null); | ||||
|         } | ||||
|         if (textInputLayout2.getError() == null || !" ".contentEquals(textInputLayout2.getError())) { | ||||
|             return; | ||||
|         } | ||||
|         textInputLayout2.setError(null); | ||||
|     } | ||||
|  | ||||
|     private void setInvalidRange(TextInputLayout textInputLayout, TextInputLayout textInputLayout2) { | ||||
|         textInputLayout.setError(this.invalidRangeStartError); | ||||
|         textInputLayout2.setError(" "); | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeValue(this.selectedStartItem); | ||||
|         parcel.writeValue(this.selectedEndItem); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,191 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.res.Resources; | ||||
| import android.os.Bundle; | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import android.text.TextUtils; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.EditText; | ||||
| import androidx.core.util.Pair; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.datepicker.DateSelector; | ||||
| import com.google.android.material.internal.ManufacturerUtils; | ||||
| import com.google.android.material.resources.MaterialAttributes; | ||||
| import com.google.android.material.textfield.TextInputLayout; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public class SingleDateSelector implements DateSelector<Long> { | ||||
|     public static final Parcelable.Creator<SingleDateSelector> CREATOR = new Parcelable.Creator<SingleDateSelector>() { // from class: com.google.android.material.datepicker.SingleDateSelector.2 | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public SingleDateSelector createFromParcel(Parcel parcel) { | ||||
|             SingleDateSelector singleDateSelector = new SingleDateSelector(); | ||||
|             singleDateSelector.selectedItem = (Long) parcel.readValue(Long.class.getClassLoader()); | ||||
|             return singleDateSelector; | ||||
|         } | ||||
|  | ||||
|         /* JADX WARN: Can't rename method to resolve collision */ | ||||
|         @Override // android.os.Parcelable.Creator | ||||
|         public SingleDateSelector[] newArray(int i) { | ||||
|             return new SingleDateSelector[i]; | ||||
|         } | ||||
|     }; | ||||
|     private CharSequence error; | ||||
|     private Long selectedItem; | ||||
|     private SimpleDateFormat textInputFormat; | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public void clearSelection() { | ||||
|         this.selectedItem = null; | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public int describeContents() { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     /* JADX WARN: Can't rename method to resolve collision */ | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public Long getSelection() { | ||||
|         return this.selectedItem; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public boolean isSelectionComplete() { | ||||
|         return this.selectedItem != null; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public void select(long j) { | ||||
|         this.selectedItem = Long.valueOf(j); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public void setSelection(Long l) { | ||||
|         this.selectedItem = l == null ? null : Long.valueOf(UtcDates.canonicalYearMonthDay(l.longValue())); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public Collection<Pair<Long, Long>> getSelectedRanges() { | ||||
|         return new ArrayList(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public Collection<Long> getSelectedDays() { | ||||
|         ArrayList arrayList = new ArrayList(); | ||||
|         Long l = this.selectedItem; | ||||
|         if (l != null) { | ||||
|             arrayList.add(l); | ||||
|         } | ||||
|         return arrayList; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public void setTextInputFormat(SimpleDateFormat simpleDateFormat) { | ||||
|         if (simpleDateFormat != null) { | ||||
|             simpleDateFormat = (SimpleDateFormat) UtcDates.getNormalizedFormat(simpleDateFormat); | ||||
|         } | ||||
|         this.textInputFormat = simpleDateFormat; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public View onCreateTextInputView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle, CalendarConstraints calendarConstraints, final OnSelectionChangedListener<Long> onSelectionChangedListener) { | ||||
|         String defaultTextInputHint; | ||||
|         View inflate = layoutInflater.inflate(R.layout.mtrl_picker_text_input_date, viewGroup, false); | ||||
|         final TextInputLayout textInputLayout = (TextInputLayout) inflate.findViewById(R.id.mtrl_picker_text_input_date); | ||||
|         EditText editText = textInputLayout.getEditText(); | ||||
|         if (ManufacturerUtils.isDateInputKeyboardMissingSeparatorCharacters()) { | ||||
|             editText.setInputType(17); | ||||
|         } | ||||
|         SimpleDateFormat simpleDateFormat = this.textInputFormat; | ||||
|         boolean z = simpleDateFormat != null; | ||||
|         if (!z) { | ||||
|             simpleDateFormat = UtcDates.getDefaultTextInputFormat(); | ||||
|         } | ||||
|         SimpleDateFormat simpleDateFormat2 = simpleDateFormat; | ||||
|         if (z) { | ||||
|             defaultTextInputHint = simpleDateFormat2.toPattern(); | ||||
|         } else { | ||||
|             defaultTextInputHint = UtcDates.getDefaultTextInputHint(inflate.getResources(), simpleDateFormat2); | ||||
|         } | ||||
|         String str = defaultTextInputHint; | ||||
|         textInputLayout.setPlaceholderText(str); | ||||
|         Long l = this.selectedItem; | ||||
|         if (l != null) { | ||||
|             editText.setText(simpleDateFormat2.format(l)); | ||||
|         } | ||||
|         editText.addTextChangedListener(new DateFormatTextWatcher(str, simpleDateFormat2, textInputLayout, calendarConstraints) { // from class: com.google.android.material.datepicker.SingleDateSelector.1 | ||||
|             @Override // com.google.android.material.datepicker.DateFormatTextWatcher | ||||
|             void onValidDate(Long l2) { | ||||
|                 if (l2 == null) { | ||||
|                     SingleDateSelector.this.clearSelection(); | ||||
|                 } else { | ||||
|                     SingleDateSelector.this.select(l2.longValue()); | ||||
|                 } | ||||
|                 SingleDateSelector.this.error = null; | ||||
|                 onSelectionChangedListener.onSelectionChanged(SingleDateSelector.this.getSelection()); | ||||
|             } | ||||
|  | ||||
|             @Override // com.google.android.material.datepicker.DateFormatTextWatcher | ||||
|             void onInvalidDate() { | ||||
|                 SingleDateSelector.this.error = textInputLayout.getError(); | ||||
|                 onSelectionChangedListener.onIncompleteSelectionChanged(); | ||||
|             } | ||||
|         }); | ||||
|         DateSelector.CC.showKeyboardWithAutoHideBehavior(editText); | ||||
|         return inflate; | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public int getDefaultThemeResId(Context context) { | ||||
|         return MaterialAttributes.resolveOrThrow(context, R.attr.materialCalendarTheme, MaterialDatePicker.class.getCanonicalName()); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public String getSelectionDisplayString(Context context) { | ||||
|         Resources resources = context.getResources(); | ||||
|         Long l = this.selectedItem; | ||||
|         if (l == null) { | ||||
|             return resources.getString(R.string.mtrl_picker_date_header_unselected); | ||||
|         } | ||||
|         return resources.getString(R.string.mtrl_picker_date_header_selected, DateStrings.getYearMonthDay(l.longValue())); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public String getSelectionContentDescription(Context context) { | ||||
|         String yearMonthDay; | ||||
|         Resources resources = context.getResources(); | ||||
|         Long l = this.selectedItem; | ||||
|         if (l == null) { | ||||
|             yearMonthDay = resources.getString(R.string.mtrl_picker_announce_current_selection_none); | ||||
|         } else { | ||||
|             yearMonthDay = DateStrings.getYearMonthDay(l.longValue()); | ||||
|         } | ||||
|         return resources.getString(R.string.mtrl_picker_announce_current_selection, yearMonthDay); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public String getError() { | ||||
|         if (TextUtils.isEmpty(this.error)) { | ||||
|             return null; | ||||
|         } | ||||
|         return this.error.toString(); | ||||
|     } | ||||
|  | ||||
|     @Override // com.google.android.material.datepicker.DateSelector | ||||
|     public int getDefaultTitleResId() { | ||||
|         return R.string.mtrl_picker_date_header_title; | ||||
|     } | ||||
|  | ||||
|     @Override // android.os.Parcelable | ||||
|     public void writeToParcel(Parcel parcel, int i) { | ||||
|         parcel.writeValue(this.selectedItem); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,28 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.util.DisplayMetrics; | ||||
| import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.LinearSmoothScroller; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class SmoothCalendarLayoutManager extends LinearLayoutManager { | ||||
|     private static final float MILLISECONDS_PER_INCH = 100.0f; | ||||
|  | ||||
|     SmoothCalendarLayoutManager(Context context, int i, boolean z) { | ||||
|         super(context, i, z); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager | ||||
|     public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int i) { | ||||
|         LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext()) { // from class: com.google.android.material.datepicker.SmoothCalendarLayoutManager.1 | ||||
|             @Override // androidx.recyclerview.widget.LinearSmoothScroller | ||||
|             protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) { | ||||
|                 return SmoothCalendarLayoutManager.MILLISECONDS_PER_INCH / displayMetrics.densityDpi; | ||||
|             } | ||||
|         }; | ||||
|         linearSmoothScroller.setTargetPosition(i); | ||||
|         startSmoothScroll(linearSmoothScroller); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,41 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import java.util.Calendar; | ||||
| import java.util.TimeZone; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class TimeSource { | ||||
|     private static final TimeSource SYSTEM_TIME_SOURCE = new TimeSource(null, null); | ||||
|     private final Long fixedTimeMs; | ||||
|     private final TimeZone fixedTimeZone; | ||||
|  | ||||
|     static TimeSource system() { | ||||
|         return SYSTEM_TIME_SOURCE; | ||||
|     } | ||||
|  | ||||
|     private TimeSource(Long l, TimeZone timeZone) { | ||||
|         this.fixedTimeMs = l; | ||||
|         this.fixedTimeZone = timeZone; | ||||
|     } | ||||
|  | ||||
|     static TimeSource fixed(long j, TimeZone timeZone) { | ||||
|         return new TimeSource(Long.valueOf(j), timeZone); | ||||
|     } | ||||
|  | ||||
|     static TimeSource fixed(long j) { | ||||
|         return new TimeSource(Long.valueOf(j), null); | ||||
|     } | ||||
|  | ||||
|     Calendar now() { | ||||
|         return now(this.fixedTimeZone); | ||||
|     } | ||||
|  | ||||
|     Calendar now(TimeZone timeZone) { | ||||
|         Calendar calendar = timeZone == null ? Calendar.getInstance() : Calendar.getInstance(timeZone); | ||||
|         Long l = this.fixedTimeMs; | ||||
|         if (l != null) { | ||||
|             calendar.setTimeInMillis(l.longValue()); | ||||
|         } | ||||
|         return calendar; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,199 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.content.res.Resources; | ||||
| import android.icu.text.DateFormat; | ||||
| import android.icu.text.DisplayContext; | ||||
| import com.google.android.material.R; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Calendar; | ||||
| import java.util.Locale; | ||||
| import java.util.TimeZone; | ||||
| import java.util.concurrent.atomic.AtomicReference; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class UtcDates { | ||||
|     static final String UTC = "UTC"; | ||||
|     static AtomicReference<TimeSource> timeSourceRef = new AtomicReference<>(); | ||||
|  | ||||
|     static void setTimeSource(TimeSource timeSource) { | ||||
|         timeSourceRef.set(timeSource); | ||||
|     } | ||||
|  | ||||
|     static TimeSource getTimeSource() { | ||||
|         TimeSource timeSource = timeSourceRef.get(); | ||||
|         return timeSource == null ? TimeSource.system() : timeSource; | ||||
|     } | ||||
|  | ||||
|     private UtcDates() { | ||||
|     } | ||||
|  | ||||
|     private static TimeZone getTimeZone() { | ||||
|         return TimeZone.getTimeZone(UTC); | ||||
|     } | ||||
|  | ||||
|     private static android.icu.util.TimeZone getUtcAndroidTimeZone() { | ||||
|         android.icu.util.TimeZone timeZone; | ||||
|         timeZone = android.icu.util.TimeZone.getTimeZone(UTC); | ||||
|         return timeZone; | ||||
|     } | ||||
|  | ||||
|     static Calendar getTodayCalendar() { | ||||
|         Calendar now = getTimeSource().now(); | ||||
|         now.set(11, 0); | ||||
|         now.set(12, 0); | ||||
|         now.set(13, 0); | ||||
|         now.set(14, 0); | ||||
|         now.setTimeZone(getTimeZone()); | ||||
|         return now; | ||||
|     } | ||||
|  | ||||
|     static Calendar getUtcCalendar() { | ||||
|         return getUtcCalendarOf(null); | ||||
|     } | ||||
|  | ||||
|     static Calendar getUtcCalendarOf(Calendar calendar) { | ||||
|         Calendar calendar2 = Calendar.getInstance(getTimeZone()); | ||||
|         if (calendar == null) { | ||||
|             calendar2.clear(); | ||||
|         } else { | ||||
|             calendar2.setTimeInMillis(calendar.getTimeInMillis()); | ||||
|         } | ||||
|         return calendar2; | ||||
|     } | ||||
|  | ||||
|     static Calendar getDayCopy(Calendar calendar) { | ||||
|         Calendar utcCalendarOf = getUtcCalendarOf(calendar); | ||||
|         Calendar utcCalendar = getUtcCalendar(); | ||||
|         utcCalendar.set(utcCalendarOf.get(1), utcCalendarOf.get(2), utcCalendarOf.get(5)); | ||||
|         return utcCalendar; | ||||
|     } | ||||
|  | ||||
|     static long canonicalYearMonthDay(long j) { | ||||
|         Calendar utcCalendar = getUtcCalendar(); | ||||
|         utcCalendar.setTimeInMillis(j); | ||||
|         return getDayCopy(utcCalendar).getTimeInMillis(); | ||||
|     } | ||||
|  | ||||
|     private static DateFormat getAndroidFormat(String str, Locale locale) { | ||||
|         DateFormat instanceForSkeleton; | ||||
|         DisplayContext displayContext; | ||||
|         instanceForSkeleton = DateFormat.getInstanceForSkeleton(str, locale); | ||||
|         instanceForSkeleton.setTimeZone(getUtcAndroidTimeZone()); | ||||
|         displayContext = DisplayContext.CAPITALIZATION_FOR_STANDALONE; | ||||
|         instanceForSkeleton.setContext(displayContext); | ||||
|         return instanceForSkeleton; | ||||
|     } | ||||
|  | ||||
|     private static java.text.DateFormat getFormat(int i, Locale locale) { | ||||
|         java.text.DateFormat dateInstance = java.text.DateFormat.getDateInstance(i, locale); | ||||
|         dateInstance.setTimeZone(getTimeZone()); | ||||
|         return dateInstance; | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getNormalizedFormat(java.text.DateFormat dateFormat) { | ||||
|         java.text.DateFormat dateFormat2 = (java.text.DateFormat) dateFormat.clone(); | ||||
|         dateFormat2.setTimeZone(getTimeZone()); | ||||
|         return dateFormat2; | ||||
|     } | ||||
|  | ||||
|     static SimpleDateFormat getDefaultTextInputFormat() { | ||||
|         SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getDatePatternAsInputFormat(((SimpleDateFormat) java.text.DateFormat.getDateInstance(3, Locale.getDefault())).toPattern()), Locale.getDefault()); | ||||
|         simpleDateFormat.setTimeZone(getTimeZone()); | ||||
|         simpleDateFormat.setLenient(false); | ||||
|         return simpleDateFormat; | ||||
|     } | ||||
|  | ||||
|     static String getDefaultTextInputHint(Resources resources, SimpleDateFormat simpleDateFormat) { | ||||
|         String pattern = simpleDateFormat.toPattern(); | ||||
|         String string = resources.getString(R.string.mtrl_picker_text_input_year_abbr); | ||||
|         String string2 = resources.getString(R.string.mtrl_picker_text_input_month_abbr); | ||||
|         String string3 = resources.getString(R.string.mtrl_picker_text_input_day_abbr); | ||||
|         if (Locale.getDefault().getLanguage().equals(Locale.KOREAN.getLanguage())) { | ||||
|             pattern = pattern.replaceAll("d+", "d").replaceAll("M+", "M").replaceAll("y+", "y"); | ||||
|         } | ||||
|         return pattern.replace("d", string3).replace("M", string2).replace("y", string); | ||||
|     } | ||||
|  | ||||
|     static String getDatePatternAsInputFormat(String str) { | ||||
|         return str.replaceAll("[^dMy/\\-.]", "").replaceAll("d{1,2}", "dd").replaceAll("M{1,2}", "MM").replaceAll("y{1,4}", "yyyy").replaceAll("\\.$", "").replaceAll("My", "M/y"); | ||||
|     } | ||||
|  | ||||
|     static SimpleDateFormat getSimpleFormat(String str) { | ||||
|         return getSimpleFormat(str, Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     private static SimpleDateFormat getSimpleFormat(String str, Locale locale) { | ||||
|         SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str, locale); | ||||
|         simpleDateFormat.setTimeZone(getTimeZone()); | ||||
|         return simpleDateFormat; | ||||
|     } | ||||
|  | ||||
|     static DateFormat getYearMonthFormat(Locale locale) { | ||||
|         return getAndroidFormat("yMMMM", locale); | ||||
|     } | ||||
|  | ||||
|     static DateFormat getYearAbbrMonthDayFormat(Locale locale) { | ||||
|         return getAndroidFormat("yMMMd", locale); | ||||
|     } | ||||
|  | ||||
|     static DateFormat getAbbrMonthDayFormat(Locale locale) { | ||||
|         return getAndroidFormat("MMMd", locale); | ||||
|     } | ||||
|  | ||||
|     static DateFormat getMonthWeekdayDayFormat(Locale locale) { | ||||
|         return getAndroidFormat("MMMMEEEEd", locale); | ||||
|     } | ||||
|  | ||||
|     static DateFormat getYearMonthWeekdayDayFormat(Locale locale) { | ||||
|         return getAndroidFormat("yMMMMEEEEd", locale); | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getMediumFormat() { | ||||
|         return getMediumFormat(Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getMediumFormat(Locale locale) { | ||||
|         return getFormat(2, locale); | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getMediumNoYear() { | ||||
|         return getMediumNoYear(Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getMediumNoYear(Locale locale) { | ||||
|         SimpleDateFormat simpleDateFormat = (SimpleDateFormat) getMediumFormat(locale); | ||||
|         simpleDateFormat.applyPattern(removeYearFromDateFormatPattern(simpleDateFormat.toPattern())); | ||||
|         return simpleDateFormat; | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getFullFormat() { | ||||
|         return getFullFormat(Locale.getDefault()); | ||||
|     } | ||||
|  | ||||
|     static java.text.DateFormat getFullFormat(Locale locale) { | ||||
|         return getFormat(0, locale); | ||||
|     } | ||||
|  | ||||
|     private static String removeYearFromDateFormatPattern(String str) { | ||||
|         int findCharactersInDateFormatPattern = findCharactersInDateFormatPattern(str, "yY", 1, 0); | ||||
|         if (findCharactersInDateFormatPattern >= str.length()) { | ||||
|             return str; | ||||
|         } | ||||
|         int findCharactersInDateFormatPattern2 = findCharactersInDateFormatPattern(str, "EMd", 1, findCharactersInDateFormatPattern); | ||||
|         return str.replace(str.substring(findCharactersInDateFormatPattern(str, findCharactersInDateFormatPattern2 < str.length() ? "EMd," : "EMd", -1, findCharactersInDateFormatPattern) + 1, findCharactersInDateFormatPattern2), " ").trim(); | ||||
|     } | ||||
|  | ||||
|     private static int findCharactersInDateFormatPattern(String str, String str2, int i, int i2) { | ||||
|         while (i2 >= 0 && i2 < str.length() && str2.indexOf(str.charAt(i2)) == -1) { | ||||
|             if (str.charAt(i2) == '\'') { | ||||
|                 do { | ||||
|                     i2 += i; | ||||
|                     if (i2 >= 0 && i2 < str.length()) { | ||||
|                     } | ||||
|                 } while (str.charAt(i2) != '\''); | ||||
|             } | ||||
|             i2 += i; | ||||
|         } | ||||
|         return i2; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,78 @@ | ||||
| package com.google.android.material.datepicker; | ||||
|  | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.TextView; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
| import com.google.android.material.R; | ||||
| import com.google.android.material.datepicker.MaterialCalendar; | ||||
| import com.google.android.material.timepicker.TimeModel; | ||||
| import java.util.Calendar; | ||||
| import java.util.Iterator; | ||||
| import java.util.Locale; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| class YearGridAdapter extends RecyclerView.Adapter<ViewHolder> { | ||||
|     private final MaterialCalendar<?> materialCalendar; | ||||
|  | ||||
|     public static class ViewHolder extends RecyclerView.ViewHolder { | ||||
|         final TextView textView; | ||||
|  | ||||
|         ViewHolder(TextView textView) { | ||||
|             super(textView); | ||||
|             this.textView = textView; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     YearGridAdapter(MaterialCalendar<?> materialCalendar) { | ||||
|         this.materialCalendar = materialCalendar; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { | ||||
|         return new ViewHolder((TextView) LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mtrl_calendar_year, viewGroup, false)); | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public void onBindViewHolder(ViewHolder viewHolder, int i) { | ||||
|         int yearForPosition = getYearForPosition(i); | ||||
|         viewHolder.textView.setText(String.format(Locale.getDefault(), TimeModel.NUMBER_FORMAT, Integer.valueOf(yearForPosition))); | ||||
|         viewHolder.textView.setContentDescription(DateStrings.getYearContentDescription(viewHolder.textView.getContext(), yearForPosition)); | ||||
|         CalendarStyle calendarStyle = this.materialCalendar.getCalendarStyle(); | ||||
|         Calendar todayCalendar = UtcDates.getTodayCalendar(); | ||||
|         CalendarItemStyle calendarItemStyle = todayCalendar.get(1) == yearForPosition ? calendarStyle.todayYear : calendarStyle.year; | ||||
|         Iterator<Long> it = this.materialCalendar.getDateSelector().getSelectedDays().iterator(); | ||||
|         while (it.hasNext()) { | ||||
|             todayCalendar.setTimeInMillis(it.next().longValue()); | ||||
|             if (todayCalendar.get(1) == yearForPosition) { | ||||
|                 calendarItemStyle = calendarStyle.selectedYear; | ||||
|             } | ||||
|         } | ||||
|         calendarItemStyle.styleItem(viewHolder.textView); | ||||
|         viewHolder.textView.setOnClickListener(createYearClickListener(yearForPosition)); | ||||
|     } | ||||
|  | ||||
|     private View.OnClickListener createYearClickListener(final int i) { | ||||
|         return new View.OnClickListener() { // from class: com.google.android.material.datepicker.YearGridAdapter.1 | ||||
|             @Override // android.view.View.OnClickListener | ||||
|             public void onClick(View view) { | ||||
|                 YearGridAdapter.this.materialCalendar.setCurrentMonth(YearGridAdapter.this.materialCalendar.getCalendarConstraints().clamp(Month.create(i, YearGridAdapter.this.materialCalendar.getCurrentMonth().month))); | ||||
|                 YearGridAdapter.this.materialCalendar.setSelector(MaterialCalendar.CalendarSelector.DAY); | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     @Override // androidx.recyclerview.widget.RecyclerView.Adapter | ||||
|     public int getItemCount() { | ||||
|         return this.materialCalendar.getCalendarConstraints().getYearSpan(); | ||||
|     } | ||||
|  | ||||
|     int getPositionForYear(int i) { | ||||
|         return i - this.materialCalendar.getCalendarConstraints().getStart().year; | ||||
|     } | ||||
|  | ||||
|     int getYearForPosition(int i) { | ||||
|         return this.materialCalendar.getCalendarConstraints().getStart().year + i; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user