package com.google.android.material.timepicker;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.text.Editable;
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 com.google.android.material.chip.Chip;
import com.google.android.material.internal.l;
import com.google.android.material.internal.o;
import com.google.android.material.textfield.TextInputLayout;
import l0.h;

/* JADX INFO: loaded from: classes.dex */
class ChipTextInputComboView extends FrameLayout implements Checkable {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private final Chip f4350e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final TextInputLayout f4351f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final EditText f4352g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private TextWatcher f4353h;

    private class b extends l {
        private b() {
        }

        @Override // com.google.android.material.internal.l, android.text.TextWatcher
        public void afterTextChanged(Editable editable) {
            if (TextUtils.isEmpty(editable)) {
                ChipTextInputComboView.this.f4350e.setText(ChipTextInputComboView.this.c("00"));
            } else {
                ChipTextInputComboView.this.f4350e.setText(ChipTextInputComboView.this.c(editable));
            }
        }
    }

    public ChipTextInputComboView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public String c(CharSequence charSequence) {
        return c.j(getResources(), charSequence);
    }

    private void d() {
        if (Build.VERSION.SDK_INT >= 24) {
            this.f4352g.setImeHintLocales(getContext().getResources().getConfiguration().getLocales());
        }
    }

    @Override // android.widget.Checkable
    public boolean isChecked() {
        return this.f4350e.isChecked();
    }

    @Override // android.view.View
    protected void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        d();
    }

    @Override // android.widget.Checkable
    public void setChecked(boolean z2) {
        this.f4350e.setChecked(z2);
        this.f4352g.setVisibility(z2 ? 0 : 4);
        this.f4350e.setVisibility(z2 ? 8 : 0);
        if (isChecked()) {
            o.h(this.f4352g);
            if (TextUtils.isEmpty(this.f4352g.getText())) {
                return;
            }
            EditText editText = this.f4352g;
            editText.setSelection(editText.getText().length());
        }
    }

    @Override // android.view.View
    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.f4350e.setOnClickListener(onClickListener);
    }

    @Override // android.view.View
    public void setTag(int i3, Object obj) {
        this.f4350e.setTag(i3, obj);
    }

    @Override // android.widget.Checkable
    public void toggle() {
        this.f4350e.toggle();
    }

    public ChipTextInputComboView(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(context);
        Chip chip = (Chip) layoutInflaterFrom.inflate(h.f5418g, (ViewGroup) this, false);
        this.f4350e = chip;
        chip.setAccessibilityClassName("android.view.View");
        TextInputLayout textInputLayout = (TextInputLayout) layoutInflaterFrom.inflate(h.f5419h, (ViewGroup) this, false);
        this.f4351f = textInputLayout;
        EditText editText = textInputLayout.getEditText();
        this.f4352g = editText;
        editText.setVisibility(4);
        b bVar = new b();
        this.f4353h = bVar;
        editText.addTextChangedListener(bVar);
        d();
        addView(chip);
        addView(textInputLayout);
        editText.setSaveEnabled(false);
        editText.setLongClickable(false);
    }
}
