ADD week 5

This commit is contained in:
2025-03-31 16:33:42 +02:00
parent 86f265f22d
commit bf645048e6
4927 changed files with 544053 additions and 0 deletions

View File

@ -0,0 +1,175 @@
package com.google.android.material.timepicker;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.os.LocaleList;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.R;
import com.google.android.material.chip.Chip;
import com.google.android.material.internal.TextWatcherAdapter;
import com.google.android.material.internal.ViewUtils;
import com.google.android.material.textfield.TextInputLayout;
import java.util.Arrays;
/* loaded from: classes.dex */
class ChipTextInputComboView extends FrameLayout implements Checkable {
private final Chip chip;
private final EditText editText;
private TextView label;
private final TextInputLayout textInputLayout;
private TextWatcher watcher;
public TextInputLayout getTextInput() {
return this.textInputLayout;
}
public ChipTextInputComboView(Context context) {
this(context, null);
}
public ChipTextInputComboView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public ChipTextInputComboView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
LayoutInflater from = LayoutInflater.from(context);
Chip chip = (Chip) from.inflate(R.layout.material_time_chip, (ViewGroup) this, false);
this.chip = chip;
chip.setAccessibilityClassName("android.view.View");
TextInputLayout textInputLayout = (TextInputLayout) from.inflate(R.layout.material_time_input, (ViewGroup) this, false);
this.textInputLayout = textInputLayout;
EditText editText = textInputLayout.getEditText();
this.editText = editText;
editText.setVisibility(4);
TextFormatter textFormatter = new TextFormatter();
this.watcher = textFormatter;
editText.addTextChangedListener(textFormatter);
updateHintLocales();
addView(chip);
addView(textInputLayout);
this.label = (TextView) findViewById(R.id.material_label);
editText.setId(ViewCompat.generateViewId());
ViewCompat.setLabelFor(this.label, editText.getId());
editText.setSaveEnabled(false);
editText.setLongClickable(false);
}
private void updateHintLocales() {
LocaleList locales;
if (Build.VERSION.SDK_INT >= 24) {
locales = getContext().getResources().getConfiguration().getLocales();
this.editText.setImeHintLocales(locales);
}
}
@Override // android.widget.Checkable
public boolean isChecked() {
return this.chip.isChecked();
}
@Override // android.widget.Checkable
public void setChecked(boolean z) {
this.chip.setChecked(z);
this.editText.setVisibility(z ? 0 : 4);
this.chip.setVisibility(z ? 8 : 0);
if (isChecked()) {
ViewUtils.requestFocusAndShowKeyboard(this.editText, false);
}
}
@Override // android.widget.Checkable
public void toggle() {
this.chip.toggle();
}
public void setText(CharSequence charSequence) {
String formatText = formatText(charSequence);
this.chip.setText(formatText);
if (TextUtils.isEmpty(formatText)) {
return;
}
this.editText.removeTextChangedListener(this.watcher);
this.editText.setText(formatText);
this.editText.addTextChangedListener(this.watcher);
}
CharSequence getChipText() {
return this.chip.getText();
}
/* JADX INFO: Access modifiers changed from: private */
public String formatText(CharSequence charSequence) {
return TimeModel.formatText(getResources(), charSequence);
}
@Override // android.view.View
public void setOnClickListener(View.OnClickListener onClickListener) {
this.chip.setOnClickListener(onClickListener);
}
@Override // android.view.View
public void setTag(int i, Object obj) {
this.chip.setTag(i, obj);
}
public void setHelperText(CharSequence charSequence) {
this.label.setText(charSequence);
}
public void setCursorVisible(boolean z) {
this.editText.setCursorVisible(z);
}
public void addInputFilter(InputFilter inputFilter) {
InputFilter[] filters = this.editText.getFilters();
InputFilter[] inputFilterArr = (InputFilter[]) Arrays.copyOf(filters, filters.length + 1);
inputFilterArr[filters.length] = inputFilter;
this.editText.setFilters(inputFilterArr);
}
public void setChipDelegate(AccessibilityDelegateCompat accessibilityDelegateCompat) {
ViewCompat.setAccessibilityDelegate(this.chip, accessibilityDelegateCompat);
}
private class TextFormatter extends TextWatcherAdapter {
private static final String DEFAULT_TEXT = "00";
private TextFormatter() {
}
@Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher
public void afterTextChanged(Editable editable) {
if (TextUtils.isEmpty(editable)) {
ChipTextInputComboView.this.chip.setText(ChipTextInputComboView.this.formatText(DEFAULT_TEXT));
return;
}
String formatText = ChipTextInputComboView.this.formatText(editable);
Chip chip = ChipTextInputComboView.this.chip;
if (TextUtils.isEmpty(formatText)) {
formatText = ChipTextInputComboView.this.formatText(DEFAULT_TEXT);
}
chip.setText(formatText);
}
}
@Override // android.view.View
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
updateHintLocales();
}
}

View File

@ -0,0 +1,21 @@
package com.google.android.material.timepicker;
import android.content.Context;
import android.view.View;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
/* loaded from: classes.dex */
class ClickActionDelegate extends AccessibilityDelegateCompat {
private final AccessibilityNodeInfoCompat.AccessibilityActionCompat clickAction;
public ClickActionDelegate(Context context, int i) {
this.clickAction = new AccessibilityNodeInfoCompat.AccessibilityActionCompat(16, context.getString(i));
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.addAction(this.clickAction);
}
}

View File

