米游社.apk(点击下载) / StartUserAgreeDialog.java


package com.mihoyo.hyperion.views;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.h;
import av.l0;
import av.n0;
import av.s1;
import av.w;
import cb.a;
import com.didiglobal.booster.instrument.ShadowToast;
import com.mihoyo.commlib.bean.KibanaAction;
import com.mihoyo.commlib.utils.ExtensionKt;
import com.mihoyo.commlib.utils.LogUtils;
import com.mihoyo.commlib.utils.SPUtils;
import com.mihoyo.hotfix.runtime.patch.RuntimeDirector;
import com.mihoyo.hyperion.R;
import com.mihoyo.hyperion.app.HyperionApplicationHelper;
import com.mihoyo.hyperion.app.HyperionApplicationHelperKt;
import com.mihoyo.hyperion.app.tasks.LoginTask;
import com.mihoyo.hyperion.app.tasks.MihoyoAbTestInitTask;
import com.mihoyo.hyperion.app.tasks.TrackInitTask;
import com.mihoyo.hyperion.manager.AppConfigManager;
import du.k2;
import ik.e0;
import j9.g0;
import j9.r0;
import java.util.Arrays;
import java.util.Objects;
import m9.m;
import xx.b0;
import xx.c0;
import yi.k;
import zu.l;

public final class StartUserAgreeDialog extends h {

    /* renamed from: f */
    public static final b f37580f = new b(null);
    public static RuntimeDirector m__m;

    /* renamed from: a */
    public final Context f37581a;

    /* renamed from: b */
    public final b.a f37582b;

    /* renamed from: c */
    public final zu.a<k2> f37583c;

    /* renamed from: d */
    public final zu.a<k2> f37584d;

    /* renamed from: e */
    public final c f37585e;

    public interface a {
        void l2(@uz.d c cVar);

        void w2(@uz.d c cVar);
    }

    public static final class b {
        public static RuntimeDirector m__m;

        public static abstract class a {

            /* renamed from: com.mihoyo.hyperion.views.StartUserAgreeDialog$b$a$a */
            public static final class C0301a extends a {

                /* renamed from: a */
                public static final C0301a f37586a = new C0301a();

                public C0301a() {
                    super(null);
                }
            }

            /* renamed from: com.mihoyo.hyperion.views.StartUserAgreeDialog$b$a$b */
            public static abstract class AbstractC0302b extends a {

                /* renamed from: com.mihoyo.hyperion.views.StartUserAgreeDialog$b$a$b$a */
                public static final class C0303a extends AbstractC0302b {

                    /* renamed from: a */
                    public static final C0303a f37587a = new C0303a();

                    public C0303a() {
                        super(null);
                    }
                }

                /* renamed from: com.mihoyo.hyperion.views.StartUserAgreeDialog$b$a$b$b */
                public static final class C0304b extends AbstractC0302b {

                    /* renamed from: a */
                    public static final C0304b f37588a = new C0304b();

                    public C0304b() {
                        super(null);
                    }
                }

                public AbstractC0302b() {
                    super(null);
                }

                public /* synthetic */ AbstractC0302b(w wVar) {
                    this();
                }
            }

            public a() {
            }

            public /* synthetic */ a(w wVar) {
                this();
            }
        }

        /* renamed from: com.mihoyo.hyperion.views.StartUserAgreeDialog$b$b */
        public static final class C0305b extends n0 implements zu.a<k2> {

            /* renamed from: a */
            public static final C0305b f37589a = new C0305b();
            public static RuntimeDirector m__m;

            public C0305b() {
                super(0);
            }

            @Override // zu.a
            public final void invoke() {
                RuntimeDirector runtimeDirector = m__m;
                if (runtimeDirector != null && runtimeDirector.isRedirect(0)) {
                    runtimeDirector.invocationDispatch(0, this, ga.a.f66507a);
                }
            }
        }

        public static final class c extends n0 implements l<a, k2> {
            public static RuntimeDirector m__m;

            /* renamed from: a */
            public final /* synthetic */ zu.a<k2> f37590a;

            /* renamed from: b */
            public final /* synthetic */ androidx.appcompat.app.e f37591b;

            /* renamed from: c */
            public final /* synthetic */ zu.a<k2> f37592c;

            /* JADX INFO: super call moved to the top of the method (can break code semantics) */
            public c(zu.a<k2> aVar, androidx.appcompat.app.e eVar, zu.a<k2> aVar2) {
                super(1);
                this.f37590a = aVar;
                this.f37591b = eVar;
                this.f37592c = aVar2;
            }

