导航菜单

页面标题

页面副标题

万能钥匙 v1.1.23 - FinHTMLWebLayout.java 源代码

正在查看: 万能钥匙 v1.1.23 应用的 FinHTMLWebLayout.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.finogeeks.lib.applet.page.view.webview;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Environment;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.DownloadListener;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import android.webkit.WebBackForwardList;
import android.webkit.WebHistoryItem;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.FragmentActivity;
import com.finogeeks.lib.applet.R;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.externallib.bottomsheet.BottomSheet;
import com.finogeeks.lib.applet.externallib.bottomsheet.BottomSheetListener;
import com.finogeeks.lib.applet.externallib.bottomsheet.menu.BottomSheetMenuItem;
import com.finogeeks.lib.applet.jsbridge.IJSBridge;
import com.finogeeks.lib.applet.jsbridge.IJSExecutor;
import com.finogeeks.lib.applet.main.host.Host;
import com.finogeeks.lib.applet.main.host.HostBase;
import com.finogeeks.lib.applet.model.Event;
import com.finogeeks.lib.applet.modules.appletloadinglayout.IFinAppletLoadingPage;
import com.finogeeks.lib.applet.modules.ext.C0325a;
import com.finogeeks.lib.applet.modules.ext.s;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.modules.log.FLogCommonTag;
import com.finogeeks.lib.applet.modules.permission.PermissionKt;
import com.finogeeks.lib.applet.modules.request.FileCallback;
import com.finogeeks.lib.applet.modules.request.ImageLoader;
import com.finogeeks.lib.applet.page.view.webview.FinHTMLWebChromeClient;
import com.finogeeks.lib.applet.page.view.webview.j;
import com.finogeeks.lib.applet.sdk.api.AppletWebViewLoadHandler;
import com.finogeeks.lib.applet.utils.FinFileResourceUtil;
import com.finogeeks.lib.applet.utils.ThemeModeUtil;
import com.finogeeks.lib.applet.utils.a0;
import com.finogeeks.lib.applet.utils.c0;
import com.finogeeks.lib.applet.utils.c1;
import com.finogeeks.lib.applet.utils.r;
import com.finogeeks.lib.applet.webview.IWebView;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.d0;
import kotlin.jvm.internal.f0;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.p;
import kotlin.jvm.internal.y;
import lg0.e0;
import org.json.JSONObject;
import tj0.t;
import tj0.u;