@ -0,0 +1,272 @@
package com.google.android.material.timepicker;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.TextView;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
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.resources.MaterialResources;
import com.google.android.material.timepicker.ClockHandView;
import java.util.Arrays;
/* loaded from: classes.dex */
class ClockFaceView extends RadialViewGroup implements ClockHandView.OnRotateListener {
private static final float EPSILON = 0.001f;
private static final int INITIAL_CAPACITY = 12;
private static final String VALUE_PLACEHOLDER = "";
private final int clockHandPadding;
private final ClockHandView clockHandView;
private final int clockSize;
private float currentHandRotation;
private final int[] gradientColors;
private final float[] gradientPositions;
private final int minimumHeight;
private final int minimumWidth;
private final RectF scratch;
private final Rect scratchLineBounds;
private final ColorStateList textColor;
private final SparseArray<TextView> textViewPool;
private final Rect textViewRect;
private final AccessibilityDelegateCompat valueAccessibilityDelegate;
private String[] values;
public ClockFaceView(Context context) {
this(context, null);
}
public ClockFaceView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.materialClockStyle);
}
public ClockFaceView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.textViewRect = new Rect();
this.scratch = new RectF();
this.scratchLineBounds = new Rect();
this.textViewPool = new SparseArray<>();
this.gradientPositions = new float[]{0.0f, 0.9f, 1.0f};
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ClockFaceView, i, R.style.Widget_MaterialComponents_TimePicker_Clock);
Resources resources = getResources();
ColorStateList colorStateList = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.ClockFaceView_clockNumberTextColor);
this.textColor = colorStateList;
LayoutInflater.from(context).inflate(R.layout.material_clockface_view, (ViewGroup) this, true);
ClockHandView clockHandView = (ClockHandView) findViewById(R.id.material_clock_hand);
this.clockHandView = clockHandView;
this.clockHandPadding = resources.getDimensionPixelSize(R.dimen.material_clock_hand_padding);
int colorForState = colorStateList.getColorForState(new int[]{android.R.attr.state_selected}, colorStateList.getDefaultColor());
this.gradientColors = new int[]{colorForState, colorForState, colorStateList.getDefaultColor()};
clockHandView.addOnRotateListener(this);
int defaultColor = AppCompatResources.getColorStateList(context, R.color.material_timepicker_clockface).getDefaultColor();
ColorStateList colorStateList2 = MaterialResources.getColorStateList(context, obtainStyledAttributes, R.styleable.ClockFaceView_clockFaceBackgroundColor);
setBackgroundColor(colorStateList2 != null ? colorStateList2.getDefaultColor() : defaultColor);
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // from class: com.google.android.material.timepicker.ClockFaceView.1
@Override // android.view.ViewTreeObserver.OnPreDrawListener
public boolean onPreDraw() {
if (!ClockFaceView.this.isShown()) {
return true;
}
ClockFaceView.this.getViewTreeObserver().removeOnPreDrawListener(this);
ClockFaceView.this.setRadius(((ClockFaceView.this.getHeight() / 2) - ClockFaceView.this.clockHandView.getSelectorRadius()) - ClockFaceView.this.clockHandPadding);
return true;
}
});
setFocusable(true);
obtainStyledAttributes.recycle();
this.valueAccessibilityDelegate = new AccessibilityDelegateCompat() { // from class: com.google.android.material.timepicker.ClockFaceView.2
@Override // androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
int intValue = ((Integer) view.getTag(R.id.material_value_index)).intValue();
if (intValue > 0) {
accessibilityNodeInfoCompat.setTraversalAfter((View) ClockFaceView.this.textViewPool.get(intValue - 1));
}
accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(0, 1, intValue, 1, false, view.isSelected()));
accessibilityNodeInfoCompat.setClickable(true);
accessibilityNodeInfoCompat.addAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CLICK);
}
@Override // androidx.core.view.AccessibilityDelegateCompat
public boolean performAccessibilityAction(View view, int i2, Bundle bundle) {
if (i2 == 16) {
long uptimeMillis = SystemClock.uptimeMillis();
view.getHitRect(ClockFaceView.this.textViewRect);
float centerX = ClockFaceView.this.textViewRect.centerX();
float centerY = ClockFaceView.this.textViewRect.centerY();
ClockFaceView.this.clockHandView.onTouchEvent(MotionEvent.obtain(uptimeMillis, uptimeMillis, 0, centerX, centerY, 0));
ClockFaceView.this.clockHandView.onTouchEvent(MotionEvent.obtain(uptimeMillis, uptimeMillis, 1, centerX, centerY, 0));
return true;
}
return super.performAccessibilityAction(view, i2, bundle);
}
};
String[] strArr = new String[12];
Arrays.fill(strArr, VALUE_PLACEHOLDER);
setValues(strArr, 0);
this.minimumHeight = resources.getDimensionPixelSize(R.dimen.material_time_picker_minimum_screen_height);
this.minimumWidth = resources.getDimensionPixelSize(R.dimen.material_time_picker_minimum_screen_width);
this.clockSize = resources.getDimensionPixelSize(R.dimen.material_clock_size);
}
public void setValues(String[] strArr, int i) {
this.values = strArr;
updateTextViews(i);
}
private void updateTextViews(int i) {
LayoutInflater from = LayoutInflater.from(getContext());
int size = this.textViewPool.size();
boolean z = false;
for (int i2 = 0; i2 < Math.max(this.values.length, size); i2++) {
TextView textView = this.textViewPool.get(i2);
if (i2 >= this.values.length) {
removeView(textView);
this.textViewPool.remove(i2);
} else {
if (textView == null) {
textView = (TextView) from.inflate(R.layout.material_clockface_textview, (ViewGroup) this, false);
this.textViewPool.put(i2, textView);
addView(textView);
}
textView.setText(this.values[i2]);
textView.setTag(R.id.material_value_index, Integer.valueOf(i2));
int i3 = (i2 / 12) + 1;
textView.setTag(R.id.material_clock_level, Integer.valueOf(i3));
if (i3 > 1) {
z = true;
}
ViewCompat.setAccessibilityDelegate(textView, this.valueAccessibilityDelegate);
textView.setTextColor(this.textColor);
if (i != 0) {
textView.setContentDescription(getResources().getString(i, this.values[i2]));
}
}
}
this.clockHandView.setMultiLevel(z);
}
@Override // com.google.android.material.timepicker.RadialViewGroup
protected void updateLayoutParams() {
super.updateLayoutParams();
for (int i = 0; i < this.textViewPool.size(); i++) {
this.textViewPool.get(i).setVisibility(0);
}
}
@Override // android.view.View
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
AccessibilityNodeInfoCompat.wrap(accessibilityNodeInfo).setCollectionInfo(AccessibilityNodeInfoCompat.CollectionInfoCompat.obtain(1, this.values.length, false, 1));
}
@Override // com.google.android.material.timepicker.RadialViewGroup
public void setRadius(int i) {
if (i != getRadius()) {
super.setRadius(i);
this.clockHandView.setCircleRadius(getRadius());
}
}
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
findIntersectingTextView();
}
public void setHandRotation(float f) {
this.clockHandView.setHandRotation(f);
findIntersectingTextView();
}
private void findIntersectingTextView() {
RectF currentSelectorBox = this.clockHandView.getCurrentSelectorBox();
TextView selectedTextView = getSelectedTextView(currentSelectorBox);
for (int i = 0; i < this.textViewPool.size(); i++) {
TextView textView = this.textViewPool.get(i);
if (textView != null) {
textView.setSelected(textView == selectedTextView);
textView.getPaint().setShader(getGradientForTextView(currentSelectorBox, textView));
textView.invalidate();
}
}
}
private TextView getSelectedTextView(RectF rectF) {
float f = Float.MAX_VALUE;
TextView textView = null;
for (int i = 0; i < this.textViewPool.size(); i++) {
TextView textView2 = this.textViewPool.get(i);
if (textView2 != null) {
textView2.getHitRect(this.textViewRect);
this.scratch.set(this.textViewRect);
this.scratch.union(rectF);
float width = this.scratch.width() * this.scratch.height();
if (width < f) {
textView = textView2;
f = width;
}
}
}
return textView;
}
private RadialGradient getGradientForTextView(RectF rectF, TextView textView) {
textView.getHitRect(this.textViewRect);
this.scratch.set(this.textViewRect);
textView.getLineBounds(0, this.scratchLineBounds);
this.scratch.inset(this.scratchLineBounds.left, this.scratchLineBounds.top);
if (RectF.intersects(rectF, this.scratch)) {
return new RadialGradient(rectF.centerX() - this.scratch.left, rectF.centerY() - this.scratch.top, rectF.width() * 0.5f, this.gradientColors, this.gradientPositions, Shader.TileMode.CLAMP);
}
return null;
}
@Override // com.google.android.material.timepicker.ClockHandView.OnRotateListener
public void onRotate(float f, boolean z) {
if (Math.abs(this.currentHandRotation - f) > EPSILON) {
this.currentHandRotation = f;
findIntersectingTextView();
}
}
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.View
protected void onMeasure(int i, int i2) {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int max3 = (int) (this.clockSize / max3(this.minimumHeight / displayMetrics.heightPixels, this.minimumWidth / displayMetrics.widthPixels, 1.0f));
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(max3, BasicMeasure.EXACTLY);
setMeasuredDimension(max3, max3);
super.onMeasure(makeMeasureSpec, makeMeasureSpec);
}
private static float max3(float f, float f2, float f3) {
return Math.max(Math.max(f, f2), f3);
}
int getCurrentLevel() {
return this.clockHandView.getCurrentLevel();
}
void setCurrentLevel(int i) {
this.clockHandView.setCurrentLevel(i);
}
}

View File

