package defpackage;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
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.strmr.ps.R;
import com.strmr.ps.data.model.UpdateInfo;
import com.strmr.ps.data.repository.ScreenConfigRepository;
import com.strmr.ps.update.UpdateDownloadManager;
import com.strmr.ps.util.PlatformUtils;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lk9a;", "Landroid/app/Dialog;", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class k9a extends Dialog {
    public static final /* synthetic */ int p = 0;
    public final UpdateInfo a;
    public final UpdateDownloadManager b;
    public final i85 c;
    public final qq3 d;
    public MaterialButton e;
    public MaterialButton f;
    public TextView i;
    public View j;
    public ProgressBar k;
    public TextView l;
    public View m;
    public TextView n;
    public boolean o;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public k9a(Context context, UpdateInfo updateInfo, UpdateDownloadManager updateDownloadManager, i85 i85Var, qq3 qq3Var) {
        super(context, R.style.Theme_Strmr_Dialog_Fullscreen);
        cr4.g(updateInfo, "updateInfo");
        this.a = updateInfo;
        this.b = updateDownloadManager;
        this.c = i85Var;
        this.d = qq3Var;
    }

    public final void a() {
        this.o = true;
        View view = this.m;
        if (view == null) {
            cr4.n("buttonSection");
            throw null;
        }
        view.setVisibility(8);
        View view2 = this.j;
        if (view2 == null) {
            cr4.n("progressSection");
            throw null;
        }
        view2.setVisibility(0);
        TextView textView = this.n;
        if (textView == null) {
            cr4.n("permissionWarning");
            throw null;
        }
        textView.setVisibility(8);
        wj0.c(s.a(this.c), null, null, new j9a(this, null), 3);
    }

    @Override // android.app.Dialog
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        requestWindowFeature(1);
        setContentView(R.layout.dialog_update_available);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        int i = getContext().getResources().getDisplayMetrics().widthPixels;
        float f = getContext().getResources().getDisplayMetrics().density;
        boolean z = getContext().getResources().getConfiguration().orientation == 2;
        Context context = getContext();
        cr4.f(context, "getContext(...)");
        int iMin = (PlatformUtils.a.a(context) || z) ? (int) (480 * f) : Math.min((int) (((double) i) * 0.85d), (int) (ScreenConfigRepository.MAX_ROWS_PER_PROFILE * f));
        Window window = getWindow();
        if (window != null) {
            window.setLayout(iMin, -2);
        }
        this.e = (MaterialButton) findViewById(R.id.btn_update);
        this.f = (MaterialButton) findViewById(R.id.btn_exit);
        this.i = (TextView) findViewById(R.id.version_info);
        this.j = findViewById(R.id.progress_section);
        this.k = (ProgressBar) findViewById(R.id.download_progress);
        this.l = (TextView) findViewById(R.id.progress_text);
        this.m = findViewById(R.id.button_section);
        this.n = (TextView) findViewById(R.id.permission_warning);
        MaterialButton materialButton = this.e;
        if (materialButton == null) {
            cr4.n("btnUpdate");
            throw null;
        }
        materialButton.requestFocus();
        MaterialButton materialButton2 = this.e;
        if (materialButton2 == null) {
            cr4.n("btnUpdate");
            throw null;
        }
        materialButton2.setOnClickListener(new h9a(this, 0));
        MaterialButton materialButton3 = this.f;
        if (materialButton3 == null) {
            cr4.n("btnExit");
            throw null;
        }
        materialButton3.setOnClickListener(new h9a(this, 1));
        String version = this.a.getVersion();
        TextView textView = this.i;
        if (textView == null) {
            cr4.n("versionInfo");
            throw null;
        }
        textView.setText(getContext().getString(R.string.update_version_info, "1.1.72", version));
        TextView textView2 = (TextView) findViewById(R.id.dialog_subtitle);
        if (textView2 != null) {
            textView2.setText(getContext().getString(R.string.update_subtitle_text));
        }
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i, KeyEvent keyEvent) {
        cr4.g(keyEvent, "event");
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        if (this.o) {
            return true;
        }
        dismiss();
        this.d.invoke();
        return true;
    }
}
