APKPure.apk(点击下载) / WebPageFragment.java


package com.apkpure.aegon.pages;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.apkpure.aegon.R;
import com.apkpure.aegon.app.model.SimpleDisplayInfo;
import com.apkpure.aegon.app.newcard.model.AppCardData;
import com.apkpure.aegon.widgets.webview.ApWebChromeClient;
import com.apkpure.aegon.widgets.webview.CustomWebView;
import com.apkpure.proto.nano.OpenConfigProtos;
import com.tencent.raft.codegenmeta.utils.RLog;
import e.g.a.i0.g0;
import e.g.a.i0.i0;
import e.g.a.i0.n0;
import e.g.a.i0.p1;
import e.g.a.m0.m0.c;
import e.g.a.t.b.b;
import e.g.a.t.d.l;
import e.g.a.x.a5;
import e.g.a.x.b5;
import e.g.a.x.y4;
import e.g.a.x.z4;
import e.g.a.z.n.h;
import e.w.e.a.b.t.d.c.a;
import i.o.c.l;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import s.e.a;
import s.e.c;

public class WebPageFragment extends b {
    public static final a w = new c("WebPage");

    /* renamed from: g  reason: collision with root package name */
    public final String f2265g = e.g.a.s.l.a.L();

    /* renamed from: h  reason: collision with root package name */
    public CustomWebView f2266h;

    /* renamed from: i  reason: collision with root package name */
    public SwipeRefreshLayout f2267i;

    /* renamed from: j  reason: collision with root package name */
    public View f2268j;

    /* renamed from: k  reason: collision with root package name */
    public TextView f2269k;

    /* renamed from: l  reason: collision with root package name */
    public Button f2270l;

    /* renamed from: m  reason: collision with root package name */
    public boolean f2271m = false;

    /* renamed from: n  reason: collision with root package name */
    public boolean f2272n = false;

    /* renamed from: o  reason: collision with root package name */
    public String f2273o = null;

    /* renamed from: p  reason: collision with root package name */
    public String f2274p;

    /* renamed from: q  reason: collision with root package name */
    public String f2275q;

    /* renamed from: r  reason: collision with root package name */
    public Map<String, String> f2276r;

    /* renamed from: s  reason: collision with root package name */
    public boolean f2277s = false;

    /* renamed from: t  reason: collision with root package name */
    public boolean f2278t = false;
    public String u = null;
    public boolean v = false;

    public static b newInstance(OpenConfigProtos.OpenConfig openConfig) {
        return b.r1(WebPageFragment.class, openConfig);
    }

    @Override // e.g.a.t.b.b
    public void I1() {
        M1();
    }

    public boolean J1() {
        CustomWebView customWebView = this.f2266h;
        return customWebView != null && customWebView.b();
    }

    public void K1() {
        CustomWebView customWebView = this.f2266h;
        if (customWebView != null) {
            customWebView.d();
        }
    }

    public final void L1(String str) throws URISyntaxException {
        Intent parseUri = Intent.parseUri(str, 1);
        parseUri.addCategory("android.intent.category.BROWSABLE");
        parseUri.setComponent(null);
        parseUri.setSelector(null);
        getActivity().startActivityIfNeeded(parseUri, -1);
    }

    public final void M1() {
        CustomWebView customWebView;
        String str = this.f2274p;
        if (str != null && !str.isEmpty() && (customWebView = this.f2266h) != null) {
            this.f2271m = true;
            this.f2272n = false;
            customWebView.f(this.f2274p);
            e.g.a.d0.b.c(c.a.WEB_PAGE_FRAGMENT, this.f2265g, this.f2274p);
        }
    }

    @Override // e.g.a.t.b.b
    public String X0() {
        return "page_video_download";
    }

    @Override // e.g.a.t.b.b
    public boolean Z0() {
        return e.g.a.s.l.a.d0(this.f2274p);
    }

    @Override // androidx.fragment.app.Fragment
    public void onAttach(Context context) {
        super.onAttach(context);
    }