@ -0,0 +1,311 @@
package com.google.android.material.timepicker;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import androidx.core.view.ViewCompat;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.internal.ViewUtils;
import com.google.android.material.math.MathUtils;
import com.google.android.material.motion.MotionUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
class ClockHandView extends View {
private static final int DEFAULT_ANIMATION_DURATION = 200;
private boolean animatingOnTouchUp;
private final int animationDuration;
private final TimeInterpolator animationInterpolator;
private final float centerDotRadius;
private boolean changedDuringTouch;
private int circleRadius;
private int currentLevel;
private double degRad;
private float downX;
private float downY;
private boolean isInTapRegion;
private boolean isMultiLevel;
private final List<OnRotateListener> listeners;
private OnActionUpListener onActionUpListener;
private float originalDeg;
private final Paint paint;
private final ValueAnimator rotationAnimator;
private final int scaledTouchSlop;
private final RectF selectorBox;
private final int selectorRadius;
private final int selectorStrokeWidth;
public interface OnActionUpListener {
void onActionUp(float f, boolean z);
}
public interface OnRotateListener {
void onRotate(float f, boolean z);
}
int getCurrentLevel() {
return this.currentLevel;
}
public RectF getCurrentSelectorBox() {
return this.selectorBox;
}
public float getHandRotation() {
return this.originalDeg;
}
public int getSelectorRadius() {
return this.selectorRadius;
}
public void setAnimateOnTouchUp(boolean z) {
this.animatingOnTouchUp = z;
}
public void setOnActionUpListener(OnActionUpListener onActionUpListener) {
this.onActionUpListener = onActionUpListener;
}
public ClockHandView(Context context) {
this(context, null);
}
public ClockHandView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.materialClockStyle);
}
public ClockHandView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.rotationAnimator = new ValueAnimator();
this.listeners = new ArrayList();
Paint paint = new Paint();
this.paint = paint;
this.selectorBox = new RectF();
this.currentLevel = 1;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ClockHandView, i, R.style.Widget_MaterialComponents_TimePicker_Clock);
this.animationDuration = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationLong2, 200);
this.animationInterpolator = MotionUtils.resolveThemeInterpolator(context, R.attr.motionEasingEmphasizedInterpolator, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
this.circleRadius = obtainStyledAttributes.getDimensionPixelSize(R.styleable.ClockHandView_materialCircleRadius, 0);
this.selectorRadius = obtainStyledAttributes.getDimensionPixelSize(R.styleable.ClockHandView_selectorSize, 0);
this.selectorStrokeWidth = getResources().getDimensionPixelSize(R.dimen.material_clock_hand_stroke_width);
this.centerDotRadius = r7.getDimensionPixelSize(R.dimen.material_clock_hand_center_dot_radius);
int color = obtainStyledAttributes.getColor(R.styleable.ClockHandView_clockHandColor, 0);
paint.setAntiAlias(true);
paint.setColor(color);
setHandRotation(0.0f);
this.scaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
ViewCompat.setImportantForAccessibility(this, 2);
obtainStyledAttributes.recycle();
}
@Override // android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
if (this.rotationAnimator.isRunning()) {
return;
}
setHandRotation(getHandRotation());
}
public void setHandRotation(float f) {
setHandRotation(f, false);
}
public void setHandRotation(float f, boolean z) {
ValueAnimator valueAnimator = this.rotationAnimator;
if (valueAnimator != null) {
valueAnimator.cancel();
}
if (!z) {
setHandRotationInternal(f, false);
return;
}
Pair<Float, Float> valuesForAnimation = getValuesForAnimation(f);
this.rotationAnimator.setFloatValues(((Float) valuesForAnimation.first).floatValue(), ((Float) valuesForAnimation.second).floatValue());
this.rotationAnimator.setDuration(this.animationDuration);
this.rotationAnimator.setInterpolator(this.animationInterpolator);
this.rotationAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.timepicker.ClockHandView$$ExternalSyntheticLambda0
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
ClockHandView.this.m280xb17f7076(valueAnimator2);
}
});
this.rotationAnimator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.timepicker.ClockHandView.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
animator.end();
}
});
this.rotationAnimator.start();
}
/* renamed from: lambda$setHandRotation$0$com-google-android-material-timepicker-ClockHandView, reason: not valid java name */
/* synthetic */ void m280xb17f7076(ValueAnimator valueAnimator) {
setHandRotationInternal(((Float) valueAnimator.getAnimatedValue()).floatValue(), true);
}
private Pair<Float, Float> getValuesForAnimation(float f) {
float handRotation = getHandRotation();
if (Math.abs(handRotation - f) > 180.0f) {
if (handRotation > 180.0f && f < 180.0f) {
f += 360.0f;
}
if (handRotation < 180.0f && f > 180.0f) {
handRotation += 360.0f;
}
}
return new Pair<>(Float.valueOf(handRotation), Float.valueOf(f));
}
private void setHandRotationInternal(float f, boolean z) {
float f2 = f % 360.0f;
this.originalDeg = f2;
this.degRad = Math.toRadians(f2 - 90.0f);
int height = getHeight() / 2;
int width = getWidth() / 2;
float leveledCircleRadius = getLeveledCircleRadius(this.currentLevel);
float cos = width + (((float) Math.cos(this.degRad)) * leveledCircleRadius);
float sin = height + (leveledCircleRadius * ((float) Math.sin(this.degRad)));
RectF rectF = this.selectorBox;
int i = this.selectorRadius;
rectF.set(cos - i, sin - i, cos + i, sin + i);
Iterator<OnRotateListener> it = this.listeners.iterator();
while (it.hasNext()) {
it.next().onRotate(f2, z);
}
invalidate();
}
public void addOnRotateListener(OnRotateListener onRotateListener) {
this.listeners.add(onRotateListener);
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawSelector(canvas);
}
private void drawSelector(Canvas canvas) {
int height = getHeight() / 2;
int width = getWidth() / 2;
float f = width;
float leveledCircleRadius = getLeveledCircleRadius(this.currentLevel);
float cos = (((float) Math.cos(this.degRad)) * leveledCircleRadius) + f;
float f2 = height;
float sin = (leveledCircleRadius * ((float) Math.sin(this.degRad))) + f2;
this.paint.setStrokeWidth(0.0f);
canvas.drawCircle(cos, sin, this.selectorRadius, this.paint);
double sin2 = Math.sin(this.degRad);
double cos2 = Math.cos(this.degRad);
this.paint.setStrokeWidth(this.selectorStrokeWidth);
canvas.drawLine(f, f2, width + ((int) (cos2 * r7)), height + ((int) (r7 * sin2)), this.paint);
canvas.drawCircle(f, f2, this.centerDotRadius, this.paint);
}
public void setCircleRadius(int i) {
this.circleRadius = i;
invalidate();
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
boolean z;
boolean z2;
boolean z3;
OnActionUpListener onActionUpListener;
int actionMasked = motionEvent.getActionMasked();
float x = motionEvent.getX();
float y = motionEvent.getY();
if (actionMasked != 0) {
if (actionMasked == 1 || actionMasked == 2) {
int i = (int) (x - this.downX);
int i2 = (int) (y - this.downY);
this.isInTapRegion = (i * i) + (i2 * i2) > this.scaledTouchSlop;
boolean z4 = this.changedDuringTouch;
z = actionMasked == 1;
if (this.isMultiLevel) {
adjustLevel(x, y);
}
z2 = z4;
} else {
z = false;
z2 = false;
}
z3 = false;
} else {
this.downX = x;
this.downY = y;
this.isInTapRegion = true;
this.changedDuringTouch = false;
z = false;
z2 = false;
z3 = true;
}
boolean handleTouchInput = handleTouchInput(x, y, z2, z3, z) | this.changedDuringTouch;
this.changedDuringTouch = handleTouchInput;
if (handleTouchInput && z && (onActionUpListener = this.onActionUpListener) != null) {
onActionUpListener.onActionUp(getDegreesFromXY(x, y), this.isInTapRegion);
}
return true;
}
private void adjustLevel(float f, float f2) {
this.currentLevel = MathUtils.dist((float) (getWidth() / 2), (float) (getHeight() / 2), f, f2) > ((float) getLeveledCircleRadius(2)) + ViewUtils.dpToPx(getContext(), 12) ? 1 : 2;
}
private boolean handleTouchInput(float f, float f2, boolean z, boolean z2, boolean z3) {
float degreesFromXY = getDegreesFromXY(f, f2);
boolean z4 = false;
boolean z5 = getHandRotation() != degreesFromXY;
if (z2 && z5) {
return true;
}
if (!z5 && !z) {
return false;
}
if (z3 && this.animatingOnTouchUp) {
z4 = true;
}
setHandRotation(degreesFromXY, z4);
return true;
}
private int getDegreesFromXY(float f, float f2) {
int degrees = (int) Math.toDegrees(Math.atan2(f2 - (getHeight() / 2), f - (getWidth() / 2)));
int i = degrees + 90;
return i < 0 ? degrees + 450 : i;
}
void setCurrentLevel(int i) {
this.currentLevel = i;
invalidate();
}
void setMultiLevel(boolean z) {
if (this.isMultiLevel && !z) {
this.currentLevel = 1;
}
this.isMultiLevel = z;
invalidate();
}
private int getLeveledCircleRadius(int i) {
return i == 2 ? Math.round(this.circleRadius * 0.66f) : this.circleRadius;
}
}

View File

