TikTok.apk(点击下载) / VKWebViewAuthActivity.java


package com.vk.api.sdk.ui;

import X.AnonymousClass0VA;
import X.AnonymousClass1IM;
import X.AnonymousClass1YE;
import X.AnonymousClass1ZP;
import X.C16500lD;
import X.C1808778y;
import X.C21290sw;
import X.C23760wv;
import X.C23820x1;
import X.C30301Hv;
import X.C37466EnX;
import X.C37471Enc;
import X.C37473Ene;
import X.C37476Enh;
import X.C37551Eou;
import X.C45324Hqz;
import X.C82193Lk;
import X.EnumC37467EnY;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ProgressBar;
import com.bytedance.covode.number.Covode;
import com.bytedance.sysoptimizer.BadParcelableCrashOptimizer;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.vk.api.sdk.R$id;
import com.vk.api.sdk.VK;
import com.zhiliaoapp.musically.R;
import java.util.ArrayList;
import java.util.Map;
import kotlin.g.b.m;

public class VKWebViewAuthActivity extends Activity {
    public static C37476Enh LIZJ;
    public static final C37471Enc LIZLLL = new C37471Enc((byte) 0);
    public WebView LIZ;
    public ProgressBar LIZIZ;
    public C37466EnX LJ;

    static {
        Covode.recordClassIndex(121102);
    }

    public static View LIZ(Window window) {
        View decorView;
        if (C16500lD.LIZIZ) {
            decorView = window.getDecorView();
        } else {
            synchronized (C16500lD.LIZ) {
                try {
                    decorView = window.getDecorView();
                } finally {
                }
            }
        }
        return decorView;
    }

    public static String LIZ(Intent intent, String str) {
        try {
            return intent.getStringExtra(str);
        } catch (Exception unused) {
            return null;
        }
    }

    public final void LIZ() {
        String str;
        try {
            if (LIZIZ()) {
                str = LIZ(getIntent(), "vk_validation_url");
            } else {
                Uri.Builder buildUpon = Uri.parse("https://oauth.vk.com/authorize").buildUpon();
                C23760wv[] r6 = new C23760wv[7];
                C37466EnX enX = this.LJ;
                if (enX == null) {
                    m.LIZ("");
                }
                r6[0] = C23820x1.LIZ("client_id", String.valueOf(enX.LIZIZ));
                C37466EnX enX2 = this.LJ;
                if (enX2 == null) {
                    m.LIZ("");
                }
                r6[1] = C23820x1.LIZ("scope", AnonymousClass1ZP.LIZ(enX2.LIZ, ",", (CharSequence) null, (CharSequence) null, 0, (CharSequence) null, (AnonymousClass1IM) null, 62));
                C37466EnX enX3 = this.LJ;
                if (enX3 == null) {
                    m.LIZ("");
                }
                r6[2] = C23820x1.LIZ("redirect_uri", enX3.LIZJ);
                r6[3] = C23820x1.LIZ("response_type", "token");
                r6[4] = C23820x1.LIZ("display", "mobile");
                C37551Eou eou = VK.LIZ;
                if (eou == null) {
                    m.LIZ("");
                }
                r6[5] = C23820x1.LIZ("v", eou.LJ);
                r6[6] = C23820x1.LIZ("revoke", "1");
                for (Map.Entry entry : AnonymousClass1YE.LIZ(r6).entrySet()) {
                    buildUpon.appendQueryParameter((String) entry.getKey(), (String) entry.getValue());
                }
                str = buildUpon.build().toString();
            }
            WebView webView = this.LIZ;
            if (webView == null) {
                m.LIZ("");
            }
            String LIZ2 = C82193Lk.LIZ.LIZ(webView, str);
            if (!TextUtils.isEmpty(LIZ2)) {
                str = LIZ2;
            }
            webView.loadUrl(str);
        } catch (Exception unused) {
            setResult(0);
            finish();
        }
    }

    public final boolean LIZIZ() {
        return LIZ(getIntent(), "vk_validation_url") != null;
    }