            public final void a(a aVar) {
                RuntimeDirector runtimeDirector = m__m;
                boolean z10 = true;
                if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                    l0.p(aVar, "it");
                    if (l0.g(aVar, a.C0301a.f37586a)) {
                        this.f37590a.invoke();
                        return;
                    }
                    if (!l0.g(aVar, a.AbstractC0302b.C0304b.f37588a)) {
                        z10 = l0.g(aVar, a.AbstractC0302b.C0303a.f37587a);
                    }
                    if (z10 && r0.n(this.f37591b)) {
                        new StartUserAgreeDialog(this.f37591b, aVar, this.f37592c, this.f37590a).show();
                        return;
                    }
                    return;
                }
                runtimeDirector.invocationDispatch(0, this, aVar);
            }

            @Override // zu.l
            public /* bridge */ /* synthetic */ k2 invoke(a aVar) {
                a(aVar);
                return k2.f53788a;
            }
        }

        public b() {
        }

        public /* synthetic */ b(w wVar) {
            this();
        }

        /* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.mihoyo.hyperion.views.StartUserAgreeDialog$b */
        /* JADX WARN: Multi-variable type inference failed */
        public static /* synthetic */ void d(b bVar, androidx.appcompat.app.e eVar, zu.a aVar, zu.a aVar2, int i10, Object obj) {
            if ((i10 & 2) != 0) {
                aVar = C0305b.f37589a;
            }
            bVar.c(eVar, aVar, aVar2);
        }