@Metadata(d1 = {"\u0000¢\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0010\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010$\n\u0002\u0010\u0000\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0017\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\t\u0018\u00002\u00020\u00012\u00020\u0002:\u0002}~B9\b\u0016\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\b\u0010\u0006\u001a\u0004\u0018\u00010\u0005\u0012\b\u0010\b\u001a\u0004\u0018\u00010\u0007\u0012\b\u0010\n\u001a\u0004\u0018\u00010\t\u0012\b\u0010\f\u001a\u0004\u0018\u00010\u000b¢\u0006\u0004\b\r\u0010\u000eB'\b\u0002\u0012\u0006\u0010\u0010\u001a\u00020\u000f\u0012\n\b\u0002\u0010\u0012\u001a\u0004\u0018\u00010\u0011\u0012\b\b\u0002\u0010\u0014\u001a\u00020\u0013¢\u0006\u0004\b\r\u0010\u0015J\u000f\u0010\u0017\u001a\u0004\u0018\u00010\u0016¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u0019\u001a\u0004\u0018\u00010\u0016¢\u0006\u0004\b\u0019\u0010\u0018J#\u0010\f\u001a\u00020\u001c2\b\u0010\u001a\u001a\u0004\u0018\u00010\u00162\b\u0010\u001b\u001a\u0004\u0018\u00010\u0016H\u0016¢\u0006\u0004\b\f\u0010\u001dJ\r\u0010\u001f\u001a\u00020\u001e¢\u0006\u0004\b\u001f\u0010 J!\u0010#\u001a\u00020\u001c2\b\u0010!\u001a\u0004\u0018\u00010\u00162\u0006\u0010\"\u001a\u00020\u0013H\u0002¢\u0006\u0004\b#\u0010$J/\u0010(\u001a\u00020\u001c2\u0006\u0010!\u001a\u00020\u00162\u0006\u0010%\u001a\u00020\u00162\u0006\u0010&\u001a\u00020\u00162\u0006\u0010'\u001a\u00020\u0016H\u0002¢\u0006\u0004\b(\u0010)J\u0017\u0010+\u001a\u00020\u00162\u0006\u0010*\u001a\u00020\u0016H\u0002¢\u0006\u0004\b+\u0010,J\r\u0010-\u001a\u00020\u0013¢\u0006\u0004\b-\u0010.J+\u00102\u001a\u00020\u00162\u0006\u00100\u001a\u00020/2\n\b\u0002\u0010!\u001a\u0004\u0018\u00010\u00162\b\b\u0002\u00101\u001a\u00020\u001e¢\u0006\u0004\b2\u00103J\r\u00104\u001a\u00020\u001c¢\u0006\u0004\b4\u00105J\u000f\u00106\u001a\u00020\u001cH\u0002¢\u0006\u0004\b6\u00105J\u0019\u00109\u001a\u00020\u001c2\b\u00108\u001a\u0004\u0018\u000107H\u0002¢\u0006\u0004\b9\u0010:J%\u0010=\u001a\u0004\u0018\u00010\u00162\b\u0010;\u001a\u0004\u0018\u00010\u00162\b\u0010<\u001a\u0004\u0018\u00010\u0016H\u0016¢\u0006\u0004\b=\u0010>J+\u0010=\u001a\u00020\u001c2\b\u0010;\u001a\u0004\u0018\u00010\u00162\b\u0010<\u001a\u0004\u0018\u00010\u00162\u0006\u0010\u001a\u001a\u00020\u0016H\u0016¢\u0006\u0004\b=\u0010?J-\u0010C\u001a\u00020\u001c2\u0006\u0010!\u001a\u00020\u00162\u0016\b\u0002\u0010B\u001a\u0010\u0012\u0004\u0012\u00020\u0016\u0012\u0004\u0012\u00020A\u0018\u00010@¢\u0006\u0004\bC\u0010DJ'\u0010I\u001a\u00020\u001c2\u0006\u0010E\u001a\u00020\u00132\u0006\u0010F\u001a\u00020\u00132\b\u0010H\u001a\u0004\u0018\u00010G¢\u0006\u0004\bI\u0010JJ-\u0010L\u001a\u00020\u001c2\b\u0010;\u001a\u0004\u0018\u00010\u00162\b\u0010<\u001a\u0004\u0018\u00010\u00162\b\u0010K\u001a\u0004\u0018\u00010\u0016H\u0016¢\u0006\u0004\bL\u0010?J\u000f\u0010M\u001a\u00020\u001cH\u0002¢\u0006\u0004\bM\u00105J\u000f\u0010N\u001a\u00020\u001cH\u0002¢\u0006\u0004\bN\u00105J/\u0010O\u001a\u00020\u001c2\u0006\u0010H\u001a\u00020\u00162\u0006\u0010'\u001a\u00020\u00162\u0006\u0010%\u001a\u00020\u00162\u0006\u0010&\u001a\u00020\u0016H\u0002¢\u0006\u0004\bO\u0010)J\u000f\u0010P\u001a\u00020\u001eH\u0002¢\u0006\u0004\bP\u0010 J#\u0010Q\u001a\u00020\u001c2\u0006\u00100\u001a\u00020/2\n\b\u0002\u0010!\u001a\u0004\u0018\u00010\u0016H\u0007¢\u0006\u0004\bQ\u0010RJ#\u0010S\u001a\u00020\u001c2\b\u0010\u001a\u001a\u0004\u0018\u00010\u00162\b\u0010\u001b\u001a\u0004\u0018\u00010\u0016H\u0016¢\u0006\u0004\bS\u0010\u001dJ+\u0010T\u001a\u00020\u001c2\b\u0010;\u001a\u0004\u0018\u00010\u00162\b\u0010<\u001a\u0004\u0018\u00010\u00162\u0006\u0010\u001a\u001a\u00020\u0016H\u0016¢\u0006\u0004\bT\u0010?J\r\u0010U\u001a\u00020\u001e¢\u0006\u0004\bU\u0010 R\"\u0010V\u001a\u00020\u001e8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bV\u0010W\u001a\u0004\bX\u0010 \"\u0004\bY\u0010ZR\u001b\u0010^\u001a\u00020\u00168VX\u0096\u0084\u0002¢\u0006\f\n\u0004\b[\u0010\\\u001a\u0004\b]\u0010\u0018R\u001b\u0010c\u001a\u00020_8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b`\u0010\\\u001a\u0004\ba\u0010bR\u0018\u0010\u0006\u001a\u0004\u0018\u00010\u00058\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0006\u0010dR\u0018\u0010\f\u001a\u0004\u0018\u00010\u000b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\f\u0010eR\u0018\u0010f\u001a\u0004\u0018\u00010\u00168\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bf\u0010gR\u0018\u0010i\u001a\u0004\u0018\u00010h8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bi\u0010jR\u0016\u0010\u0004\u001a\u00020\u00038\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0004\u0010kR\u0018\u0010l\u001a\u0004\u0018\u00010\u00168\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bl\u0010gR\u0018\u0010\n\u001a\u0004\u0018\u00010\t8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\n\u0010mR\u0016\u0010o\u001a\u00020n8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\bo\u0010pR\u0016\u0010q\u001a\u00020\u001e8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bq\u0010WR\u0018\u0010s\u001a\u0004\u0018\u00010r8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bs\u0010tR\u0018\u0010\b\u001a\u0004\u0018\u00010\u00078\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\b\u0010uR\"\u0010w\u001a\u00020v8\u0006@\u0006X\u0086.¢\u0006\u0012\n\u0004\bw\u0010x\u001a\u0004\by\u0010z\"\u0004\b{\u0010|¨\u0006\u007f"}, d2 = {"Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebLayout;", "Landroid/widget/FrameLayout;", "Lcom/finogeeks/lib/applet/jsbridge/IJSBridge;", "Lcom/finogeeks/lib/applet/main/host/Host;", "host", "Lcom/finogeeks/lib/applet/api/ApisManager;", "apisManager", "Lcom/finogeeks/lib/applet/api/WebApisManager;", "webApisManager", "Lcom/finogeeks/lib/applet/page/view/webview/FinPageWebView;", "pageWebView", "Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebLayout$Callback;", "callback", "<init>", "(Lcom/finogeeks/lib/applet/main/host/Host;Lcom/finogeeks/lib/applet/api/ApisManager;Lcom/finogeeks/lib/applet/api/WebApisManager;Lcom/finogeeks/lib/applet/page/view/webview/FinPageWebView;Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebLayout$Callback;)V", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "", "defStyleAttr", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "", "getUrl", "()Ljava/lang/String;", "getUserAgent", "callbackId", "result", "Llg0/e0;", "(Ljava/lang/String;Ljava/lang/String;)V", "", "canWebViewGoBack", "()Z", "url", "progress", "checkNotifyOnWebViewLoaded", "(Ljava/lang/String;I)V", "contentDisposition", "mimeType", "fileName", "downloadFile", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "dataUrl", "extractDataUrl", "(Ljava/lang/String;)Ljava/lang/String;", "gePageWebViewId", "()I", "Lcom/finogeeks/lib/applet/modules/domain/DomainCheckResult;", "checkResult", "includeErrorCode", "getErrorMessage", "(Lcom/finogeeks/lib/applet/modules/domain/DomainCheckResult;Ljava/lang/String;Z)Ljava/lang/String;", "hideErrorLayout", "()V", "init", "Lcom/finogeeks/lib/applet/client/FinAppConfig$UIConfig;", "uiConfig", "initErrorView", "(Lcom/finogeeks/lib/applet/client/FinAppConfig$UIConfig;)V", FinFileResourceUtil.KEY_EVENT, "params", "invoke", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "", "", "headers", "loadNetworkUrl", "(Ljava/lang/String;Ljava/util/Map;)V", "requestCode", "resultCode", "Landroid/content/Intent;", "data", "onActivityResult", "(IILandroid/content/Intent;)V", "viewIds", "publish", "reload", "resetTimeoutStatus", "saveDataToFile", "saveImageByLonePress", "showErrorLayout", "(Lcom/finogeeks/lib/applet/modules/domain/DomainCheckResult;Ljava/lang/String;)V", "webCallback", "webInvoke", "webViewGoBack", "needClearWebViewHistory", "Z", "getNeedClearWebViewHistory", "setNeedClearWebViewHistory", "(Z)V", "bridgeTag$delegate", "Llg0/h;", "getBridgeTag", "bridgeTag", "Landroidx/fragment/app/FragmentActivity;", "activity$delegate", "getActivity", "()Landroid/support/v4/app/FragmentActivity;", "activity", "Lcom/finogeeks/lib/applet/api/ApisManager;", "Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebLayout$Callback;", "errorNetworkUrl", "Ljava/lang/String;", "Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebChromeClient;", "finHTMLWebChromeClient", "Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebChromeClient;", "Lcom/finogeeks/lib/applet/main/host/Host;", "pageStartedNetworkUrl", "Lcom/finogeeks/lib/applet/page/view/webview/FinPageWebView;", "Landroid/widget/ProgressBar;", "progressBar", "Landroid/widget/ProgressBar;", "timeout", "Ljava/lang/Runnable;", "timeoutRunnable", "Ljava/lang/Runnable;", "Lcom/finogeeks/lib/applet/api/WebApisManager;", "Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebView;", "webView", "Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebView;", "getWebView", "()Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebView;", "setWebView", "(Lcom/finogeeks/lib/applet/page/view/webview/FinHTMLWebView;)V", "Callback", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class FinHTMLWebLayout extends FrameLayout implements IJSBridge {
    static final hh0.l[] p = {g0.j(new y(g0.b(FinHTMLWebLayout.class), "activity", "getActivity()Landroid/support/v4/app/FragmentActivity;")), g0.j(new y(g0.b(FinHTMLWebLayout.class), "bridgeTag", "getBridgeTag()Ljava/lang/String;"))};
    private Host a;
    private final lg0.h b;
    public com.finogeeks.lib.applet.page.view.webview.f c;
    private ProgressBar d;
    private com.finogeeks.lib.applet.api.d e;
    private com.finogeeks.lib.applet.api.g f;
    private com.finogeeks.lib.applet.page.view.webview.h g;
    private a h;
    private FinHTMLWebChromeClient i;
    private boolean j;
    private Runnable k;
    private String l;
    private String m;
    private final lg0.h n;
    private HashMap o;

    public interface a {
        void a();

        void a(String str);
    }

    public static final class b {
        private b() {
        }

        public b(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }
    }

    public static final class c extends p implements ah0.a<FragmentActivity> {
        public c() {
            super(0);
        }

        public final FragmentActivity m740invoke() {
            return FinHTMLWebLayout.d(FinHTMLWebLayout.this).getK();
        }
    }

    public static final class d extends p implements ah0.a<String> {
        public d() {
            super(0);
        }

        public final String invoke() {
            return "FinHTMLWebLayout@" + FinHTMLWebLayout.this.getWebView().getViewId();
        }
    }

    public static final class e implements com.finogeeks.lib.applet.i.domain.a {
        public e() {
        }

        @Override
        public void a(String str, com.finogeeks.lib.applet.i.domain.b bVar) {
            n.j(str, "url");
            n.j(bVar, "checkResult");
            FinHTMLWebLayout.this.a(bVar, str);
        }
    }

    public static final class f implements View.OnLongClickListener {
        public static final f a = new f();

        @Override
        public final boolean onLongClick(View view) {
            return false;
        }
    }

    public static final class g implements View.OnLongClickListener {
        public g() {
        }

        @Override
        public final boolean onLongClick(View view) {
            return FinHTMLWebLayout.this.i();
        }
    }

    public static final class h implements j.a {
        public h() {
        }

        @Override
        public void a(com.finogeeks.lib.applet.i.domain.b bVar, String str) {
            n.j(bVar, "checkResult");
            n.j(str, "url");
            FinHTMLWebLayout.this.a(bVar, str);
        }

        @Override
        public void a(IWebView iWebView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
            n.j(iWebView, "webView");
            n.j(webResourceRequest, FLogCommonTag.REQUEST);
            n.j(webResourceResponse, "response");
            FLog.d$default("FinHTMLWebLayout", "WebViewClient onReceivedHttpError", null, 4, null);
            Uri url = webResourceRequest.getUrl();
            String uri = url != null ? url.toString() : null;
            if (uri == null) {
                uri = "";
            }
            a(iWebView, uri, webResourceRequest.isForMainFrame(), webResourceResponse.getStatusCode(), webResourceResponse.getReasonPhrase());
        }

        @Override
        public void a(IWebView iWebView, String str) {
            n.j(iWebView, "webView");
            n.j(str, "url");
            FLog.d$default("FinHTMLWebLayout", "WebViewClient onPageFinished url : " + str + " & errorNetworkUrl : " + FinHTMLWebLayout.this.l, null, 4, null);
            FinHTMLWebLayout.this.h();
            FinHTMLWebLayout.this.a(str, iWebView.getProgress());
        }

        @Override
        public void a(IWebView iWebView, String str, boolean z10) {
            n.j(iWebView, "webView");
            n.j(str, "url");
            FLog.d$default("FinHTMLWebLayout", "doUpdateVisitedHistory url : " + str, null, 4, null);
            if (URLUtil.isNetworkUrl(str)) {
                FinHTMLWebLayout.this.m = str;
            }
            a aVar = FinHTMLWebLayout.this.h;
            if (aVar != null) {
                aVar.a();
            }
            if (FinHTMLWebLayout.this.getJ()) {
                iWebView.clearHistory();
                FinHTMLWebLayout.this.setNeedClearWebViewHistory(false);
            }
        }

        @Override
        public void a(IWebView iWebView, String str, boolean z10, int i, String str2) {
            String str3;
            n.j(iWebView, "webView");
            FLog.d$default("FinHTMLWebLayout", "WebViewClient onReceivedError url: " + str + ", isForMainFrame: " + z10 + ", code: " + i + ", error: " + str2, null, 4, null);
            if (URLUtil.isNetworkUrl(str) && z10 && i != -1) {
                FinHTMLWebLayout.this.l = str;
                if (str2 == null || t.y(str2)) {
                    str3 = "{}";
                } else {
                    str3 = new JSONObject().put("code", i).put("errMsg", str2).put("src", str).toString();
                    n.e(str3, "JSONObject()\n           …              .toString()");
                }
                HostBase.sendToServiceJSBridge$default(FinHTMLWebLayout.d(FinHTMLWebLayout.this), "onWebviewError", str3, Integer.valueOf(FinHTMLWebLayout.this.e()), null, 8, null);
            }
        }

        @Override
        public void b(IWebView iWebView, String str) {
            n.j(iWebView, "webView");
            n.j(str, "url");
            FLog.d$default("FinHTMLWebLayout", "onPageStarted webView url : " + str, null, 4, null);
            if (URLUtil.isNetworkUrl(str)) {
                FinHTMLWebLayout.this.l = null;
                FinHTMLWebLayout.this.m = str;
            }
        }
    }

    public static final class i implements FinHTMLWebChromeClient.a {
        final FinAppConfig b;

        public i(FinAppConfig finAppConfig) {
            this.b = finAppConfig;
        }

        @Override
        public void a(IWebView iWebView, int i) {
            n.j(iWebView, "webView");
            String url = iWebView.getUrl();
            FLog.d$default("FinHTMLWebLayout", "onProgressChanged url:" + url + ", progress:" + i, null, 4, null);
            FinAppConfig.UIConfig uiConfig = this.b.getUiConfig();
            if (uiConfig == null || !uiConfig.isHideWebViewProgressBar()) {
                FinHTMLWebLayout.e(FinHTMLWebLayout.this).setProgress(i);
                if (1 <= i && 99 >= i) {
                    FinHTMLWebLayout.e(FinHTMLWebLayout.this).setVisibility(0);
                } else {
                    FinHTMLWebLayout.e(FinHTMLWebLayout.this).setVisibility(8);
                }
            }
            FinHTMLWebLayout.this.a(url, i);
        }

        @Override
        public void a(IWebView iWebView, String str) {
            n.j(iWebView, "webView");
            FLog.d$default("FinHTMLWebLayout", "onReceivedTitle title : " + str, null, 4, null);
            a aVar = FinHTMLWebLayout.this.h;
            if (aVar == null || str == null || t.y(str) || URLUtil.isValidUrl(str) || URLUtil.isDataUrl(str)) {
                return;
            }
            aVar.a(str);
        }
    }

    @Metadata(d1 = {"\u0000\u0016\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u000b\u001a\u00020\b2\u000e\u0010\u0002\u001a\n \u0001*\u0004\u0018\u00010\u00000\u00002\u000e\u0010\u0003\u001a\n \u0001*\u0004\u0018\u00010\u00000\u00002\u000e\u0010\u0004\u001a\n \u0001*\u0004\u0018\u00010\u00000\u00002\u000e\u0010\u0005\u001a\n \u0001*\u0004\u0018\u00010\u00000\u00002\u0006\u0010\u0007\u001a\u00020\u0006H\n¢\u0006\u0004\b\t\u0010\n"}, d2 = {"", "kotlin.jvm.PlatformType", "url", "userAgent", "contentDisposition", "mimeType", "", "contentLength", "Llg0/e0;", "onDownloadStart", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
    public static final class j implements DownloadListener {

        public static final class a implements DialogInterface.OnClickListener {
            public static final a a = new a();

            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
            }
        }

        @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\b\u001a\u00020\u00052\u000e\u0010\u0002\u001a\n \u0001*\u0004\u0018\u00010\u00000\u00002\u0006\u0010\u0004\u001a\u00020\u0003H\n¢\u0006\u0004\b\u0006\u0010\u0007"}, d2 = {"Landroid/content/DialogInterface;", "kotlin.jvm.PlatformType", "<anonymous parameter 0>", "", "<anonymous parameter 1>", "Llg0/e0;", "onClick", "(Landroid/content/DialogInterface;I)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
        public static final class b implements DialogInterface.OnClickListener {
            final String b;
            final String c;
            final String d;
            final f0 e;

            public static final class a extends p implements ah0.a<e0> {
                public a() {
                    super(0);
                }

                public Object invoke() {
                    m742invoke();
                    return e0.a;
                }

                public final void m742invoke() {
                    b bVar = b.this;
                    FinHTMLWebLayout finHTMLWebLayout = FinHTMLWebLayout.this;
                    String str = bVar.b;
                    n.e(str, "url");
                    String str2 = b.this.c;
                    n.e(str2, "contentDisposition");
                    String str3 = b.this.d;
                    n.e(str3, "mimeType");
                    String str4 = (String) b.this.e.a;
                    n.e(str4, "fileName");
                    finHTMLWebLayout.a(str, str2, str3, str4);
                }
            }

            public static final class C0229b extends p implements ah0.l<String[], e0> {
                public static final C0229b a = new C0229b();

                public C0229b() {
                    super(1);
                }

                public final void a(String[] strArr) {
                    n.j(strArr, "it");
                }

                public Object invoke(Object obj) {
                    a((String[]) obj);
                    return e0.a;
                }
            }

            public static final class c extends p implements ah0.a<e0> {
                public static final c a = new c();

                public c() {
                    super(0);
                }

                public Object invoke() {
                    m743invoke();
                    return e0.a;
                }

                public final void m743invoke() {
                }
            }

            public b(String str, String str2, String str3, f0 f0Var) {
                this.b = str;
                this.c = str2;
                this.d = str3;
                this.e = f0Var;
            }

            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                PermissionKt.checkPermissions$default(FinHTMLWebLayout.this.getActivity(), new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, new a(), null, C0229b.a, c.a, 4, null);
            }
        }

        public j() {
        }

        @Override
        public final void onDownloadStart(String str, String str2, String str3, String str4, long j) {
            FLog.d$default("FinHTMLWebLayout", "onDownloadStart " + str + ", " + str2 + ", " + str3 + ", " + str4 + ", " + j, null, 4, null);
            f0 f0Var = new f0();
            String a2 = r.a(str, str3, str4);
            f0Var.a = a2;
            if (a2 == null || a2.length() == 0) {
                f0Var.a = a0.a(str);
            }
            new AlertDialog.Builder(FinHTMLWebLayout.this.getContext()).setTitle(FinHTMLWebLayout.this.getContext().getString(R.string.fin_applet_download_tips)).setMessage(FinHTMLWebLayout.this.getContext().getString(R.string.fin_applet_download_or_not) + ((String) f0Var.a) + (char) 65311).setNegativeButton(FinHTMLWebLayout.this.getContext().getString(R.string.fin_applet_cancel), a.a).setPositiveButton(FinHTMLWebLayout.this.getContext().getString(R.string.fin_applet_confirm), new b(str, str3, str4, f0Var)).setCancelable(true).show();
        }
    }

    @Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0004\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lcom/finogeeks/lib/applet/ipc/IFinAppAidlServer;", "Llg0/e0;", "invoke", "(Lcom/finogeeks/lib/applet/ipc/IFinAppAidlServer;)V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
    public static final class k extends p implements ah0.l<com.finogeeks.lib.applet.ipc.h, e0> {
        final String b;
        final Map c;

        public static final class a implements AppletWebViewLoadHandler.UrlCanLoadCallback {
            final f0 b;

            public a(f0 f0Var) {
                this.b = f0Var;
            }

            @Override
            public void onResult(boolean z10) {
                if (z10) {
                    com.finogeeks.lib.applet.page.view.webview.f webView = FinHTMLWebLayout.this.getWebView();
                    k kVar = k.this;
                    webView.a(kVar.b, kVar.c, (Map) this.b.a);
                }
            }
        }

        public k(String str, Map map) {
            super(1);
            this.b = str;
            this.c = map;
        }

        public final void a(com.finogeeks.lib.applet.ipc.h hVar) {
            n.j(hVar, "$receiver");
            f0 f0Var = new f0();
            f0Var.a = null;
            try {
                f0Var.a = hVar.getWebViewCookie(FinHTMLWebLayout.d(FinHTMLWebLayout.this).getAppId());
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            AppletWebViewLoadHandler companion = AppletWebViewLoadHandler.INSTANCE.getInstance(FinHTMLWebLayout.d(FinHTMLWebLayout.this).getFinAppConfig().getAppletWebViewLoadHandlerClass());
            if (companion == null || n.d(this.b, "about:blank")) {
                FinHTMLWebLayout.this.getWebView().a(this.b, this.c, (Map) f0Var.a);
                return;
            }
            Context context = FinHTMLWebLayout.this.getContext();
            n.e(context, "context");
            companion.webviewCanLoadUrl(context, FinHTMLWebLayout.d(FinHTMLWebLayout.this).getB(), this.b, new a(f0Var));
        }

        public Object invoke(Object obj) {
            a((com.finogeeks.lib.applet.ipc.h) obj);
            return e0.a;
        }
    }

    @Metadata(d1 = {"\u0000-\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0004*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J!\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\b\u0010\u0005\u001a\u0004\u0018\u00010\u0004H\u0016¢\u0006\u0004\b\u0007\u0010\bJ+\u0010\u000b\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\b\u0010\n\u001a\u0004\u0018\u00010\t2\b\u0010\u0005\u001a\u0004\u0018\u00010\u0004H\u0016¢\u0006\u0004\b\u000b\u0010\fJ)\u0010\u000f\u001a\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00022\b\u0010\u0005\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u000e\u001a\u00020\rH\u0016¢\u0006\u0004\b\u000f\u0010\u0010¨\u0006\u0011"}, d2 = {"com/finogeeks/lib/applet/page/view/webview/FinHTMLWebLayout$saveImageByLonePress$1", "Lcom/finogeeks/lib/applet/externallib/bottomsheet/BottomSheetListener;", "Lcom/finogeeks/lib/applet/externallib/bottomsheet/BottomSheet;", "bottomSheet", "", "object", "Llg0/e0;", "onSheetShown", "(Lcom/finogeeks/lib/applet/externallib/bottomsheet/BottomSheet;Ljava/lang/Object;)V", "Landroid/view/MenuItem;", "item", "onSheetItemSelected", "(Lcom/finogeeks/lib/applet/externallib/bottomsheet/BottomSheet;Landroid/view/MenuItem;Ljava/lang/Object;)V", "", "dismissEvent", "onSheetDismissed", "(Lcom/finogeeks/lib/applet/externallib/bottomsheet/BottomSheet;Ljava/lang/Object;I)V", "finapplet_release"}, k = 1, mv = {1, 4, 0})
    public static final class l implements BottomSheetListener {
        final String b;

        @Metadata(d1 = {"\u0000\b\n\u0002\u0018\u0002\n\u0002\b\u0003\u0010\u0003\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0001\u0010\u0002"}, d2 = {"Llg0/e0;", "invoke", "()V", "<anonymous>"}, k = 3, mv = {1, 4, 0})
        public static final class a extends p implements ah0.a<e0> {

            @Metadata(d1 = {"\u0000\u0019\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u000f\u0010\u0003\u001a\u00020\u0002H\u0016¢\u0006\u0004\b\u0003\u0010\u0004J\u0017\u0010\u0007\u001a\u00020\u00022\u0006\u0010\u0006\u001a\u00020\u0005H\u0016¢\u0006\u0004\b\u0007\u0010\b¨\u0006\t"}, d2 = {"com/finogeeks/lib/applet/page/view/webview/FinHTMLWebLayout$saveImageByLonePress$1$onSheetItemSelected$1$1", "Lcom/finogeeks/lib/applet/modules/imageloader/FileCallback;", "Llg0/e0;", "onLoadFailure", "()V", "Ljava/io/File;", "r", "onLoadSuccess", "(Ljava/io/File;)V", "finapplet_release"}, k = 1, mv = {1, 4, 0})
            public static final class C0230a implements FileCallback {

                public static final class RunnableC0231a implements Runnable {
                    public RunnableC0231a() {
                    }

                    @Override
                    public final void run() {
                        gq.g.b(Toast.makeText((Context) FinHTMLWebLayout.this.getActivity(), (CharSequence) FinHTMLWebLayout.this.getActivity().getString(R.string.fin_applet_save_image_to_phone_failed), 0));
                    }
                }

                public static final class b implements Runnable {
                    final boolean b;
                    final File c;

                    public b(boolean z10, File file) {
                        this.b = z10;
                        this.c = file;
                    }

                    @Override
                    public final void run() {
                        if (this.b) {
                            gq.g.b(Toast.makeText((Context) FinHTMLWebLayout.this.getActivity(), (CharSequence) FinHTMLWebLayout.this.getActivity().getString(R.string.fin_applet_save_image_to_phone_succeed, this.c.getAbsolutePath()), 0));
                        } else {
                            gq.g.b(Toast.makeText((Context) FinHTMLWebLayout.this.getActivity(), (CharSequence) FinHTMLWebLayout.this.getActivity().getString(R.string.fin_applet_save_image_to_phone_failed), 0));
                        }
                    }
                }

                public C0230a() {
                }

                @Override
                public void onLoadSuccess(File file) {
                    File file2;
                    String valueOf;
                    n.j(file, "r");
                    String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(l.this.b);
                    if (fileExtensionFromUrl == null || fileExtensionFromUrl.length() == 0) {
                        file2 = file;
                    } else {
                        file2 = new File(file.getParent(), yg0.n.w(file) + '.' + fileExtensionFromUrl);
                    }
                    if (!n.d(file2, file)) {
                        file.renameTo(file2);
                    }
                    File file3 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "/Pictures");
                    if (!file3.exists()) {
                        file3.mkdirs();
                    }
                    if (fileExtensionFromUrl == null || fileExtensionFromUrl.length() == 0) {
                        valueOf = String.valueOf(System.currentTimeMillis());
                    } else {
                        valueOf = System.currentTimeMillis() + '.' + fileExtensionFromUrl;
                    }
                    FinHTMLWebLayout.this.getActivity().runOnUiThread(new b(c0.a(file2, (Context) FinHTMLWebLayout.this.getActivity(), c1.IMAGE, valueOf, Environment.DIRECTORY_DCIM, "Pictures") != null, file3));
                }

                @Override
                public void onLoadFailure() {
                    FinHTMLWebLayout.this.getActivity().runOnUiThread(new RunnableC0231a());
                }
            }

            public a() {
                super(0);
            }

            public Object invoke() {
                m744invoke();
                return e0.a;
            }

            public final void m744invoke() {
                ImageLoader.INSTANCE.get(FinHTMLWebLayout.this.getActivity()).load(l.this.b, new C0230a());
            }
        }

        public static final class b extends p implements ah0.l<String[], e0> {
            public static final b a = new b();

            public b() {
                super(1);
            }

            public final void a(String[] strArr) {
                n.j(strArr, "it");
            }

            public Object invoke(Object obj) {
                a((String[]) obj);
                return e0.a;
            }
        }

        public static final class c extends p implements ah0.a<e0> {
            public static final c a = new c();

            public c() {
                super(0);
            }

            public Object invoke() {
                m745invoke();
                return e0.a;
            }

            public final void m745invoke() {
            }
        }

        public l(String str) {
            this.b = str;
        }

        @Override
        public void onSheetDismissed(BottomSheet bottomSheet, Object object, int dismissEvent) {
            n.j(bottomSheet, "bottomSheet");
        }

        @Override
        public void onSheetItemSelected(BottomSheet bottomSheet, MenuItem item, Object object) {
            String str;
            n.j(bottomSheet, "bottomSheet");
            if (!n.d(item != null ? item.getTitle() : null, FinHTMLWebLayout.this.getActivity().getString(R.string.fin_applet_save_image_to_phone)) || (str = this.b) == null || str.length() == 0) {
                return;
            }
            C0325a.a((Activity) FinHTMLWebLayout.this.getActivity(), (ah0.a<e0>) new a(), (ah0.l<? super String[], e0>) b.a, (ah0.a<e0>) c.a);
        }

        @Override
        public void onSheetShown(BottomSheet bottomSheet, Object object) {
            n.j(bottomSheet, "bottomSheet");
        }
    }

    static {
        new b(null);
    }

    private FinHTMLWebLayout(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        this.b = lg0.i.a(new c());
        this.n = lg0.i.a(new d());
    }

    public FinHTMLWebLayout(Context context, AttributeSet attributeSet, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
        this(context, (i3 & 2) != 0 ? null : attributeSet, (i3 & 4) != 0 ? 0 : i2);
    }

    public FinHTMLWebLayout(Host host, com.finogeeks.lib.applet.api.d dVar, com.finogeeks.lib.applet.api.g gVar, com.finogeeks.lib.applet.page.view.webview.h hVar, a aVar) {
        this((Context) host.getK(), (AttributeSet) null, 0, 6, (DefaultConstructorMarker) null);
        n.j(host, "host");
        this.a = host;
        this.e = dVar;
        this.f = gVar;
        this.h = aVar;
        this.g = hVar;
        b();
    }

    public static String a(FinHTMLWebLayout finHTMLWebLayout, com.finogeeks.lib.applet.i.domain.b bVar, String str, boolean z10, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str = null;
        }
        if ((i2 & 4) != 0) {
            z10 = true;
        }
        return finHTMLWebLayout.a(bVar, str, z10);
    }

    private final void a(FinAppConfig.UIConfig uIConfig) {
        IFinAppletLoadingPage.Companion companion = IFinAppletLoadingPage.INSTANCE;
        Context context = getContext();
        n.e(context, "context");
        View inflate = View.inflate(getContext(), companion.a(uIConfig, context).getFailureLayoutRes(), null);
        ((LinearLayout) a(R.id.llError)).addView(inflate, -1, -1);
        View findViewById = inflate.findViewById(R.id.btnFailReload);
        if (findViewById != null) {
            findViewById.setVisibility(8);
        }
    }

    public static void a(FinHTMLWebLayout finHTMLWebLayout, com.finogeeks.lib.applet.i.domain.b bVar, String str, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            str = null;
        }
        finHTMLWebLayout.a(bVar, str);
    }

    public static void a(FinHTMLWebLayout finHTMLWebLayout, String str, Map map, int i2, Object obj) {
        if ((i2 & 2) != 0) {
            map = null;
        }
        finHTMLWebLayout.a(str, (Map<String, ? extends Object>) map);
    }

    public final void a(String str, int i2) {
        if (str == null || n.d(str, this.l)) {
            return;
        }
        FLog.d$default("FinHTMLWebLayout", "checkNotifyOnWebViewLoaded pageStartedNetworkUrl: " + this.m + ", url: " + str + ",progress: " + i2, null, 4, null);
        if (n.d(this.m, str) && i2 == 100) {
            this.m = null;
            Host host = this.a;
            if (host == null) {
                n.z("host");
            }
            HostBase.sendToServiceJSBridge$default(host, "onWebviewLoad", "{}", Integer.valueOf(e()), null, 8, null);
        }
    }

    public final void a(String str, String str2, String str3, String str4) {
        if (!TextUtils.isEmpty(str) && t.L(str, "data", false, 2, (Object) null)) {
            b(b(str), str4, str2, str3);
            return;
        }
        if (!URLUtil.isNetworkUrl(str)) {
            FLog.e$default("FinHTMLWebLayout", "downloadFile error , Can only download HTTP/HTTPS URIs ", null, 4, null);
            return;
        }
        DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
        request.allowScanningByMediaScanner();
        request.setNotificationVisibility(1);
        request.setAllowedOverMetered(false);
        request.setVisibleInDownloadsUi(false);
        request.setAllowedOverRoaming(true);
        if (t.t(str4, ".apk", false)) {
            request.setMimeType("application/vnd.android.package-archive");
        }
        request.setAllowedNetworkTypes(3);
        request.setTitle(str4);
        request.setDescription("正在下载...");
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, str4);
        Object systemService = getContext().getSystemService(FLogCommonTag.DOWNLOAD);
        if (!(systemService instanceof DownloadManager)) {
            systemService = null;
        }
        DownloadManager downloadManager = (DownloadManager) systemService;
        FLog.d$default("FinHTMLWebLayout", "downloadFile " + (downloadManager != null ? Long.valueOf(downloadManager.enqueue(request)) : null), null, 4, null);
    }

    private final String b(String str) {
        int i2;
        if (TextUtils.isEmpty(str) || !t.L(str, "data", false, 2, (Object) null)) {
            return "";
        }
        d0 d0Var = new d0();
        int d0 = u.d0(str, ",", 5, false, 4, (Object) null);
        d0Var.a = d0;
        if (d0 <= 5) {
            return "";
        }
        while (d0 >= 5) {
            String valueOf = String.valueOf(str.charAt(d0));
            if (n.d(valueOf, ";") || n.d(valueOf, ":")) {
                i2 = d0 + 1;
                break;
            }
            d0--;
        }
        i2 = -1;
        int i3 = d0Var.a;
        if (str == null) {
            throw new lg0.t("null cannot be cast to non-null type java.lang.String");
        }
        String substring = str.substring(i2, i3);
        n.e(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        if (t.v(substring, "base64", true)) {
            String substring2 = str.substring(u.d0(str, ",", 5, false, 4, (Object) null) + 1);
            n.e(substring2, "(this as java.lang.String).substring(startIndex)");
            return substring2;
        }
        FLog.e$default("FinHTMLWebLayout", "unsupported chartset:" + substring, null, 4, null);
        return "";
    }

    private final void b() {
        Host host = this.a;
        if (host == null) {
            n.z("host");
        }
        FinAppConfig finAppConfig = host.getFinAppConfig();
        View inflate = LayoutInflater.from(getContext()).inflate(R.layout.fin_applet_html_web_layout, this);
        if (inflate == null) {
            throw new lg0.t("null cannot be cast to non-null type android.view.ViewGroup");
        }
        ViewGroup viewGroup = (ViewGroup) inflate;
        a(finAppConfig.getUiConfig());
        Host host2 = this.a;
        if (host2 == null) {
            n.z("host");
        }
        this.c = new com.finogeeks.lib.applet.page.view.webview.f(host2);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        viewGroup.addView(fVar, 0, layoutParams);
        View findViewById = viewGroup.findViewById(R.id.progressBar);
        n.e(findViewById, "layout.findViewById(R.id.progressBar)");
        this.d = (ProgressBar) findViewById;
        FinAppConfig.UIConfig uiConfig = finAppConfig.getUiConfig();
        Integer valueOf = uiConfig != null ? Integer.valueOf(uiConfig.getWebViewProgressBarColor()) : null;
        if (valueOf != null && valueOf.intValue() != -1) {
            ProgressBar progressBar = this.d;
            if (progressBar == null) {
                n.z("progressBar");
            }
            progressBar.setProgressTintList(ColorStateList.valueOf(valueOf.intValue()));
        }
        com.finogeeks.lib.applet.page.view.webview.f fVar2 = this.c;
        if (fVar2 == null) {
            n.z("webView");
        }
        fVar2.d = new e();
        com.finogeeks.lib.applet.page.view.webview.f fVar3 = this.c;
        if (fVar3 == null) {
            n.z("webView");
        }
        fVar3.setOnLongClickListener(f.a);
        com.finogeeks.lib.applet.page.view.webview.f fVar4 = this.c;
        if (fVar4 == null) {
            n.z("webView");
        }
        fVar4.mo781getWebView().setOnLongClickListener(new g());
        com.finogeeks.lib.applet.page.view.webview.f fVar5 = this.c;
        if (fVar5 == null) {
            n.z("webView");
        }
        Host host3 = this.a;
        if (host3 == null) {
            n.z("host");
        }
        fVar5.setWebViewClient(new com.finogeeks.lib.applet.page.view.webview.g(host3, new h()));
        FragmentActivity activity = getActivity();
        Host host4 = this.a;
        if (host4 == null) {
            n.z("host");
        }
        this.i = new FinHTMLWebChromeClient(activity, host4, new i(finAppConfig));
        com.finogeeks.lib.applet.page.view.webview.f fVar6 = this.c;
        if (fVar6 == null) {
            n.z("webView");
        }
        fVar6.setWebChromeClient(this.i);
        FinHTMLWebChromeClient finHTMLWebChromeClient = this.i;
        if (finHTMLWebChromeClient != null) {
            com.finogeeks.lib.applet.page.view.webview.f fVar7 = this.c;
            if (fVar7 == null) {
                n.z("webView");
            }
            finHTMLWebChromeClient.a(fVar7);
        }
        com.finogeeks.lib.applet.page.view.webview.f fVar8 = this.c;
        if (fVar8 == null) {
            n.z("webView");
        }
        Host host5 = this.a;
        if (host5 == null) {
            n.z("host");
        }
        fVar8.setJSBridge(host5, this);
        if (finAppConfig.isEnableWebViewDownloadFile()) {
            com.finogeeks.lib.applet.page.view.webview.f fVar9 = this.c;
            if (fVar9 == null) {
                n.z("webView");
            }
            fVar9.setDownloadListener(new j());
            return;
        }
        com.finogeeks.lib.applet.page.view.webview.f fVar10 = this.c;
        if (fVar10 == null) {
            n.z("webView");
        }
        fVar10.setDownloadListener(null);
    }

    private final void b(String str, String str2, String str3, String str4) {
        if (str.length() == 0) {
            return;
        }
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        if (!externalStoragePublicDirectory.exists()) {
            externalStoragePublicDirectory.mkdirs();
        }
        byte[] decode = Base64.decode(str, 0);
        n.e(decode, "Base64.decode(data, Base64.DEFAULT)");
        r.a((Context) getActivity(), decode, externalStoragePublicDirectory, str2, str4);
    }

    public static final Host d(FinHTMLWebLayout finHTMLWebLayout) {
        Host host = finHTMLWebLayout.a;
        if (host == null) {
            n.z("host");
        }
        return host;
    }

    public static final ProgressBar e(FinHTMLWebLayout finHTMLWebLayout) {
        ProgressBar progressBar = finHTMLWebLayout.d;
        if (progressBar == null) {
            n.z("progressBar");
        }
        return progressBar;
    }

    public final FragmentActivity getActivity() {
        lg0.h hVar = this.b;
        hh0.l lVar = p[0];
        return (FragmentActivity) hVar.getValue();
    }

    public final void h() {
        Runnable runnable = this.k;
        if (runnable != null) {
            removeCallbacks(runnable);
        }
        this.k = null;
    }

    public final boolean i() {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        com.finogeeks.lib.applet.webview.a hitTestResult = fVar.hitTestResult();
        int b2 = hitTestResult.b();
        String a2 = hitTestResult.a();
        if (b2 != 5 && b2 != 8) {
            return false;
        }
        Host host = this.a;
        if (host == null) {
            n.z("host");
        }
        new BottomSheet.Builder(getActivity(), ThemeModeUtil.getBottomSheetStyle(host.getFinAppConfig().getUiConfig(), getActivity())).addMenuItem(new BottomSheetMenuItem((Context) getActivity(), (CharSequence) getActivity().getString(R.string.fin_applet_save_image_to_phone), (Drawable) null)).addMenuItem(new BottomSheetMenuItem((Context) getActivity(), (CharSequence) getActivity().getString(R.string.fin_applet_cancel), (Drawable) null)).setListener(new l(a2)).show();
        return true;
    }

    public View a(int i2) {
        if (this.o == null) {
            this.o = new HashMap();
        }
        View view = (View) this.o.get(Integer.valueOf(i2));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i2);
        this.o.put(Integer.valueOf(i2), findViewById);
        return findViewById;
    }

    public final String a(com.finogeeks.lib.applet.i.domain.b bVar, String str, boolean z10) {
        String str2;
        n.j(bVar, "checkResult");
        if (str != null) {
            int d0 = u.d0(str, "/", 8, false, 4, (Object) null);
            Integer valueOf = Integer.valueOf(d0);
            if (d0 <= 0) {
                valueOf = null;
            }
            str2 = str.substring(0, valueOf != null ? valueOf.intValue() : str.length());
            n.e(str2, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        } else {
            str2 = null;
        }
        int i2 = com.finogeeks.lib.applet.page.view.webview.e.b[bVar.ordinal()];
        if (i2 == 1) {
            StringBuilder sb = new StringBuilder();
            sb.append(getContext().getString(R.string.fin_applet_illegal_domain_notice, str2));
            sb.append(z10 ? "(13002)" : "");
            return sb.toString();
        }
        if (i2 != 2) {
            StringBuilder sb2 = new StringBuilder();
            sb2.append(s.a(getContext().getString(R.string.fin_applet_page_not_found_notice), null, 1, null));
            sb2.append(z10 ? "(13001)" : "");
            return sb2.toString();
        }
        StringBuilder sb3 = new StringBuilder();
        sb3.append(getContext().getString(R.string.fin_applet_blacklist_domain_notice, str2));
        sb3.append(z10 ? "(13003)" : "");
        return sb3.toString();
    }

    @Override
    public String a(String str, String str2) {
        com.finogeeks.lib.applet.api.d dVar = this.e;
        if (dVar != null) {
            return dVar.a(new Event(str, str2));
        }
        return null;
    }

    public final void a(int i2, int i3, Intent intent) {
        FinHTMLWebChromeClient finHTMLWebChromeClient = this.i;
        if (finHTMLWebChromeClient != null) {
            finHTMLWebChromeClient.a(i2, i3, intent);
        }
    }

    @SuppressLint({"SetTextI18n"})
    public final void a(com.finogeeks.lib.applet.i.domain.b bVar, String str) {
        n.j(bVar, "checkResult");
        int i2 = R.id.llError;
        LinearLayout linearLayout = (LinearLayout) a(i2);
        n.e(linearLayout, "llError");
        linearLayout.setVisibility(0);
        LinearLayout linearLayout2 = (LinearLayout) a(i2);
        n.e(linearLayout2, "llError");
        linearLayout2.setTag(bVar);
        TextView textView = (TextView) ((LinearLayout) a(i2)).findViewById(R.id.tvLoadingFailedTitle);
        TextView textView2 = (TextView) ((LinearLayout) a(i2)).findViewById(R.id.tvLoadingFailed);
        int i3 = com.finogeeks.lib.applet.page.view.webview.e.a[bVar.ordinal()];
        if (i3 != 1) {
            if (i3 != 2) {
                if (textView != null) {
                    textView.setText(getContext().getString(R.string.fin_applet_page_not_found));
                }
            } else if (textView != null) {
                textView.setText(getContext().getString(R.string.fin_applet_error_code_black_list_domain_url_title));
            }
        } else if (textView != null) {
            textView.setText(getContext().getString(R.string.fin_applet_error_code_not_registered_domain_url_title));
        }
        if (textView2 != null) {
            textView2.setText(a(this, bVar, str, false, 4, null));
        }
    }

    @Override
    public void a(String str, String str2, String str3) {
        n.j(str3, "callbackId");
        if (n.d("initPage", str)) {
            b(str3, String.valueOf(e()));
            return;
        }
        com.finogeeks.lib.applet.api.g gVar = this.f;
        if (gVar != null) {
            gVar.b(new Event(str, str2, str3), this);
        }
    }

    public final void a(String str, Map<String, ? extends Object> map) {
        n.j(str, "url");
        setVisibility(0);
        Host host = this.a;
        if (host == null) {
            n.z("host");
        }
        host.a("getWebViewCookie", new k(str, map));
    }

    @Override
    public void b(String str, String str2) {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        IJSExecutor.a.a(fVar, "javascript:FinChatJSBridge.webInvokeCallbackHandler(" + str + ',' + str2 + ')', null, 2, null);
    }

    @Override
    public void b(String str, String str2, String str3) {
        n.j(str3, "callbackId");
        com.finogeeks.lib.applet.api.d dVar = this.e;
        if (dVar != null) {
            dVar.b(new Event(str, str2, str3), this);
        }
    }

    @Override
    public void c(String str, String str2) {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        IJSExecutor.a.a(fVar, "javascript:FinChatJSBridge.invokeCallbackHandler(" + str + ',' + str2 + ')', null, 2, null);
    }

    @Override
    public void c(String str, String str2, String str3) {
        IJSBridge.a.a(this, str, str2, str3);
    }

    @Override
    public void d(String str, String str2, String str3) {
        if (str != null && str.hashCode() == -335649376 && str.equals("onWebviewEvent")) {
            Host host = this.a;
            if (host == null) {
                n.z("host");
            }
            HostBase.sendToServiceJSBridge$default(host, str, str2, Integer.valueOf(e()), null, 8, null);
        }
    }

    public final boolean d() {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        WebBackForwardList copyBackForwardList = fVar.copyBackForwardList();
        int currentIndex = copyBackForwardList.getCurrentIndex();
        if (currentIndex < 1) {
            return false;
        }
        for (int i2 = currentIndex; i2 >= 0; i2--) {
            WebHistoryItem itemAtIndex = copyBackForwardList.getItemAtIndex(currentIndex);
            if (itemAtIndex != null) {
                Host host = this.a;
                if (host == null) {
                    n.z("host");
                }
                if (host.getB().isOfflineWeb() || URLUtil.isNetworkUrl(itemAtIndex.getUrl())) {
                    com.finogeeks.lib.applet.page.view.webview.f fVar2 = this.c;
                    if (fVar2 == null) {
                        n.z("webView");
                    }
                    if (fVar2.canGoBack()) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public final int e() {
        com.finogeeks.lib.applet.page.view.webview.h hVar = this.g;
        if (hVar != null) {
            return hVar.getViewId();
        }
        return 0;
    }

    public final void f() {
        LinearLayout linearLayout = (LinearLayout) a(R.id.llError);
        n.e(linearLayout, "llError");
        linearLayout.setVisibility(8);
    }

    public final boolean g() {
        int i2 = R.id.llError;
        LinearLayout linearLayout = (LinearLayout) a(i2);
        n.e(linearLayout, "llError");
        if (linearLayout.getVisibility() == 0) {
            LinearLayout linearLayout2 = (LinearLayout) a(i2);
            n.e(linearLayout2, "llError");
            if (((com.finogeeks.lib.applet.i.domain.b) linearLayout2.getTag()) != com.finogeeks.lib.applet.i.domain.b.LEGAL && d()) {
                f();
            }
        }
        if (!d()) {
            return false;
        }
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        fVar.goBack();
        return true;
    }

    @Override
    public String getN() {
        lg0.h hVar = this.n;
        hh0.l lVar = p[1];
        return (String) hVar.getValue();
    }

    public final boolean getJ() {
        return this.j;
    }

    public final String getUrl() {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        return fVar.getUrl();
    }

    public final String getUserAgent() {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        return fVar.getSettings().getUserAgentString();
    }

    public final com.finogeeks.lib.applet.page.view.webview.f getWebView() {
        com.finogeeks.lib.applet.page.view.webview.f fVar = this.c;
        if (fVar == null) {
            n.z("webView");
        }
        return fVar;
    }

    public final void setNeedClearWebViewHistory(boolean z10) {
        this.j = z10;
    }

    public final void setWebView(com.finogeeks.lib.applet.page.view.webview.f fVar) {
        n.j(fVar, "<set-?>");
        this.c = fVar;
    }
}