@ -0,0 +1,506 @@
package com.google.android.material.timepicker;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Pair;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.R;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.resources.MaterialAttributes;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.timepicker.TimePickerView;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
/* loaded from: classes.dex */
public final class MaterialTimePicker extends DialogFragment implements TimePickerView.OnDoubleTapListener {
public static final int INPUT_MODE_CLOCK = 0;
static final String INPUT_MODE_EXTRA = "TIME_PICKER_INPUT_MODE";
public static final int INPUT_MODE_KEYBOARD = 1;
static final String NEGATIVE_BUTTON_TEXT_EXTRA = "TIME_PICKER_NEGATIVE_BUTTON_TEXT";
static final String NEGATIVE_BUTTON_TEXT_RES_EXTRA = "TIME_PICKER_NEGATIVE_BUTTON_TEXT_RES";
static final String OVERRIDE_THEME_RES_ID = "TIME_PICKER_OVERRIDE_THEME_RES_ID";
static final String POSITIVE_BUTTON_TEXT_EXTRA = "TIME_PICKER_POSITIVE_BUTTON_TEXT";
static final String POSITIVE_BUTTON_TEXT_RES_EXTRA = "TIME_PICKER_POSITIVE_BUTTON_TEXT_RES";
static final String TIME_MODEL_EXTRA = "TIME_PICKER_TIME_MODEL";
static final String TITLE_RES_EXTRA = "TIME_PICKER_TITLE_RES";
static final String TITLE_TEXT_EXTRA = "TIME_PICKER_TITLE_TEXT";
private TimePickerPresenter activePresenter;
private Button cancelButton;
private int clockIcon;
private int keyboardIcon;
private MaterialButton modeButton;
private CharSequence negativeButtonText;
private CharSequence positiveButtonText;
private ViewStub textInputStub;
private TimeModel time;
private TimePickerClockPresenter timePickerClockPresenter;
private TimePickerTextInputPresenter timePickerTextInputPresenter;
private TimePickerView timePickerView;
private CharSequence titleText;
private final Set<View.OnClickListener> positiveButtonListeners = new LinkedHashSet();
private final Set<View.OnClickListener> negativeButtonListeners = new LinkedHashSet();
private final Set<DialogInterface.OnCancelListener> cancelListeners = new LinkedHashSet();
private final Set<DialogInterface.OnDismissListener> dismissListeners = new LinkedHashSet();
private int titleResId = 0;
private int positiveButtonTextResId = 0;
private int negativeButtonTextResId = 0;
private int inputMode = 0;
private int overrideThemeResId = 0;
public int getInputMode() {
return this.inputMode;
}
TimePickerClockPresenter getTimePickerClockPresenter() {
return this.timePickerClockPresenter;
}
void setActivePresenter(TimePickerPresenter timePickerPresenter) {
this.activePresenter = timePickerPresenter;
}
/* JADX INFO: Access modifiers changed from: private */
public static MaterialTimePicker newInstance(Builder builder) {
MaterialTimePicker materialTimePicker = new MaterialTimePicker();
Bundle bundle = new Bundle();
bundle.putParcelable(TIME_MODEL_EXTRA, builder.time);
if (builder.inputMode != null) {
bundle.putInt(INPUT_MODE_EXTRA, builder.inputMode.intValue());
}
bundle.putInt(TITLE_RES_EXTRA, builder.titleTextResId);
if (builder.titleText != null) {
bundle.putCharSequence(TITLE_TEXT_EXTRA, builder.titleText);
}
bundle.putInt(POSITIVE_BUTTON_TEXT_RES_EXTRA, builder.positiveButtonTextResId);
if (builder.positiveButtonText != null) {
bundle.putCharSequence(POSITIVE_BUTTON_TEXT_EXTRA, builder.positiveButtonText);
}
bundle.putInt(NEGATIVE_BUTTON_TEXT_RES_EXTRA, builder.negativeButtonTextResId);
if (builder.negativeButtonText != null) {
bundle.putCharSequence(NEGATIVE_BUTTON_TEXT_EXTRA, builder.negativeButtonText);
}
bundle.putInt(OVERRIDE_THEME_RES_ID, builder.overrideThemeResId);
materialTimePicker.setArguments(bundle);
return materialTimePicker;
}
public int getMinute() {
return this.time.minute;
}
public void setMinute(int i) {
this.time.setMinute(i);
TimePickerPresenter timePickerPresenter = this.activePresenter;
if (timePickerPresenter != null) {
timePickerPresenter.invalidate();
}
}
public int getHour() {
return this.time.hour % 24;
}
public void setHour(int i) {
this.time.setHour(i);
TimePickerPresenter timePickerPresenter = this.activePresenter;
if (timePickerPresenter != null) {
timePickerPresenter.invalidate();
}
}
@Override // androidx.fragment.app.DialogFragment
public final Dialog onCreateDialog(Bundle bundle) {
Dialog dialog = new Dialog(requireContext(), getThemeResId());
Context context = dialog.getContext();
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(context, null, R.attr.materialTimePickerStyle, R.style.Widget_MaterialComponents_TimePicker);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(null, R.styleable.MaterialTimePicker, R.attr.materialTimePickerStyle, R.style.Widget_MaterialComponents_TimePicker);
this.clockIcon = obtainStyledAttributes.getResourceId(R.styleable.MaterialTimePicker_clockIcon, 0);
this.keyboardIcon = obtainStyledAttributes.getResourceId(R.styleable.MaterialTimePicker_keyboardIcon, 0);
int color = obtainStyledAttributes.getColor(R.styleable.MaterialTimePicker_backgroundTint, 0);
obtainStyledAttributes.recycle();
materialShapeDrawable.initializeElevationOverlay(context);
materialShapeDrawable.setFillColor(ColorStateList.valueOf(color));
Window window = dialog.getWindow();
window.setBackgroundDrawable(materialShapeDrawable);
window.requestFeature(1);
window.setLayout(-2, -2);
materialShapeDrawable.setElevation(ViewCompat.getElevation(window.getDecorView()));
return dialog;
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (bundle == null) {
bundle = getArguments();
}
restoreState(bundle);
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putParcelable(TIME_MODEL_EXTRA, this.time);
bundle.putInt(INPUT_MODE_EXTRA, this.inputMode);
bundle.putInt(TITLE_RES_EXTRA, this.titleResId);
bundle.putCharSequence(TITLE_TEXT_EXTRA, this.titleText);
bundle.putInt(POSITIVE_BUTTON_TEXT_RES_EXTRA, this.positiveButtonTextResId);
bundle.putCharSequence(POSITIVE_BUTTON_TEXT_EXTRA, this.positiveButtonText);
bundle.putInt(NEGATIVE_BUTTON_TEXT_RES_EXTRA, this.negativeButtonTextResId);
bundle.putCharSequence(NEGATIVE_BUTTON_TEXT_EXTRA, this.negativeButtonText);
bundle.putInt(OVERRIDE_THEME_RES_ID, this.overrideThemeResId);
}
private void restoreState(Bundle bundle) {
if (bundle == null) {
return;
}
TimeModel timeModel = (TimeModel) bundle.getParcelable(TIME_MODEL_EXTRA);
this.time = timeModel;
if (timeModel == null) {
this.time = new TimeModel();
}
this.inputMode = bundle.getInt(INPUT_MODE_EXTRA, this.time.format != 1 ? 0 : 1);
this.titleResId = bundle.getInt(TITLE_RES_EXTRA, 0);
this.titleText = bundle.getCharSequence(TITLE_TEXT_EXTRA);
this.positiveButtonTextResId = bundle.getInt(POSITIVE_BUTTON_TEXT_RES_EXTRA, 0);
this.positiveButtonText = bundle.getCharSequence(POSITIVE_BUTTON_TEXT_EXTRA);
this.negativeButtonTextResId = bundle.getInt(NEGATIVE_BUTTON_TEXT_RES_EXTRA, 0);
this.negativeButtonText = bundle.getCharSequence(NEGATIVE_BUTTON_TEXT_EXTRA);
this.overrideThemeResId = bundle.getInt(OVERRIDE_THEME_RES_ID, 0);
}
@Override // androidx.fragment.app.Fragment
public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
ViewGroup viewGroup2 = (ViewGroup) layoutInflater.inflate(R.layout.material_timepicker_dialog, viewGroup);
TimePickerView timePickerView = (TimePickerView) viewGroup2.findViewById(R.id.material_timepicker_view);
this.timePickerView = timePickerView;
timePickerView.setOnDoubleTapListener(this);
this.textInputStub = (ViewStub) viewGroup2.findViewById(R.id.material_textinput_timepicker);
this.modeButton = (MaterialButton) viewGroup2.findViewById(R.id.material_timepicker_mode_button);
TextView textView = (TextView) viewGroup2.findViewById(R.id.header_title);
int i = this.titleResId;
if (i != 0) {
textView.setText(i);
} else if (!TextUtils.isEmpty(this.titleText)) {
textView.setText(this.titleText);
}
updateInputMode(this.modeButton);
Button button = (Button) viewGroup2.findViewById(R.id.material_timepicker_ok_button);
button.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.timepicker.MaterialTimePicker.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
Iterator it = MaterialTimePicker.this.positiveButtonListeners.iterator();
while (it.hasNext()) {
((View.OnClickListener) it.next()).onClick(view);
}
MaterialTimePicker.this.dismiss();
}
});
int i2 = this.positiveButtonTextResId;
if (i2 != 0) {
button.setText(i2);
} else if (!TextUtils.isEmpty(this.positiveButtonText)) {
button.setText(this.positiveButtonText);
}
Button button2 = (Button) viewGroup2.findViewById(R.id.material_timepicker_cancel_button);
this.cancelButton = button2;
button2.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.timepicker.MaterialTimePicker.2
@Override // android.view.View.OnClickListener
public void onClick(View view) {
Iterator it = MaterialTimePicker.this.negativeButtonListeners.iterator();
while (it.hasNext()) {
((View.OnClickListener) it.next()).onClick(view);
}
MaterialTimePicker.this.dismiss();
}
});
int i3 = this.negativeButtonTextResId;
if (i3 != 0) {
this.cancelButton.setText(i3);
} else if (!TextUtils.isEmpty(this.negativeButtonText)) {
this.cancelButton.setText(this.negativeButtonText);
}
updateCancelButtonVisibility();
this.modeButton.setOnClickListener(new View.OnClickListener() { // from class: com.google.android.material.timepicker.MaterialTimePicker.3
@Override // android.view.View.OnClickListener
public void onClick(View view) {
MaterialTimePicker materialTimePicker = MaterialTimePicker.this;
materialTimePicker.inputMode = materialTimePicker.inputMode == 0 ? 1 : 0;
MaterialTimePicker materialTimePicker2 = MaterialTimePicker.this;
materialTimePicker2.updateInputMode(materialTimePicker2.modeButton);
}
});
return viewGroup2;
}
@Override // androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
super.onViewCreated(view, bundle);
if (this.activePresenter instanceof TimePickerTextInputPresenter) {
view.postDelayed(new Runnable() { // from class: com.google.android.material.timepicker.MaterialTimePicker$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
MaterialTimePicker.this.m281xac73da03();
}
}, 100L);
}
}
/* renamed from: lambda$onViewCreated$0$com-google-android-material-timepicker-MaterialTimePicker, reason: not valid java name */
/* synthetic */ void m281xac73da03() {
TimePickerPresenter timePickerPresenter = this.activePresenter;
if (timePickerPresenter instanceof TimePickerTextInputPresenter) {
((TimePickerTextInputPresenter) timePickerPresenter).resetChecked();
}
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onDestroyView() {
super.onDestroyView();
this.activePresenter = null;
this.timePickerClockPresenter = null;
this.timePickerTextInputPresenter = null;
TimePickerView timePickerView = this.timePickerView;
if (timePickerView != null) {
timePickerView.setOnDoubleTapListener(null);
this.timePickerView = null;
}
}
@Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnCancelListener
public final void onCancel(DialogInterface dialogInterface) {
Iterator<DialogInterface.OnCancelListener> it = this.cancelListeners.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.dismissListeners.iterator();
while (it.hasNext()) {
it.next().onDismiss(dialogInterface);
}
super.onDismiss(dialogInterface);
}
@Override // androidx.fragment.app.DialogFragment
public void setCancelable(boolean z) {
super.setCancelable(z);
updateCancelButtonVisibility();
}
@Override // com.google.android.material.timepicker.TimePickerView.OnDoubleTapListener
public void onDoubleTap() {
this.inputMode = 1;
updateInputMode(this.modeButton);
this.timePickerTextInputPresenter.resetChecked();
}
/* JADX INFO: Access modifiers changed from: private */
public void updateInputMode(MaterialButton materialButton) {
if (materialButton == null || this.timePickerView == null || this.textInputStub == null) {
return;
}
TimePickerPresenter timePickerPresenter = this.activePresenter;
if (timePickerPresenter != null) {
timePickerPresenter.hide();
}
TimePickerPresenter initializeOrRetrieveActivePresenterForMode = initializeOrRetrieveActivePresenterForMode(this.inputMode, this.timePickerView, this.textInputStub);
this.activePresenter = initializeOrRetrieveActivePresenterForMode;
initializeOrRetrieveActivePresenterForMode.show();
this.activePresenter.invalidate();
Pair<Integer, Integer> dataForMode = dataForMode(this.inputMode);
materialButton.setIconResource(((Integer) dataForMode.first).intValue());
materialButton.setContentDescription(getResources().getString(((Integer) dataForMode.second).intValue()));
materialButton.sendAccessibilityEvent(4);
}
private void updateCancelButtonVisibility() {
Button button = this.cancelButton;
if (button != null) {
button.setVisibility(isCancelable() ? 0 : 8);
}
}
private TimePickerPresenter initializeOrRetrieveActivePresenterForMode(int i, TimePickerView timePickerView, ViewStub viewStub) {
if (i != 0) {
if (this.timePickerTextInputPresenter == null) {
this.timePickerTextInputPresenter = new TimePickerTextInputPresenter((LinearLayout) viewStub.inflate(), this.time);
}
this.timePickerTextInputPresenter.clearCheck();
return this.timePickerTextInputPresenter;
}
TimePickerClockPresenter timePickerClockPresenter = this.timePickerClockPresenter;
if (timePickerClockPresenter == null) {
timePickerClockPresenter = new TimePickerClockPresenter(timePickerView, this.time);
}
this.timePickerClockPresenter = timePickerClockPresenter;
return timePickerClockPresenter;
}
private Pair<Integer, Integer> dataForMode(int i) {
if (i == 0) {
return new Pair<>(Integer.valueOf(this.keyboardIcon), Integer.valueOf(R.string.material_timepicker_text_input_mode_description));
}
if (i == 1) {
return new Pair<>(Integer.valueOf(this.clockIcon), Integer.valueOf(R.string.material_timepicker_clock_mode_description));
}
throw new IllegalArgumentException("no icon for mode: " + i);
}
public boolean addOnPositiveButtonClickListener(View.OnClickListener onClickListener) {
return this.positiveButtonListeners.add(onClickListener);
}
public boolean removeOnPositiveButtonClickListener(View.OnClickListener onClickListener) {
return this.positiveButtonListeners.remove(onClickListener);
}
public void clearOnPositiveButtonClickListeners() {
this.positiveButtonListeners.clear();
}
public boolean addOnNegativeButtonClickListener(View.OnClickListener onClickListener) {
return this.negativeButtonListeners.add(onClickListener);
}
public boolean removeOnNegativeButtonClickListener(View.OnClickListener onClickListener) {
return this.negativeButtonListeners.remove(onClickListener);
}
public void clearOnNegativeButtonClickListeners() {
this.negativeButtonListeners.clear();
}
public boolean addOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
return this.cancelListeners.add(onCancelListener);
}
public boolean removeOnCancelListener(DialogInterface.OnCancelListener onCancelListener) {
return this.cancelListeners.remove(onCancelListener);
}
public void clearOnCancelListeners() {
this.cancelListeners.clear();
}
public boolean addOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
return this.dismissListeners.add(onDismissListener);
}
public boolean removeOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
return this.dismissListeners.remove(onDismissListener);
}
public void clearOnDismissListeners() {
this.dismissListeners.clear();
}
private int getThemeResId() {
int i = this.overrideThemeResId;
if (i != 0) {
return i;
}
TypedValue resolve = MaterialAttributes.resolve(requireContext(), R.attr.materialTimePickerTheme);
if (resolve == null) {
return 0;
}
return resolve.data;
}
public static final class Builder {
private Integer inputMode;
private CharSequence negativeButtonText;
private CharSequence positiveButtonText;
private CharSequence titleText;
private TimeModel time = new TimeModel();
private int titleTextResId = 0;
private int positiveButtonTextResId = 0;
private int negativeButtonTextResId = 0;
private int overrideThemeResId = 0;
public Builder setNegativeButtonText(int i) {
this.negativeButtonTextResId = i;
return this;
}
public Builder setNegativeButtonText(CharSequence charSequence) {
this.negativeButtonText = charSequence;
return this;
}
public Builder setPositiveButtonText(int i) {
this.positiveButtonTextResId = i;
return this;
}
public Builder setPositiveButtonText(CharSequence charSequence) {
this.positiveButtonText = charSequence;
return this;
}
public Builder setTheme(int i) {
this.overrideThemeResId = i;
return this;
}
public Builder setTitleText(int i) {
this.titleTextResId = i;
return this;
}
public Builder setTitleText(CharSequence charSequence) {
this.titleText = charSequence;
return this;
}
public Builder setInputMode(int i) {
this.inputMode = Integer.valueOf(i);
return this;
}
public Builder setHour(int i) {
this.time.setHourOfDay(i);
return this;
}
public Builder setMinute(int i) {
this.time.setMinute(i);
return this;
}
public Builder setTimeFormat(int i) {
int i2 = this.time.hour;
int i3 = this.time.minute;
TimeModel timeModel = new TimeModel(i);
this.time = timeModel;
timeModel.setMinute(i3);
this.time.setHourOfDay(i2);
return this;
}
public MaterialTimePicker build() {
return MaterialTimePicker.newInstance(this);
}
}
}