    @Override // e.g.a.t.b.b, androidx.fragment.app.Fragment
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        OpenConfigProtos.OpenConfig w0 = w0();
        String str = w0.url;
        this.f2274p = str;
        e.g.a.d0.b.g(c.a.WEB_PAGE_FRAGMENT, this.f2265g, str);
        this.f2273o = w0.shareUrl;
        if (e.g.a.s.l.a.d0(this.f2274p)) {
            this.f2277s = true;
        }
        String str2 = this.f2274p;
        if (str2.contains("&gp_jump=") && str2.contains("&package_name=")) {
            try {
                Uri parse = Uri.parse(this.f2274p);
                this.u = parse.getQueryParameter("package_name");
                this.v = "1".equals(parse.getQueryParameter("gp_jump"));
                this.f2278t = true;
            } catch (Throwable th) {
                th.printStackTrace();
            }
        }
        OpenConfigProtos.EventInfo eventInfo = w0.eventInfo;
        if (eventInfo != null) {
            this.f2275q = eventInfo.eventName;
            this.f2276r = eventInfo.eventTag;
        }
        if (!TextUtils.isEmpty(this.f2275q)) {
            g0.o(getActivity(), this.f2275q, this.f2276r);
        }
    }

    @Override // androidx.fragment.app.Fragment
    public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
        menuInflater.inflate(R.menu.arg_RES_2131558421, menu);
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        final l activity = getActivity();
        c.a aVar = c.a.WEB_PAGE_FRAGMENT;
        e.g.a.d0.b.f(aVar, this.f2265g, this.f2274p);
        View inflate = layoutInflater.inflate(R.layout.arg_RES_2131493199, viewGroup, false);
        this.f2267i = (SwipeRefreshLayout) inflate.findViewById(R.id.arg_RES_2131298566);
        e.g.a.d0.b.i(aVar, this.f2265g, this.f2274p);
        try {
            this.f2266h = new CustomWebView(this.d, null);
            this.f2266h.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
            this.f2267i.addView(this.f2266h);
            i.i.d.c.b0(activity, this.f2274p);
            this.f2266h.setWebViewClient(new e.g.a.m0.m0.b() {
                /* class com.apkpure.aegon.pages.WebPageFragment.AnonymousClass1 */

                public void onPageFinished(WebView webView, String str) {
                    WebPageFragment webPageFragment = WebPageFragment.this;
                    if (webPageFragment.f2271m) {
                        if (!webPageFragment.f2272n) {
                            webPageFragment.f2267i.setEnabled(false);
                        }
                        WebPageFragment.this.f2267i.setRefreshing(false);
                        c.a aVar = c.a.WEB_PAGE_FRAGMENT;
                        WebPageFragment webPageFragment2 = WebPageFragment.this;
                        e.g.a.d0.b.d(aVar, webPageFragment2.f2265g, webPageFragment2.f2274p);
                        WebPageFragment.this.f2271m = false;
                    }
                }

                @Override // e.g.a.m0.m0.b
                public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
                    Set<String> set = e.w.e.a.b.t.d.c.a.b;
                    a.b.f12432a.b(webView);
                    WebPageFragment webPageFragment = WebPageFragment.this;
                    if (webPageFragment.f2271m) {
                        webPageFragment.f2267i.setEnabled(true);
                        WebPageFragment.this.f2267i.setVisibility(0);
                        WebPageFragment.this.f2268j.setVisibility(8);
                        WebPageFragment.this.f2267i.setRefreshing(true);
                        c.a aVar = c.a.WEB_PAGE_FRAGMENT;
                        WebPageFragment webPageFragment2 = WebPageFragment.this;
                        e.g.a.d0.b.e(aVar, webPageFragment2.f2265g, webPageFragment2.f2274p);
                    }
                }

                public void onReceivedError(WebView webView, int i2, String str, String str2) {
                    WebPageFragment webPageFragment = WebPageFragment.this;
                    if (webPageFragment.f2271m) {
                        webPageFragment.f2267i.setEnabled(false);
                        WebPageFragment.this.f2267i.setVisibility(8);
                        WebPageFragment.this.f2268j.setVisibility(0);
                        WebPageFragment.this.f2269k.setText(R.string.arg_RES_2131821182);
                        WebPageFragment.this.f2269k.setCompoundDrawablesRelativeWithIntrinsicBounds(0, R.drawable.arg_RES_2131231385, 0, 0);
                        WebPageFragment.this.f2270l.setVisibility(0);
                        WebPageFragment.this.f2267i.setRefreshing(false);
                        WebPageFragment.this.f2271m = false;
                        webView.loadUrl("about:blank");
                    }
                }

                public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
                    WebPageFragment.this.f2272n = true;
                }

                @Override // e.g.a.m0.m0.b, android.webkit.WebViewClient
                public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                    Boolean bool = Boolean.FALSE;
                    s.e.a aVar = WebPageFragment.w;
                    s.e.a aVar2 = WebPageFragment.w;
                    WebPageFragment webPageFragment = WebPageFragment.this;
                    boolean z = webPageFragment.f2277s;
                    boolean z2 = webPageFragment.f2278t;
                    if (z) {
                        if (str.startsWith("http")) {
                            webView.loadUrl(str);
                            return true;
                        } else if (str.startsWith("apkpure://")) {
                            e.g.a.t.d.l.b(WebPageFragment.this.getContext(), new l.a(str), bool);
                            return true;
                        } else if (!str.startsWith("intent://")) {
                            return false;
                        } else {
                            try {
                                WebPageFragment.this.L1(str);
                            } catch (Throwable th) {
                                th.printStackTrace();
                                s.e.a aVar3 = WebPageFragment.w;
                                s.e.a aVar4 = WebPageFragment.w;
                                th.getMessage();
                            }
                            return true;
                        }
                    } else if (z2) {
                        i.i.g.c.d0(((s.e.c) aVar2).f16991a, "isDownloadJumpH5----url----" + str);
                        if (str.startsWith("https://play.google.com/store")) {
                            if (webPageFragment.v || TextUtils.isEmpty(webPageFragment.u)) {
                                n0.t(webPageFragment.getActivity(), str);
                            } else {
                                n0.C(webPageFragment.c, SimpleDisplayInfo.m(webPageFragment.u), null, null);
                                e.g.a.t.d.l.a(webPageFragment.c, webPageFragment.u, 2063, "", "", "");
                            }
                        } else if (str.startsWith("http")) {
                            webView.loadUrl(str);
                        } else if (str.startsWith("apkpure://")) {
                            e.g.a.t.d.l.b(webPageFragment.getContext(), new l.a(str), bool);
                        } else {
                            try {
                                webPageFragment.L1(str);
                            } catch (Throwable th2) {
                                th2.printStackTrace();
                                th2.getMessage();
                            }
                        }
                        return true;
                    } else {
                        Context context = activity;
                        l.a aVar5 = new l.a(str);
                        aVar5.f7143e = false;
                        return e.g.a.t.d.l.b(context, aVar5, bool);
                    }
                }
            });
            this.f2266h.setWebChromeClient(new ApWebChromeClient(activity, new e.g.a.m0.m0.c(aVar, this.f2274p, this.f2265g)) {
                /* class com.apkpure.aegon.pages.WebPageFragment.AnonymousClass2 */

                @Override // com.apkpure.aegon.widgets.webview.ApWebChromeClient
                public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                    ConsoleMessage.MessageLevel messageLevel = consoleMessage.messageLevel();
                    String str = messageLevel == ConsoleMessage.MessageLevel.TIP ? "TIP" : messageLevel == ConsoleMessage.MessageLevel.LOG ? "LOG" : messageLevel == ConsoleMessage.MessageLevel.WARNING ? "WARNING" : messageLevel == ConsoleMessage.MessageLevel.ERROR ? "ERROR" : messageLevel == ConsoleMessage.MessageLevel.DEBUG ? RLog.DEBUG : "UNKNOWN";
                    s.e.a aVar = WebPageFragment.w;
                    ((s.e.c) WebPageFragment.w).d("WebPage", String.format("%s: %s @ %s: %s", str, consoleMessage.message(), String.valueOf(consoleMessage.lineNumber()), consoleMessage.sourceId()));
                    return true;
                }

                public boolean onCreateWindow(WebView webView, boolean z, boolean z2, Message message) {
                    return true;
                }

                @Override // com.apkpure.aegon.widgets.webview.ApWebChromeClient, e.w.e.a.a.e.b.a
                @Override
                public void onProgressChanged(WebView webView, int i2) {
                    Set<String> set = e.w.e.a.b.t.d.c.a.b;
                    a.b.f12432a.c(webView, i2);
                    super.onProgressChanged(webView, i2);
                }

                public void onReceivedTitle(WebView webView, String str) {
                }
            });
            this.f2266h.setDownLoadListener(new z4(this, activity));
            i.i.d.c.D(this.f2266h);
            e.g.a.d0.b.h(aVar, this.f2265g, this.f2274p);
            p1.u(this.d, this.f2267i);
            this.f2267i.setOnRefreshListener(new y4(this));
            this.f2268j = inflate.findViewById(R.id.arg_RES_2131297596);
            this.f2269k = (TextView) inflate.findViewById(R.id.arg_RES_2131297595);
            Button button = (Button) inflate.findViewById(R.id.arg_RES_2131297594);
            this.f2270l = button;
            button.setOnClickListener(new a5(this));
        } catch (Exception e2) {
            i.i.d.c.C(e2);
        }
        e.w.c.e.b.l.b1(this, inflate);
        return inflate;
    }

    @Override // androidx.fragment.app.Fragment
    public void onDestroy() {
        super.onDestroy();
        CustomWebView customWebView = this.f2266h;
        if (customWebView != null) {
            customWebView.removeAllViews();
            this.f2266h.c();
        }
    }

    @Override // androidx.fragment.app.Fragment
    public void onDetach() {
        super.onDetach();
    }

    @Override // androidx.fragment.app.Fragment
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        CustomWebView customWebView;
        if (menuItem.getItemId() == R.id.arg_RES_2131296380) {
            String str = this.f2273o;
            Object obj = h.f7767a;
            h.e(getChildFragmentManager(), str, null, null);
            i0.g(getContext(), "WebPage", "ShareUrl");
            return true;
        }
        if (menuItem.getItemId() == R.id.arg_RES_2131297936) {
            if (!TextUtils.isEmpty(this.f2273o)) {
                n0.t(this.c, this.f2273o);
            }
        } else if (menuItem.getItemId() == R.id.arg_RES_2131298239 && (customWebView = this.f2266h) != null) {
            customWebView.i();
        }
        return super.onOptionsItemSelected(menuItem);
    }

    @Override // e.g.a.t.b.b, e.w.e.a.b.t.c.c, androidx.fragment.app.Fragment
    public void onPause() {
        super.onPause();
        CustomWebView customWebView = this.f2266h;
        if (customWebView != null) {
            customWebView.g();
        }
    }

    @Override // androidx.fragment.app.Fragment
    public void onPrepareOptionsMenu(Menu menu) {
        menu.findItem(R.id.arg_RES_2131296380).setVisible(!TextUtils.isEmpty(this.f2273o));
        menu.findItem(R.id.arg_RES_2131297936).setVisible(!TextUtils.isEmpty(this.f2273o));
        menu.findItem(R.id.arg_RES_2131296979).setVisible(false);
        if (!e.g.a.z.c.f7527a && menu.findItem(R.id.arg_RES_2131296380) != null) {
            menu.findItem(R.id.arg_RES_2131296380).setVisible(false);
        }
    }

    @Override // e.g.a.t.b.b, e.w.e.a.b.t.c.c, androidx.fragment.app.Fragment
    public void onResume() {
        super.onResume();
        g0.q(getActivity(), "web_page", "WebPageFragment");
        CustomWebView customWebView = this.f2266h;
        if (customWebView != null) {
            customWebView.h();
        }
    }

    @Override // e.g.a.t.b.b, androidx.fragment.app.Fragment
    public void onViewCreated(View view, Bundle bundle) {
        super.onViewCreated(view, bundle);
        if (e.g.a.s.l.a.d0(this.f2274p)) {
            HashMap hashMap = new HashMap();
            hashMap.put(AppCardData.KEY_SCENE, 2116L);
            e.g.a.h0.b.h.s(requireView(), AppCardData.KEY_SCENE, hashMap, false);
            HashMap hashMap2 = new HashMap();
            hashMap2.put(AppCardData.KEY_SCENE, 2116L);
            e.g.a.h0.b.h.s(requireView(), AppCardData.KEY_SCENE, hashMap2, false);
            CustomWebView customWebView = this.f2266h;
            if (customWebView != null) {
                customWebView.setOnTouchListener(new b5(this));
            }
        }
    }

    @Override // e.g.a.t.b.b, e.g.a.t.b.h
    public long v1() {
        return 2116;
    }
}