        public final void a(l<? super a, k2> lVar) {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(2)) {
                String string = SPUtils.INSTANCE.getInstance(SPUtils.a.SP_TABLE_COMMON).getString("user_agree_protocol_version_key", "First");
                String user_protocol_version = AppConfigManager.INSTANCE.getConfig().getUser_protocol_version();
                if (user_protocol_version == null) {
                    user_protocol_version = "";
                }
                LogUtils logUtils = LogUtils.INSTANCE;
                logUtils.d("request appconfig isAgreeLatestUserProtocol localVersion:" + string + " netWorkVersion:" + user_protocol_version);
                if (b0.U1(user_protocol_version)) {
                    q8.b.i(q8.b.f104172a, KibanaAction.USER_AGREE_FIRST_FAIL, null, 2, null);
                }
                if (l0.g(string, "First")) {
                    lVar.invoke(a.AbstractC0302b.C0303a.f37587a);
                } else if (!l0.g(string, user_protocol_version)) {
                    lVar.invoke(a.AbstractC0302b.C0304b.f37588a);
                } else {
                    lVar.invoke(a.C0301a.f37586a);
                }
            } else {
                runtimeDirector.invocationDispatch(2, this, lVar);
            }
        }

        public final boolean b() {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector != null && runtimeDirector.isRedirect(0)) {
                return ((Boolean) runtimeDirector.invocationDispatch(0, this, ga.a.f66507a)).booleanValue();
            }
            String string = SPUtils.INSTANCE.getInstance(SPUtils.a.SP_TABLE_COMMON).getString("user_agree_protocol_version_key", "First");
            String user_protocol_version = AppConfigManager.INSTANCE.getConfig().getUser_protocol_version();
            if (user_protocol_version == null) {
                user_protocol_version = "";
            }
            LogUtils logUtils = LogUtils.INSTANCE;
            logUtils.d("request appconfig isAgreeLatestUserProtocol localVersion:" + string + " netWorkVersion:" + user_protocol_version);
            if (b0.U1(user_protocol_version)) {
                q8.b.i(q8.b.f104172a, KibanaAction.USER_AGREE_FIRST_FAIL, null, 2, null);
            }
            if (!l0.g(string, "First") && l0.g(string, user_protocol_version)) {
                return true;
            }
            return false;
        }

        public final void c(androidx.appcompat.app.e eVar, zu.a<k2> aVar, zu.a<k2> aVar2) {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(1)) {
                l0.p(eVar, "context");
                l0.p(aVar, "notAllowCallback");
                l0.p(aVar2, "callback");
                a(new c(aVar2, eVar, aVar));
                return;
            }
            runtimeDirector.invocationDispatch(1, this, eVar, aVar, aVar2);
        }
    }

    public interface c {
        void a();
    }

    public static final class d extends n0 implements zu.a<k2> {
        public static RuntimeDirector m__m;

        /* renamed from: a */
        public final /* synthetic */ StartUserAgreeDialog f37593a;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public d(StartUserAgreeDialog startUserAgreeDialog) {
            super(0);
            this.f37593a = startUserAgreeDialog;
        }

        @Override // zu.a
        public final void invoke() {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                this.f37593a.f37583c.invoke();
                System.exit(0);
                throw new RuntimeException("System.exit returned normally, while it was supposed to halt JVM.");
            }
            runtimeDirector.invocationDispatch(0, this, ga.a.f66507a);
        }
    }

    public static final class e extends n0 implements zu.a<k2> {
        public static RuntimeDirector m__m;

        /* renamed from: a */
        public final /* synthetic */ StartUserAgreeDialog f37594a;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public e(StartUserAgreeDialog startUserAgreeDialog) {
            super(0);
            this.f37594a = startUserAgreeDialog;
        }

        @Override // zu.a
        public final void invoke() {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                SPUtils sPUtils = SPUtils.INSTANCE;
                SPUtils.a aVar = SPUtils.a.SP_TABLE_COMMON;
                g0.v(sPUtils.getInstance(aVar), "comm_app_first_run_dia_agree", true);
                if (!j9.h.f74133a.q()) {
                    HyperionApplicationHelper.INSTANCE.initHotfix();
                    new TrackInitTask(HyperionApplicationHelperKt.getHYPERION_APPLICATION()).initTracker();
                }
                k kVar = k.f162066a;
                if (!kVar.f()) {
                    kVar.n(true);
                }
                new MihoyoAbTestInitTask().run();
                new LoginTask().run();
                SharedPreferences instance = sPUtils.getInstance(aVar);
                String user_protocol_version = AppConfigManager.INSTANCE.getConfig().getUser_protocol_version();
                if (user_protocol_version == null) {
                    user_protocol_version = "";
                }
                g0.t(instance, "user_agree_protocol_version_key", user_protocol_version);
                this.f37594a.f37584d.invoke();
                this.f37594a.dismiss();
                return;
            }
            runtimeDirector.invocationDispatch(0, this, ga.a.f66507a);
        }
    }

    public static final class f extends ClickableSpan {
        public static RuntimeDirector m__m;

        /* renamed from: a */
        public final /* synthetic */ StartUserAgreeDialog f37595a;

        /* renamed from: b */
        public final /* synthetic */ String f37596b;

        public f(StartUserAgreeDialog startUserAgreeDialog, String str) {
            this.f37595a = startUserAgreeDialog;
            this.f37596b = str;
        }

        public void onClick(View view) {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
                l0.p(view, "widget");
                this.f37595a.C(this.f37596b);
                return;
            }
            runtimeDirector.invocationDispatch(0, this, view);
        }

        public void updateDrawState(TextPaint textPaint) {
            RuntimeDirector runtimeDirector = m__m;
            if (runtimeDirector == null || !runtimeDirector.isRedirect(1)) {
                l0.p(textPaint, "ds");
                textPaint.setUnderlineText(false);
                return;
            }
            runtimeDirector.invocationDispatch(1, this, textPaint);
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public StartUserAgreeDialog(Context context, b.a aVar, zu.a<k2> aVar2, zu.a<k2> aVar3) {
        super(context);
        l0.p(context, "mContext");
        l0.p(aVar, "result");
        l0.p(aVar2, "notAllowCallback");
        l0.p(aVar3, "mBlock");
        this.f37581a = context;
        this.f37582b = aVar;
        this.f37583c = aVar2;
        this.f37584d = aVar3;
        e0 e0Var = new e0(this);
        this.f37585e = e0Var;
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        if (context instanceof a) {
            ((a) context).l2(e0Var);
        }
    }

    public static final void B(StartUserAgreeDialog startUserAgreeDialog) {
        View decorView;
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(7)) {
            l0.p(startUserAgreeDialog, "this$0");
            Window window = startUserAgreeDialog.getWindow();
            if (window != null && (decorView = window.getDecorView()) != null) {
                decorView.requestLayout();
                return;
            }
            return;
        }
        runtimeDirector.invocationDispatch(7, null, startUserAgreeDialog);
    }

    public final String A() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(2)) {
            return (String) runtimeDirector.invocationDispatch(2, this, ga.a.f66507a);
        }
        String string = this.f37581a.getString(l0.g(this.f37582b, b.a.AbstractC0302b.C0303a.f37587a) ? R.string.user_agree_content : R.string.user_agree_content_update);
        l0.o(string, "mContext.getString(it)");
        return string;
    }

    public final void C(String str) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(4)) {
            try {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                intent.setData(Uri.parse(str));
                this.f37581a.startActivity(intent);
            } catch (Exception unused) {
                ShadowToast.show(Toast.makeText(this.f37581a.getApplicationContext(), "请安装系统浏览器后访问", 0));
            }
        } else {
            runtimeDirector.invocationDispatch(4, this, str);
        }
    }

    public final void D(SpannableString spannableString, String str, String str2) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(3)) {
            f fVar = new f(this, str2);
            StartUserAgreeDialog$setSpan$textColorSpan$1 startUserAgreeDialog$setSpan$textColorSpan$1 = new StartUserAgreeDialog$setSpan$textColorSpan$1(this);
            int r32 = c0.r3(spannableString, str, 0, false, 6, null);
            spannableString.setSpan(fVar, r32, str.length() + r32, 33);
            spannableString.setSpan(startUserAgreeDialog$setSpan$textColorSpan$1, r32, str.length() + r32, 33);
            return;
        }
        runtimeDirector.invocationDispatch(3, this, spannableString, str, str2);
    }

    @Override // androidx.appcompat.app.h
    public void dismiss() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(5)) {
            super.dismiss();
            Context context = this.f37581a;
            if (context instanceof a) {
                ((a) context).w2(this.f37585e);
                return;
            }
            return;
        }
        runtimeDirector.invocationDispatch(5, this, ga.a.f66507a);
    }

    @Override // androidx.appcompat.app.h
    public void onCreate(Bundle bundle) {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(0)) {
            super.onCreate(bundle);
            setContentView(R.layout.start_user_agree_dialog);
            Window window = getWindow();
            if (window != null) {
                window.setDimAmount(0.0f);
                window.setBackgroundDrawableResource(R.color.black_40);
                WindowManager.LayoutParams attributes = window.getAttributes();
                if (attributes != null) {
                    l0.o(attributes, ph.b.f102085j);
                    attributes.height = -1;
                    attributes.width = -1;
                } else {
                    attributes = null;
                }
                window.setAttributes(attributes);
            }
            View findViewById = findViewById(R.id.dialogRoot);
            if (findViewById != null) {
                ViewGroup.LayoutParams layoutParams = findViewById.getLayoutParams();
                Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
                FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
                layoutParams2.gravity = 17;
                findViewById.setLayoutParams(layoutParams2);
                TextView textView = (TextView) findViewById.findViewById(R.id.mUserDialogCancel);
                l0.o(textView, "mContainerView.mUserDialogCancel");
                ExtensionKt.M(textView, new d(this));
                TextView textView2 = (TextView) findViewById.findViewById(R.id.mUserDialogOK);
                l0.o(textView2, "mContainerView.mUserDialogOK");
                ExtensionKt.M(textView2, new e(this));
                SpannableString z10 = z();
                int i10 = R.id.mUserAgreeTitle;
                ((TextView) findViewById.findViewById(i10)).setText(z10);
                ((TextView) findViewById.findViewById(i10)).setMovementMethod(LinkMovementMethod.getInstance());
                return;
            }
            return;
        }
        runtimeDirector.invocationDispatch(0, this, bundle);
    }

    public void onStart() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector == null || !runtimeDirector.isRedirect(6)) {
            super.onStart();
            m.f89904a.b(this);
            return;
        }
        runtimeDirector.invocationDispatch(6, this, ga.a.f66507a);
    }

    public final SpannableString z() {
        RuntimeDirector runtimeDirector = m__m;
        if (runtimeDirector != null && runtimeDirector.isRedirect(1)) {
            return (SpannableString) runtimeDirector.invocationDispatch(1, this, ga.a.f66507a);
        }
        String string = this.f37581a.getString(R.string.user_agree_protocol);
        l0.o(string, "mContext.getString(R.string.user_agree_protocol)");
        String string2 = this.f37581a.getString(R.string.user_agree_privacy);
        l0.o(string2, "mContext.getString(R.string.user_agree_privacy)");
        String string3 = this.f37581a.getString(R.string.user_third_sdk_list);
        l0.o(string3, "mContext.getString(R.string.user_third_sdk_list)");
        s1 s1Var = s1.f8418a;
        String format = String.format(A(), Arrays.copyOf(new Object[]{string, string2, string3}, 3));
        l0.o(format, "format(format, *args)");
        SpannableString spannableString = new SpannableString(format);
        a.C0113a aVar = cb.a.f14567a;
        D(spannableString, string, aVar.c());
        D(spannableString, string2, "https://m.miyoushe.com/bh3/?type=noHeader&type=inApp#/agreement?type=privacy");
        D(spannableString, string3, aVar.E());
        return spannableString;
    }
}