View File

@ -0,0 +1,35 @@
package com.google.android.material.timepicker;
import android.text.InputFilter;
import android.text.Spanned;
/* loaded from: classes.dex */
class MaxInputValidator implements InputFilter {
private int max;
public int getMax() {
return this.max;
}
public void setMax(int i) {
this.max = i;
}
public MaxInputValidator(int i) {
this.max = i;
}
@Override // android.text.InputFilter
public CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
try {
StringBuilder sb = new StringBuilder(spanned);
sb.replace(i3, i4, charSequence.subSequence(i, i2).toString());
if (Integer.parseInt(sb.toString()) <= this.max) {
return null;
}
return "";
} catch (NumberFormatException unused) {
return "";
}
}
}

View File

@ -0,0 +1,147 @@
package com.google.android.material.timepicker;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.view.ViewCompat;
import com.google.android.material.R;
import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.RelativeCornerSize;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
class RadialViewGroup extends ConstraintLayout {
static final int LEVEL_1 = 1;
static final int LEVEL_2 = 2;
static final float LEVEL_RADIUS_RATIO = 0.66f;
private static final String SKIP_TAG = "skip";
private MaterialShapeDrawable background;
private int radius;
private final Runnable updateLayoutParametersRunnable;
public int getRadius() {
return this.radius;
}
public RadialViewGroup(Context context) {
this(context, null);
}
public RadialViewGroup(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public RadialViewGroup(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
LayoutInflater.from(context).inflate(R.layout.material_radial_view_group, this);
ViewCompat.setBackground(this, createBackground());
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.RadialViewGroup, i, 0);
this.radius = obtainStyledAttributes.getDimensionPixelSize(R.styleable.RadialViewGroup_materialCircleRadius, 0);
this.updateLayoutParametersRunnable = new Runnable() { // from class: com.google.android.material.timepicker.RadialViewGroup$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
RadialViewGroup.this.updateLayoutParams();
}
};
obtainStyledAttributes.recycle();
}
private Drawable createBackground() {
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable();
this.background = materialShapeDrawable;
materialShapeDrawable.setCornerSize(new RelativeCornerSize(0.5f));
this.background.setFillColor(ColorStateList.valueOf(-1));
return this.background;
}
@Override // android.view.View
public void setBackgroundColor(int i) {
this.background.setFillColor(ColorStateList.valueOf(i));
}
@Override // android.view.ViewGroup
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
super.addView(view, i, layoutParams);
if (view.getId() == -1) {
view.setId(ViewCompat.generateViewId());
}
updateLayoutParamsAsync();
}
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup
public void onViewRemoved(View view) {
super.onViewRemoved(view);
updateLayoutParamsAsync();
}
private void updateLayoutParamsAsync() {
Handler handler = getHandler();
if (handler != null) {
handler.removeCallbacks(this.updateLayoutParametersRunnable);
handler.post(this.updateLayoutParametersRunnable);
}
}
@Override // android.view.View
protected void onFinishInflate() {
super.onFinishInflate();
updateLayoutParams();
}
protected void updateLayoutParams() {
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(this);
HashMap hashMap = new HashMap();
for (int i = 0; i < getChildCount(); i++) {
View childAt = getChildAt(i);
if (childAt.getId() != R.id.circle_center && !shouldSkipView(childAt)) {
int i2 = (Integer) childAt.getTag(R.id.material_clock_level);
if (i2 == null) {
i2 = 1;
}
if (!hashMap.containsKey(i2)) {
hashMap.put(i2, new ArrayList());
}
((List) hashMap.get(i2)).add(childAt);
}
}
for (Map.Entry entry : hashMap.entrySet()) {
addConstraints((List) entry.getValue(), constraintSet, getLeveledRadius(((Integer) entry.getKey()).intValue()));
}
constraintSet.applyTo(this);
}
private void addConstraints(List<View> list, ConstraintSet constraintSet, int i) {
Iterator<View> it = list.iterator();
float f = 0.0f;
while (it.hasNext()) {
constraintSet.constrainCircle(it.next().getId(), R.id.circle_center, i, f);
f += 360.0f / list.size();
}
}
public void setRadius(int i) {
this.radius = i;
updateLayoutParams();
}
int getLeveledRadius(int i) {
return i == 2 ? Math.round(this.radius * LEVEL_RADIUS_RATIO) : this.radius;
}
private static boolean shouldSkipView(View view) {
return SKIP_TAG.equals(view.getTag());
}
}

View File

@ -0,0 +1,11 @@
package com.google.android.material.timepicker;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes.dex */
public @interface TimeFormat {
public static final int CLOCK_12H = 0;
public static final int CLOCK_24H = 1;
}

View File

