package androidx.preference;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

/* loaded from: classes.dex */
public abstract class TwoStatePreference extends Preference {
    protected boolean S;
    private CharSequence T;
    private CharSequence U;
    private boolean V;
    private boolean W;

    public TwoStatePreference(Context context, AttributeSet attributeSet, int i10, int i11) {
        super(context, attributeSet, i10, i11);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.preference.Preference
    public void G() {
        super.G();
        boolean z10 = !S();
        if (a(Boolean.valueOf(z10))) {
            T(z10);
        }
    }

    @Override // androidx.preference.Preference
    protected Object I(TypedArray typedArray, int i10) {
        return Boolean.valueOf(typedArray.getBoolean(i10, false));
    }

    @Override // androidx.preference.Preference
    public boolean Q() {
        return (this.W ? this.S : !this.S) || super.Q();
    }

    public boolean S() {
        return this.S;
    }

    public void T(boolean z10) {
        boolean z11 = this.S != z10;
        if (z11 || !this.V) {
            this.S = z10;
            this.V = true;
            M(z10);
            if (z11) {
                F(Q());
                E();
            }
        }
    }

    public void U(boolean z10) {
        this.W = z10;
    }

    public void V(CharSequence charSequence) {
        this.U = charSequence;
        if (S()) {
            return;
        }
        E();
    }

    public void W(CharSequence charSequence) {
        this.T = charSequence;
        if (S()) {
            E();
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    /* JADX WARN: Removed duplicated region for block: B:12:0x0030  */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0041  */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0049  */
    /* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void X(View view) {
        boolean z10;
        int i10;
        if (!(view instanceof TextView)) {
            return;
        }
        TextView textView = (TextView) view;
        if (this.S && !TextUtils.isEmpty(this.T)) {
            textView.setText(this.T);
        } else {
            if (this.S || TextUtils.isEmpty(this.U)) {
                z10 = true;
                if (z10) {
                    CharSequence y10 = y();
                    if (!TextUtils.isEmpty(y10)) {
                        textView.setText(y10);
                        z10 = false;
                    }
                }
                i10 = z10 ? 8 : 0;
                if (i10 == textView.getVisibility()) {
                    textView.setVisibility(i10);
                    return;
                }
                return;
            }
            textView.setText(this.U);
        }
        z10 = false;
        if (z10) {
        }
        if (z10) {
        }
        if (i10 == textView.getVisibility()) {
        }
    }

    public TwoStatePreference(Context context, AttributeSet attributeSet, int i10) {
        this(context, attributeSet, i10, 0);
    }

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