    public final String LIZJ() {
        if (LIZIZ()) {
            return LIZ(getIntent(), "vk_validation_url");
        }
        C37466EnX enX = this.LJ;
        if (enX == null) {
            m.LIZ("");
        }
        return enX.LIZJ;
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x0051  */
    /* JADX WARNING: Removed duplicated region for block: B:13:0x0061  */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x00a2  */
    public void onCreate(Bundle bundle) {
        ArrayList arrayList;
        WebView webView;
        WebView webView2;
        AnonymousClass0VA.LIZ(this, bundle);
        super.onCreate(bundle);
        setContentView(R.layout.bxj);
        View findViewById = findViewById(R$id.webView);
        m.LIZ((Object) findViewById, "");
        this.LIZ = (WebView) findViewById;
        View findViewById2 = findViewById(R.id.e42);
        m.LIZ((Object) findViewById2, "");
        this.LIZIZ = (ProgressBar) findViewById2;
        Bundle bundleExtra = getIntent().getBundleExtra("vk_auth_params");
        Context context = BadParcelableCrashOptimizer.getContext();
        if (!(bundleExtra == null || context == null)) {
            bundleExtra.setClassLoader(context.getClassLoader());
        }
        if (bundleExtra != null) {
            int i2 = bundleExtra.getInt("vk_app_id");
            ArrayList<String> stringArrayList = bundleExtra.getStringArrayList("vk_app_scope");
            if (stringArrayList != null) {
                ArrayList arrayList2 = new ArrayList(AnonymousClass1ZP.LIZ((Iterable) stringArrayList, 10));
                for (T t : stringArrayList) {
                    m.LIZ((Object) t, "");
                    arrayList2.add(EnumC37467EnY.valueOf(t));
                }
                arrayList = arrayList2;
            } else {
                arrayList = C30301Hv.INSTANCE;
            }
            String string = bundleExtra.getString("vk_app_redirect_url", "https://oauth.vk.com/blank.html");
            m.LIZ((Object) string, "");
            C37466EnX enX = new C37466EnX(i2, string, arrayList);
            if (enX != null) {
                this.LJ = enX;
                webView = this.LIZ;
                if (webView == null) {
                    m.LIZ("");
                }
                C37473Ene ene = new C37473Ene(this);
                if (C21290sw.LIZIZ.LIZ()) {
                    WebSettings settings = webView.getSettings();
                    String userAgentString = settings.getUserAgentString();
                    if (!userAgentString.contains("BytedanceWebview/d8a21c6")) {
                        StringBuilder sb = new StringBuilder(userAgentString);
                        if (!TextUtils.isEmpty(sb)) {
                            sb.append(" ");
                        }
                        sb.append("BytedanceWebview/d8a21c6");
                        settings.setUserAgentString(sb.toString());
                    }
                }
                webView.setWebViewClient(C45324Hqz.LIZ(ene));
                webView.setVerticalScrollBarEnabled(false);
                webView.setVisibility(4);
                webView.setOverScrollMode(2);
                webView2 = this.LIZ;
                if (webView2 == null) {
                    m.LIZ("");
                }
                webView2.getSettings().setJavaScriptEnabled(true);
                LIZ();
            }
        }
        if (!LIZIZ()) {
            finish();
        }
        webView = this.LIZ;
        if (webView == null) {
        }
        C37473Ene ene2 = new C37473Ene(this);
        if (C21290sw.LIZIZ.LIZ()) {
        }
        webView.setWebViewClient(C45324Hqz.LIZ(ene2));
        webView.setVerticalScrollBarEnabled(false);
        webView.setVisibility(4);
        webView.setOverScrollMode(2);
        webView2 = this.LIZ;
        if (webView2 == null) {
        }
        webView2.getSettings().setJavaScriptEnabled(true);
        LIZ();
    }

    public void onDestroy() {
        AnonymousClass0VA.LJ(this);
        WebView webView = this.LIZ;
        if (webView == null) {
            m.LIZ("");
        }
        webView.destroy();
        C1808778y.LIZ.LIZIZ();
        super.onDestroy();
    }

    public void onPause() {
        AnonymousClass0VA.LIZJ(this);
        super.onPause();
    }

    public void onResume() {
        AnonymousClass0VA.LIZIZ(this);
        super.onResume();
    }

    public void onStart() {
        AnonymousClass0VA.LIZ(this);
        super.onStart();
    }

    public void onStop() {
        AnonymousClass0VA.LIZLLL(this);
        super.onStop();
        if (EnterTransitionCrashOptimizer.getContext() != null && Build.VERSION.SDK_INT >= 21) {
            try {
                LIZ(getWindow()).getViewTreeObserver().dispatchOnPreDraw();
            } catch (Throwable unused) {
            }
        }
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                LIZ(getWindow()).getViewTreeObserver().dispatchOnPreDraw();
            } catch (Throwable unused2) {
            }
        }
    }
}