@ -0,0 +1,154 @@
package com.google.android.material.timepicker;
import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.material.R;
import java.util.Arrays;
/* loaded from: classes.dex */
class TimeModel implements Parcelable {
public static final Parcelable.Creator<TimeModel> CREATOR = new Parcelable.Creator<TimeModel>() { // from class: com.google.android.material.timepicker.TimeModel.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public TimeModel createFromParcel(Parcel parcel) {
return new TimeModel(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public TimeModel[] newArray(int i) {
return new TimeModel[i];
}
};
public static final String NUMBER_FORMAT = "%d";
public static final String ZERO_LEADING_NUMBER_FORMAT = "%02d";
final int format;
int hour;
private final MaxInputValidator hourInputValidator;
int minute;
private final MaxInputValidator minuteInputValidator;
int period;
int selection;
private static int getPeriod(int i) {
return i >= 12 ? 1 : 0;
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public MaxInputValidator getHourInputValidator() {
return this.hourInputValidator;
}
public MaxInputValidator getMinuteInputValidator() {
return this.minuteInputValidator;
}
public void setPeriod(int i) {
if (i != this.period) {
this.period = i;
int i2 = this.hour;
if (i2 < 12 && i == 1) {
this.hour = i2 + 12;
} else {
if (i2 < 12 || i != 0) {
return;
}
this.hour = i2 - 12;
}
}
}
public TimeModel() {
this(0);
}
public TimeModel(int i) {
this(0, 0, 10, i);
}
public TimeModel(int i, int i2, int i3, int i4) {
this.hour = i;
this.minute = i2;
this.selection = i3;
this.format = i4;
this.period = getPeriod(i);
this.minuteInputValidator = new MaxInputValidator(59);
this.hourInputValidator = new MaxInputValidator(i4 == 1 ? 23 : 12);
}
protected TimeModel(Parcel parcel) {
this(parcel.readInt(), parcel.readInt(), parcel.readInt(), parcel.readInt());
}
public void setHourOfDay(int i) {
this.period = getPeriod(i);
this.hour = i;
}
public void setHour(int i) {
if (this.format == 1) {
this.hour = i;
} else {
this.hour = (i % 12) + (this.period != 1 ? 0 : 12);
}
}
public void setMinute(int i) {
this.minute = i % 60;
}
public int getHourForDisplay() {
if (this.format == 1) {
return this.hour % 24;
}
int i = this.hour;
if (i % 12 == 0) {
return 12;
}
return this.period == 1 ? i - 12 : i;
}
public int getHourContentDescriptionResId() {
return this.format == 1 ? R.string.material_hour_24h_suffix : R.string.material_hour_suffix;
}
public int hashCode() {
return Arrays.hashCode(new Object[]{Integer.valueOf(this.format), Integer.valueOf(this.hour), Integer.valueOf(this.minute), Integer.valueOf(this.selection)});
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof TimeModel)) {
return false;
}
TimeModel timeModel = (TimeModel) obj;
return this.hour == timeModel.hour && this.minute == timeModel.minute && this.format == timeModel.format && this.selection == timeModel.selection;
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.hour);
parcel.writeInt(this.minute);
parcel.writeInt(this.selection);
parcel.writeInt(this.format);
}
public static String formatText(Resources resources, CharSequence charSequence) {
return formatText(resources, charSequence, ZERO_LEADING_NUMBER_FORMAT);
}
public static String formatText(Resources resources, CharSequence charSequence, String str) {
try {
return String.format(resources.getConfiguration().locale, str, Integer.valueOf(Integer.parseInt(String.valueOf(charSequence))));
} catch (NumberFormatException unused) {
return null;
}
}
}

View File

