package defpackage;

import android.app.Dialog;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.lifecycle.s;
import androidx.media3.container.NalUnitUtil;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.switchmaterial.SwitchMaterial;
import com.strmr.ps.R;
import com.strmr.ps.data.repository.PreferencesRepository;
import com.strmr.ps.data.repository.UpdateRepository;
import dagger.hilt.android.AndroidEntryPoint;
import defpackage.q9;
import java.util.concurrent.ExecutorService;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0007\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003¨\u0006\u0004"}, d2 = {"Lan;", "Landroidx/fragment/app/o;", "<init>", "()V", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@AndroidEntryPoint
public final class an extends y34 {
    public UpdateRepository f;
    public l9a i;
    public PreferencesRepository j;
    public MaterialButton k;
    public MaterialButton l;
    public TextView m;
    public TextView n;
    public ProgressBar o;
    public TextView p;
    public SwitchMaterial q;
    public View r;
    public Dialog s;
    public final s9 t;

    public an() {
        s9 s9VarRegisterForActivityResult = registerForActivityResult(new q9.l(), new dj1(this, 1));
        cr4.f(s9VarRegisterForActivityResult, "registerForActivityResult(...)");
        this.t = s9VarRegisterForActivityResult;
    }

    @Override // androidx.fragment.app.o
    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        cr4.g(layoutInflater, "inflater");
        return layoutInflater.inflate(R.layout.fragment_about, viewGroup, false);
    }

    @Override // androidx.fragment.app.o
    public final void onDestroyView() {
        super.onDestroyView();
        Dialog dialog = this.s;
        if (dialog != null) {
            dialog.dismiss();
        }
        this.s = null;
    }

    @Override // androidx.fragment.app.o
    public final void onResume() {
        super.onResume();
        MaterialButton materialButton = this.k;
        if (materialButton != null) {
            materialButton.post(new ag(this, 0));
        } else {
            cr4.n("checkUpdateButton");
            throw null;
        }
    }

    @Override // androidx.fragment.app.o
    public final void onViewCreated(View view, Bundle bundle) {
        cr4.g(view, "view");
        super.onViewCreated(view, bundle);
        this.k = (MaterialButton) view.findViewById(R.id.btn_check_update);
        this.l = (MaterialButton) view.findViewById(R.id.btn_export_logs);
        this.m = (TextView) view.findViewById(R.id.log_path_text);
        this.n = (TextView) view.findViewById(R.id.log_size_text);
        this.o = (ProgressBar) view.findViewById(R.id.update_check_progress);
        this.p = (TextView) view.findViewById(R.id.update_status_text);
        this.q = (SwitchMaterial) view.findViewById(R.id.switch_dev_channel);
        this.r = view.findViewById(R.id.dev_channel_container);
        ((TextView) view.findViewById(R.id.version_name)).setText(getString(R.string.version_format, "1.1.72"));
        ((TextView) view.findViewById(R.id.version_code)).setText(getString(R.string.build_format, 1010723));
        MaterialButton materialButton = this.k;
        if (materialButton == null) {
            cr4.n("checkUpdateButton");
            throw null;
        }
        final int i = 0;
        materialButton.setOnClickListener(new View.OnClickListener(this) { // from class: ai
            public final /* synthetic */ an b;

            {
                this.b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                switch (i) {
                    case 0:
                        an anVar = this.b;
                        MaterialButton materialButton2 = anVar.k;
                        if (materialButton2 == null) {
                            cr4.n("checkUpdateButton");
                            throw null;
                        }
                        materialButton2.setEnabled(false);
                        ProgressBar progressBar = anVar.o;
                        if (progressBar == null) {
                            cr4.n("updateProgress");
                            throw null;
                        }
                        progressBar.setVisibility(0);
                        TextView textView = anVar.p;
                        if (textView == null) {
                            cr4.n("updateStatusText");
                            throw null;
                        }
                        textView.setVisibility(8);
                        i85 viewLifecycleOwner = anVar.getViewLifecycleOwner();
                        cr4.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
                        wj0.c(s.a(viewLifecycleOwner), null, null, new ak(anVar, null), 3);
                        return;
                    case 1:
                        int i2 = Build.VERSION.SDK_INT;
                        an anVar2 = this.b;
                        if (i2 < 29 && sf1.checkSelfPermission(anVar2.requireContext(), "android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
                            anVar2.t.a("android.permission.WRITE_EXTERNAL_STORAGE");
                            return;
                        }
                        i85 viewLifecycleOwner2 = anVar2.getViewLifecycleOwner();
                        cr4.f(viewLifecycleOwner2, "getViewLifecycleOwner(...)");
                        wj0.c(s.a(viewLifecycleOwner2), null, null, new am(anVar2, null), 3);
                        return;
                    default:
                        SwitchMaterial switchMaterial = this.b.q;
                        if (switchMaterial != null) {
                            switchMaterial.toggle();
                            return;
                        } else {
                            cr4.n("devChannelSwitch");
                            throw null;
                        }
                }
            }
        });
        MaterialButton materialButton2 = this.k;
        if (materialButton2 == null) {
            cr4.n("checkUpdateButton");
            throw null;
        }
        final int i2 = 1;
        materialButton2.post(new ag(this, i2));
        SwitchMaterial switchMaterial = this.q;
        if (switchMaterial == null) {
            cr4.n("devChannelSwitch");
            throw null;
        }
        PreferencesRepository preferencesRepository = this.j;
        if (preferencesRepository == null) {
            cr4.n("preferencesRepository");
            throw null;
        }
        switchMaterial.setChecked(preferencesRepository.getDevUpdatesEnabled());
        View view2 = this.r;
        if (view2 == null) {
            cr4.n("devChannelContainer");
            throw null;
        }
        final int i3 = 2;
        view2.setOnClickListener(new View.OnClickListener(this) { // from class: ai
            public final /* synthetic */ an b;

            {
                this.b = this;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view22) {
                switch (i3) {
                    case 0:
                        an anVar = this.b;
                        MaterialButton materialButton22 = anVar.k;
                        if (materialButton22 == null) {
                            cr4.n("checkUpdateButton");
                            throw null;
                        }
                        materialButton22.setEnabled(false);
                        ProgressBar progressBar = anVar.o;
                        if (progressBar == null) {
                            cr4.n("updateProgress");
                            throw null;
                        }
                        progressBar.setVisibility(0);
                        TextView textView = anVar.p;
                        if (textView == null) {
                            cr4.n("updateStatusText");
                            throw null;
                        }
                        textView.setVisibility(8);
                        i85 viewLifecycleOwner = anVar.getViewLifecycleOwner();
                        cr4.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
                        wj0.c(s.a(viewLifecycleOwner), null, null, new ak(anVar, null), 3);
                        return;
                    case 1:
                        int i22 = Build.VERSION.SDK_INT;
                        an anVar2 = this.b;
                        if (i22 < 29 && sf1.checkSelfPermission(anVar2.requireContext(), "android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
                            anVar2.t.a("android.permission.WRITE_EXTERNAL_STORAGE");
                            return;
                        }
                        i85 viewLifecycleOwner2 = anVar2.getViewLifecycleOwner();
                        cr4.f(viewLifecycleOwner2, "getViewLifecycleOwner(...)");
                        wj0.c(s.a(viewLifecycleOwner2), null, null, new am(anVar2, null), 3);
                        return;
                    default:
                        SwitchMaterial switchMaterial2 = this.b.q;
                        if (switchMaterial2 != null) {
                            switchMaterial2.toggle();
                            return;
                        } else {
                            cr4.n("devChannelSwitch");
                            throw null;
                        }
                }
            }
        });
        SwitchMaterial switchMaterial2 = this.q;
        if (switchMaterial2 == null) {
            cr4.n("devChannelSwitch");
            throw null;
        }
        switchMaterial2.setOnCheckedChangeListener(new aj(this, i));
        TextView textView = this.m;
        if (textView == null) {
            cr4.n("logPathText");
            throw null;
        }
        ExecutorService executorService = kq.a;
        textView.setText(kq.d());
        TextView textView2 = this.n;
        if (textView2 == null) {
            cr4.n("logSizeText");
            throw null;
        }
        textView2.setText(getString(R.string.about_log_size, kq.e()));
        MaterialButton materialButton3 = this.l;
        if (materialButton3 != null) {
            materialButton3.setOnClickListener(new View.OnClickListener(this) { // from class: ai
                public final /* synthetic */ an b;

                {
                    this.b = this;
                }

                @Override // android.view.View.OnClickListener
                public final void onClick(View view22) {
                    switch (i2) {
                        case 0:
                            an anVar = this.b;
                            MaterialButton materialButton22 = anVar.k;
                            if (materialButton22 == null) {
                                cr4.n("checkUpdateButton");
                                throw null;
                            }
                            materialButton22.setEnabled(false);
                            ProgressBar progressBar = anVar.o;
                            if (progressBar == null) {
                                cr4.n("updateProgress");
                                throw null;
                            }
                            progressBar.setVisibility(0);
                            TextView textView3 = anVar.p;
                            if (textView3 == null) {
                                cr4.n("updateStatusText");
                                throw null;
                            }
                            textView3.setVisibility(8);
                            i85 viewLifecycleOwner = anVar.getViewLifecycleOwner();
                            cr4.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
                            wj0.c(s.a(viewLifecycleOwner), null, null, new ak(anVar, null), 3);
                            return;
                        case 1:
                            int i22 = Build.VERSION.SDK_INT;
                            an anVar2 = this.b;
                            if (i22 < 29 && sf1.checkSelfPermission(anVar2.requireContext(), "android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
                                anVar2.t.a("android.permission.WRITE_EXTERNAL_STORAGE");
                                return;
                            }
                            i85 viewLifecycleOwner2 = anVar2.getViewLifecycleOwner();
                            cr4.f(viewLifecycleOwner2, "getViewLifecycleOwner(...)");
                            wj0.c(s.a(viewLifecycleOwner2), null, null, new am(anVar2, null), 3);
                            return;
                        default:
                            SwitchMaterial switchMaterial22 = this.b.q;
                            if (switchMaterial22 != null) {
                                switchMaterial22.toggle();
                                return;
                            } else {
                                cr4.n("devChannelSwitch");
                                throw null;
                            }
                    }
                }
            });
        } else {
            cr4.n("exportLogsButton");
            throw null;
        }
    }
}