@ -0,0 +1,185 @@
package com.google.android.material.timepicker;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import androidx.core.content.ContextCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.google.android.material.R;
import com.google.android.material.timepicker.ClockHandView;
import com.google.android.material.timepicker.TimePickerView;
/* loaded from: classes.dex */
class TimePickerClockPresenter implements ClockHandView.OnRotateListener, TimePickerView.OnSelectionChange, TimePickerView.OnPeriodChangeListener, ClockHandView.OnActionUpListener, TimePickerPresenter {
private static final int DEGREES_PER_HOUR = 30;
private static final int DEGREES_PER_MINUTE = 6;
private boolean broadcasting = false;
private float hourRotation;
private float minuteRotation;
private final TimeModel time;
private final TimePickerView timePickerView;
private static final String[] HOUR_CLOCK_VALUES = {"12", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"};
private static final String[] HOUR_CLOCK_24_VALUES = {"00", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"};
private static final String[] MINUTE_CLOCK_VALUES = {"00", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55"};
public TimePickerClockPresenter(TimePickerView timePickerView, TimeModel timeModel) {
this.timePickerView = timePickerView;
this.time = timeModel;
initialize();
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void initialize() {
if (this.time.format == 0) {
this.timePickerView.showToggle();
}
this.timePickerView.addOnRotateListener(this);
this.timePickerView.setOnSelectionChangeListener(this);
this.timePickerView.setOnPeriodChangeListener(this);
this.timePickerView.setOnActionUpListener(this);
updateValues();
invalidate();
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void invalidate() {
this.hourRotation = getHourRotation();
this.minuteRotation = this.time.minute * 6;
setSelection(this.time.selection, false);
updateTime();
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void show() {
this.timePickerView.setVisibility(0);
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void hide() {
this.timePickerView.setVisibility(8);
}
private String[] getHourClockValues() {
return this.time.format == 1 ? HOUR_CLOCK_24_VALUES : HOUR_CLOCK_VALUES;
}
@Override // com.google.android.material.timepicker.ClockHandView.OnRotateListener
public void onRotate(float f, boolean z) {
if (this.broadcasting) {
return;
}
int i = this.time.hour;
int i2 = this.time.minute;
int round = Math.round(f);
if (this.time.selection == 12) {
this.time.setMinute((round + 3) / 6);
this.minuteRotation = (float) Math.floor(this.time.minute * 6);
} else {
int i3 = (round + 15) / 30;
if (this.time.format == 1) {
i3 %= 12;
if (this.timePickerView.getCurrentLevel() == 2) {
i3 += 12;
}
}
this.time.setHour(i3);
this.hourRotation = getHourRotation();
}
if (z) {
return;
}
updateTime();
performHapticFeedback(i, i2);
}
private void performHapticFeedback(int i, int i2) {
if (this.time.minute == i2 && this.time.hour == i) {
return;
}
this.timePickerView.performHapticFeedback(4);
}
@Override // com.google.android.material.timepicker.TimePickerView.OnSelectionChange
public void onSelectionChanged(int i) {
setSelection(i, true);
}
@Override // com.google.android.material.timepicker.TimePickerView.OnPeriodChangeListener
public void onPeriodChange(int i) {
this.time.setPeriod(i);
}
void setSelection(int i, boolean z) {
boolean z2 = i == 12;
this.timePickerView.setAnimateOnTouchUp(z2);
this.time.selection = i;
this.timePickerView.setValues(z2 ? MINUTE_CLOCK_VALUES : getHourClockValues(), z2 ? R.string.material_minute_suffix : this.time.getHourContentDescriptionResId());
updateCurrentLevel();
this.timePickerView.setHandRotation(z2 ? this.minuteRotation : this.hourRotation, z);
this.timePickerView.setActiveSelection(i);
this.timePickerView.setMinuteHourDelegate(new ClickActionDelegate(this.timePickerView.getContext(), R.string.material_hour_selection) { // from class: com.google.android.material.timepicker.TimePickerClockPresenter.1
@Override // com.google.android.material.timepicker.ClickActionDelegate, androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setContentDescription(view.getResources().getString(TimePickerClockPresenter.this.time.getHourContentDescriptionResId(), String.valueOf(TimePickerClockPresenter.this.time.getHourForDisplay())));
}
});
this.timePickerView.setHourClickDelegate(new ClickActionDelegate(this.timePickerView.getContext(), R.string.material_minute_selection) { // from class: com.google.android.material.timepicker.TimePickerClockPresenter.2
@Override // com.google.android.material.timepicker.ClickActionDelegate, androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setContentDescription(view.getResources().getString(R.string.material_minute_suffix, String.valueOf(TimePickerClockPresenter.this.time.minute)));
}
});
}
private void updateCurrentLevel() {
int i = 1;
if (this.time.selection == 10 && this.time.format == 1 && this.time.hour >= 12) {
i = 2;
}
this.timePickerView.setCurrentLevel(i);
}
@Override // com.google.android.material.timepicker.ClockHandView.OnActionUpListener
public void onActionUp(float f, boolean z) {
this.broadcasting = true;
int i = this.time.minute;
int i2 = this.time.hour;
if (this.time.selection == 10) {
this.timePickerView.setHandRotation(this.hourRotation, false);
AccessibilityManager accessibilityManager = (AccessibilityManager) ContextCompat.getSystemService(this.timePickerView.getContext(), AccessibilityManager.class);
if (accessibilityManager == null || !accessibilityManager.isTouchExplorationEnabled()) {
setSelection(12, true);
}
} else {
int round = Math.round(f);
if (!z) {
this.time.setMinute(((round + 15) / 30) * 5);
this.minuteRotation = this.time.minute * 6;
}
this.timePickerView.setHandRotation(this.minuteRotation, z);
}
this.broadcasting = false;
updateTime();
performHapticFeedback(i2, i);
}
private void updateTime() {
this.timePickerView.updateTime(this.time.period, this.time.getHourForDisplay(), this.time.minute);
}
private void updateValues() {
updateValues(HOUR_CLOCK_VALUES, TimeModel.NUMBER_FORMAT);
updateValues(MINUTE_CLOCK_VALUES, TimeModel.ZERO_LEADING_NUMBER_FORMAT);
}
private void updateValues(String[] strArr, String str) {
for (int i = 0; i < strArr.length; i++) {
strArr[i] = TimeModel.formatText(this.timePickerView.getResources(), strArr[i], str);
}
}
private int getHourRotation() {
return (this.time.getHourForDisplay() * 30) % 360;
}
}

View File

@ -0,0 +1,24 @@
package com.google.android.material.timepicker;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes.dex */
interface TimePickerControls {
@Retention(RetentionPolicy.SOURCE)
public @interface ActiveSelection {
}
@Retention(RetentionPolicy.SOURCE)
public @interface ClockPeriod {
}
void setActiveSelection(int i);
void setHandRotation(float f);
void setValues(String[] strArr, int i);
void updateTime(int i, int i2, int i3);
}

View File

@ -0,0 +1,12 @@
package com.google.android.material.timepicker;
/* loaded from: classes.dex */
interface TimePickerPresenter {
void hide();
void initialize();
void invalidate();
void show();
}

View File

@ -0,0 +1,95 @@
package com.google.android.material.timepicker;
import android.text.Editable;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.google.android.material.textfield.TextInputLayout;
/* loaded from: classes.dex */
class TimePickerTextInputKeyController implements TextView.OnEditorActionListener, View.OnKeyListener {
private final ChipTextInputComboView hourLayoutComboView;
private boolean keyListenerRunning = false;
private final ChipTextInputComboView minuteLayoutComboView;
private final TimeModel time;
TimePickerTextInputKeyController(ChipTextInputComboView chipTextInputComboView, ChipTextInputComboView chipTextInputComboView2, TimeModel timeModel) {
this.hourLayoutComboView = chipTextInputComboView;
this.minuteLayoutComboView = chipTextInputComboView2;
this.time = timeModel;
}
public void bind() {
TextInputLayout textInput = this.hourLayoutComboView.getTextInput();
TextInputLayout textInput2 = this.minuteLayoutComboView.getTextInput();
EditText editText = textInput.getEditText();
EditText editText2 = textInput2.getEditText();
editText.setImeOptions(268435461);
editText2.setImeOptions(268435462);
editText.setOnEditorActionListener(this);
editText.setOnKeyListener(this);
editText2.setOnKeyListener(this);
}
private void moveSelection(int i) {
this.minuteLayoutComboView.setChecked(i == 12);
this.hourLayoutComboView.setChecked(i == 10);
this.time.selection = i;
}
@Override // android.widget.TextView.OnEditorActionListener
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
boolean z = i == 5;
if (z) {
moveSelection(12);
}
return z;
}
@Override // android.view.View.OnKeyListener
public boolean onKey(View view, int i, KeyEvent keyEvent) {
boolean onHourKeyPress;
if (this.keyListenerRunning) {
return false;
}
this.keyListenerRunning = true;
EditText editText = (EditText) view;
if (this.time.selection == 12) {
onHourKeyPress = onMinuteKeyPress(i, keyEvent, editText);
} else {
onHourKeyPress = onHourKeyPress(i, keyEvent, editText);
}
this.keyListenerRunning = false;
return onHourKeyPress;
}
private boolean onMinuteKeyPress(int i, KeyEvent keyEvent, EditText editText) {
if (i == 67 && keyEvent.getAction() == 0 && TextUtils.isEmpty(editText.getText())) {
moveSelection(10);
return true;
}
clearPrefilledText(editText);
return false;
}
private boolean onHourKeyPress(int i, KeyEvent keyEvent, EditText editText) {
Editable text = editText.getText();
if (text == null) {
return false;
}
if (i >= 7 && i <= 16 && keyEvent.getAction() == 1 && editText.getSelectionStart() == 2 && text.length() == 2) {
moveSelection(12);
return true;
}
clearPrefilledText(editText);
return false;
}
private void clearPrefilledText(EditText editText) {
if (editText.getSelectionStart() == 0 && editText.length() == 2) {
editText.getText().clear();
}
}
}

View File

@ -0,0 +1,225 @@
package com.google.android.material.timepicker;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import com.google.android.material.R;
import com.google.android.material.button.MaterialButtonToggleGroup;
import com.google.android.material.internal.TextWatcherAdapter;
import com.google.android.material.internal.ViewUtils;
import com.google.android.material.timepicker.TimePickerView;
import java.lang.reflect.Field;
import java.util.Locale;
/* loaded from: classes.dex */
class TimePickerTextInputPresenter implements TimePickerView.OnSelectionChange, TimePickerPresenter {
private final TimePickerTextInputKeyController controller;
private final EditText hourEditText;
private final ChipTextInputComboView hourTextInput;
private final EditText minuteEditText;
private final ChipTextInputComboView minuteTextInput;
private final TimeModel time;
private final LinearLayout timePickerView;
private MaterialButtonToggleGroup toggle;
private final TextWatcher minuteTextWatcher = new TextWatcherAdapter() { // from class: com.google.android.material.timepicker.TimePickerTextInputPresenter.1
@Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher
public void afterTextChanged(Editable editable) {
try {
if (TextUtils.isEmpty(editable)) {
TimePickerTextInputPresenter.this.time.setMinute(0);
} else {
TimePickerTextInputPresenter.this.time.setMinute(Integer.parseInt(editable.toString()));
}
} catch (NumberFormatException unused) {
}
}
};
private final TextWatcher hourTextWatcher = new TextWatcherAdapter() { // from class: com.google.android.material.timepicker.TimePickerTextInputPresenter.2
@Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher
public void afterTextChanged(Editable editable) {
try {
if (TextUtils.isEmpty(editable)) {
TimePickerTextInputPresenter.this.time.setHour(0);
} else {
TimePickerTextInputPresenter.this.time.setHour(Integer.parseInt(editable.toString()));
}
} catch (NumberFormatException unused) {
}
}
};
public TimePickerTextInputPresenter(LinearLayout linearLayout, final TimeModel timeModel) {
this.timePickerView = linearLayout;
this.time = timeModel;
Resources resources = linearLayout.getResources();
ChipTextInputComboView chipTextInputComboView = (ChipTextInputComboView) linearLayout.findViewById(R.id.material_minute_text_input);
this.minuteTextInput = chipTextInputComboView;
ChipTextInputComboView chipTextInputComboView2 = (ChipTextInputComboView) linearLayout.findViewById(R.id.material_hour_text_input);
this.hourTextInput = chipTextInputComboView2;
TextView textView = (TextView) chipTextInputComboView.findViewById(R.id.material_label);
TextView textView2 = (TextView) chipTextInputComboView2.findViewById(R.id.material_label);
textView.setText(resources.getString(R.string.material_timepicker_minute));
textView2.setText(resources.getString(R.string.material_timepicker_hour));
chipTextInputComboView.setTag(R.id.selection_type, 12);
chipTextInputComboView2.setTag(R.id.selection_type, 10);
if (timeModel.format == 0) {
setupPeriodToggle();
}
View.OnClickListener onClickListener = new View.OnClickListener() { // from class: com.google.android.material.timepicker.TimePickerTextInputPresenter.3
@Override // android.view.View.OnClickListener
public void onClick(View view) {
TimePickerTextInputPresenter.this.onSelectionChanged(((Integer) view.getTag(R.id.selection_type)).intValue());
}
};
chipTextInputComboView2.setOnClickListener(onClickListener);
chipTextInputComboView.setOnClickListener(onClickListener);
chipTextInputComboView2.addInputFilter(timeModel.getHourInputValidator());
chipTextInputComboView.addInputFilter(timeModel.getMinuteInputValidator());
this.hourEditText = chipTextInputComboView2.getTextInput().getEditText();
this.minuteEditText = chipTextInputComboView.getTextInput().getEditText();
this.controller = new TimePickerTextInputKeyController(chipTextInputComboView2, chipTextInputComboView, timeModel);
chipTextInputComboView2.setChipDelegate(new ClickActionDelegate(linearLayout.getContext(), R.string.material_hour_selection) { // from class: com.google.android.material.timepicker.TimePickerTextInputPresenter.4
@Override // com.google.android.material.timepicker.ClickActionDelegate, androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setContentDescription(view.getResources().getString(timeModel.getHourContentDescriptionResId(), String.valueOf(timeModel.getHourForDisplay())));
}
});
chipTextInputComboView.setChipDelegate(new ClickActionDelegate(linearLayout.getContext(), R.string.material_minute_selection) { // from class: com.google.android.material.timepicker.TimePickerTextInputPresenter.5
@Override // com.google.android.material.timepicker.ClickActionDelegate, androidx.core.view.AccessibilityDelegateCompat
public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
accessibilityNodeInfoCompat.setContentDescription(view.getResources().getString(R.string.material_minute_suffix, String.valueOf(timeModel.minute)));
}
});
initialize();
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void initialize() {
addTextWatchers();
setTime(this.time);
this.controller.bind();
}
private void addTextWatchers() {
this.hourEditText.addTextChangedListener(this.hourTextWatcher);
this.minuteEditText.addTextChangedListener(this.minuteTextWatcher);
}
private void removeTextWatchers() {
this.hourEditText.removeTextChangedListener(this.hourTextWatcher);
this.minuteEditText.removeTextChangedListener(this.minuteTextWatcher);
}
private void setTime(TimeModel timeModel) {
removeTextWatchers();
Locale locale = this.timePickerView.getResources().getConfiguration().locale;
String format = String.format(locale, TimeModel.ZERO_LEADING_NUMBER_FORMAT, Integer.valueOf(timeModel.minute));
String format2 = String.format(locale, TimeModel.ZERO_LEADING_NUMBER_FORMAT, Integer.valueOf(timeModel.getHourForDisplay()));
this.minuteTextInput.setText(format);
this.hourTextInput.setText(format2);
addTextWatchers();
updateSelection();
}
private void setupPeriodToggle() {
MaterialButtonToggleGroup materialButtonToggleGroup = (MaterialButtonToggleGroup) this.timePickerView.findViewById(R.id.material_clock_period_toggle);
this.toggle = materialButtonToggleGroup;
materialButtonToggleGroup.addOnButtonCheckedListener(new MaterialButtonToggleGroup.OnButtonCheckedListener() { // from class: com.google.android.material.timepicker.TimePickerTextInputPresenter$$ExternalSyntheticLambda0
@Override // com.google.android.material.button.MaterialButtonToggleGroup.OnButtonCheckedListener
public final void onButtonChecked(MaterialButtonToggleGroup materialButtonToggleGroup2, int i, boolean z) {
TimePickerTextInputPresenter.this.m282xf2085e95(materialButtonToggleGroup2, i, z);
}
});
this.toggle.setVisibility(0);
updateSelection();
}
/* renamed from: lambda$setupPeriodToggle$0$com-google-android-material-timepicker-TimePickerTextInputPresenter, reason: not valid java name */
/* synthetic */ void m282xf2085e95(MaterialButtonToggleGroup materialButtonToggleGroup, int i, boolean z) {
if (z) {
this.time.setPeriod(i == R.id.material_clock_period_pm_button ? 1 : 0);
}
}
private void updateSelection() {
int i;
MaterialButtonToggleGroup materialButtonToggleGroup = this.toggle;
if (materialButtonToggleGroup == null) {
return;
}
if (this.time.period == 0) {
i = R.id.material_clock_period_am_button;
} else {
i = R.id.material_clock_period_pm_button;
}
materialButtonToggleGroup.check(i);
}
@Override // com.google.android.material.timepicker.TimePickerView.OnSelectionChange
public void onSelectionChanged(int i) {
this.time.selection = i;
this.minuteTextInput.setChecked(i == 12);
this.hourTextInput.setChecked(i == 10);
updateSelection();
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void show() {
this.timePickerView.setVisibility(0);
onSelectionChanged(this.time.selection);
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void hide() {
View focusedChild = this.timePickerView.getFocusedChild();
if (focusedChild != null) {
ViewUtils.hideKeyboard(focusedChild, false);
}
this.timePickerView.setVisibility(8);
}
@Override // com.google.android.material.timepicker.TimePickerPresenter
public void invalidate() {
setTime(this.time);
}
private static void setCursorDrawableColor(EditText editText, int i) {
try {
Context context = editText.getContext();
Field declaredField = TextView.class.getDeclaredField("mCursorDrawableRes");
declaredField.setAccessible(true);
int i2 = declaredField.getInt(editText);
Field declaredField2 = TextView.class.getDeclaredField("mEditor");
declaredField2.setAccessible(true);
Object obj = declaredField2.get(editText);
Field declaredField3 = obj.getClass().getDeclaredField("mCursorDrawable");
declaredField3.setAccessible(true);
Drawable drawable = AppCompatResources.getDrawable(context, i2);
drawable.setColorFilter(i, PorterDuff.Mode.SRC_IN);
declaredField3.set(obj, new Drawable[]{drawable, drawable});
} catch (Throwable unused) {
}
}
public void resetChecked() {
this.minuteTextInput.setChecked(this.time.selection == 12);
this.hourTextInput.setChecked(this.time.selection == 10);
}
public void clearCheck() {
this.minuteTextInput.setChecked(false);
this.hourTextInput.setChecked(false);
}
}

View File

@ -0,0 +1,219 @@
package com.google.android.material.timepicker;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Checkable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import com.google.android.material.R;
import com.google.android.material.button.MaterialButtonToggleGroup;
import com.google.android.material.chip.Chip;
import com.google.android.material.timepicker.ClockHandView;
import java.util.Locale;
/* loaded from: classes.dex */
class TimePickerView extends ConstraintLayout implements TimePickerControls {
static final String GENERIC_VIEW_ACCESSIBILITY_CLASS_NAME = "android.view.View";
private final ClockFaceView clockFace;
private final ClockHandView clockHandView;
private final Chip hourView;
private final Chip minuteView;
private OnDoubleTapListener onDoubleTapListener;
private OnPeriodChangeListener onPeriodChangeListener;
private OnSelectionChange onSelectionChangeListener;
private final View.OnClickListener selectionListener;
private final MaterialButtonToggleGroup toggle;
interface OnDoubleTapListener {
void onDoubleTap();
}
interface OnPeriodChangeListener {
void onPeriodChange(int i);
}
interface OnSelectionChange {
void onSelectionChanged(int i);
}
void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
this.onDoubleTapListener = onDoubleTapListener;
}
void setOnPeriodChangeListener(OnPeriodChangeListener onPeriodChangeListener) {
this.onPeriodChangeListener = onPeriodChangeListener;
}
void setOnSelectionChangeListener(OnSelectionChange onSelectionChange) {
this.onSelectionChangeListener = onSelectionChange;
}
public TimePickerView(Context context) {
this(context, null);
}
public TimePickerView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public TimePickerView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.selectionListener = new View.OnClickListener() { // from class: com.google.android.material.timepicker.TimePickerView.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
if (TimePickerView.this.onSelectionChangeListener != null) {
TimePickerView.this.onSelectionChangeListener.onSelectionChanged(((Integer) view.getTag(R.id.selection_type)).intValue());
}
}
};
LayoutInflater.from(context).inflate(R.layout.material_timepicker, this);
this.clockFace = (ClockFaceView) findViewById(R.id.material_clock_face);
MaterialButtonToggleGroup materialButtonToggleGroup = (MaterialButtonToggleGroup) findViewById(R.id.material_clock_period_toggle);
this.toggle = materialButtonToggleGroup;
materialButtonToggleGroup.addOnButtonCheckedListener(new MaterialButtonToggleGroup.OnButtonCheckedListener() { // from class: com.google.android.material.timepicker.TimePickerView$$ExternalSyntheticLambda0
@Override // com.google.android.material.button.MaterialButtonToggleGroup.OnButtonCheckedListener
public final void onButtonChecked(MaterialButtonToggleGroup materialButtonToggleGroup2, int i2, boolean z) {
TimePickerView.this.m283x9f44237d(materialButtonToggleGroup2, i2, z);
}
});
this.minuteView = (Chip) findViewById(R.id.material_minute_tv);
this.hourView = (Chip) findViewById(R.id.material_hour_tv);
this.clockHandView = (ClockHandView) findViewById(R.id.material_clock_hand);
setupDoubleTap();
setUpDisplay();
}
/* renamed from: lambda$new$0$com-google-android-material-timepicker-TimePickerView, reason: not valid java name */
/* synthetic */ void m283x9f44237d(MaterialButtonToggleGroup materialButtonToggleGroup, int i, boolean z) {
if (z && this.onPeriodChangeListener != null) {
this.onPeriodChangeListener.onPeriodChange(i == R.id.material_clock_period_pm_button ? 1 : 0);
}
}
private void setupDoubleTap() {
final GestureDetector gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { // from class: com.google.android.material.timepicker.TimePickerView.2
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
public boolean onDoubleTap(MotionEvent motionEvent) {
OnDoubleTapListener onDoubleTapListener = TimePickerView.this.onDoubleTapListener;
if (onDoubleTapListener == null) {
return false;
}
onDoubleTapListener.onDoubleTap();
return true;
}
});
View.OnTouchListener onTouchListener = new View.OnTouchListener() { // from class: com.google.android.material.timepicker.TimePickerView.3
/* JADX WARN: Multi-variable type inference failed */
@Override // android.view.View.OnTouchListener
public boolean onTouch(View view, MotionEvent motionEvent) {
if (((Checkable) view).isChecked()) {
return gestureDetector.onTouchEvent(motionEvent);
}
return false;
}
};
this.minuteView.setOnTouchListener(onTouchListener);
this.hourView.setOnTouchListener(onTouchListener);
}
public void setMinuteHourDelegate(AccessibilityDelegateCompat accessibilityDelegateCompat) {
ViewCompat.setAccessibilityDelegate(this.hourView, accessibilityDelegateCompat);
}
public void setHourClickDelegate(AccessibilityDelegateCompat accessibilityDelegateCompat) {
ViewCompat.setAccessibilityDelegate(this.minuteView, accessibilityDelegateCompat);
}
private void setUpDisplay() {
this.minuteView.setTag(R.id.selection_type, 12);
this.hourView.setTag(R.id.selection_type, 10);
this.minuteView.setOnClickListener(this.selectionListener);
this.hourView.setOnClickListener(this.selectionListener);
this.minuteView.setAccessibilityClassName(GENERIC_VIEW_ACCESSIBILITY_CLASS_NAME);
this.hourView.setAccessibilityClassName(GENERIC_VIEW_ACCESSIBILITY_CLASS_NAME);
}
@Override // com.google.android.material.timepicker.TimePickerControls
public void setValues(String[] strArr, int i) {
this.clockFace.setValues(strArr, i);
}
@Override // com.google.android.material.timepicker.TimePickerControls
public void setHandRotation(float f) {
this.clockHandView.setHandRotation(f);
}
public void setHandRotation(float f, boolean z) {
this.clockHandView.setHandRotation(f, z);
}
public void setAnimateOnTouchUp(boolean z) {
this.clockHandView.setAnimateOnTouchUp(z);
}
@Override // com.google.android.material.timepicker.TimePickerControls
public void updateTime(int i, int i2, int i3) {
int i4;
if (i == 1) {
i4 = R.id.material_clock_period_pm_button;
} else {
i4 = R.id.material_clock_period_am_button;
}
this.toggle.check(i4);
Locale locale = getResources().getConfiguration().locale;
String format = String.format(locale, TimeModel.ZERO_LEADING_NUMBER_FORMAT, Integer.valueOf(i3));
String format2 = String.format(locale, TimeModel.ZERO_LEADING_NUMBER_FORMAT, Integer.valueOf(i2));
if (!TextUtils.equals(this.minuteView.getText(), format)) {
this.minuteView.setText(format);
}
if (TextUtils.equals(this.hourView.getText(), format2)) {
return;
}
this.hourView.setText(format2);
}
@Override // com.google.android.material.timepicker.TimePickerControls
public void setActiveSelection(int i) {
updateSelection(this.minuteView, i == 12);
updateSelection(this.hourView, i == 10);
}
private void updateSelection(Chip chip, boolean z) {
chip.setChecked(z);
ViewCompat.setAccessibilityLiveRegion(chip, z ? 2 : 0);
}
public void addOnRotateListener(ClockHandView.OnRotateListener onRotateListener) {
this.clockHandView.addOnRotateListener(onRotateListener);
}
public void setOnActionUpListener(ClockHandView.OnActionUpListener onActionUpListener) {
this.clockHandView.setOnActionUpListener(onActionUpListener);
}
public void showToggle() {
this.toggle.setVisibility(0);
}
@Override // android.view.View
protected void onVisibilityChanged(View view, int i) {
super.onVisibilityChanged(view, i);
if (view == this && i == 0) {
this.hourView.sendAccessibilityEvent(8);
}
}
int getCurrentLevel() {
return this.clockFace.getCurrentLevel();
}
void setCurrentLevel(int i) {
this.clockFace.setCurrentLevel(i);
}
}