导航菜单

页面标题

页面副标题

Minits v4.9.3.32 - XOneWebView.java 源代码

正在查看: Minits v4.9.3.32 应用的 XOneWebView.java JAVA 源代码文件

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


package com.xone.android.framework.views;

import C8.C0037d;
import F8.L;
import F8.b4;
import K4.b;
import M8.f;
import M8.h;
import N1.c;
import Q8.m;
import ab.AbstractC0399a;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Picture;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.print.PrintAttributes;
import android.print.PrintJob;
import android.print.PrintManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.URLUtil;
import android.webkit.WebBackForwardList;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import com.xone.android.framework.activities.XoneBaseActivity;
import com.xone.android.framework.views.XOneWebView;
import com.xone.android.framework.webview.XOneWebViewJsBridge;
import com.xone.android.framework.xoneApp;
import com.xone.android.javascript.XOneJavascript;
import com.xone.android.utils.Utils;
import com.xone.annotations.ScriptAllowed;
import com.xone.interfaces.IXoneObject;
import com.xone.interfaces.IXoneView;
import fa.j;
import fb.q;
import fb.t;
import ha.AbstractC0751f;
import j$.util.Objects;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Callable;
import org.mozilla.javascript.C0893d0;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Q0;
import p8.p;
import ua.E;
import ua.I;
import ua.InterfaceC1012B;
import ua.InterfaceC1036l0;
import ua.InterfaceC1038m0;
import ua.InterfaceC1042o0;
import va.C1066a;

@ScriptAllowed
public final class XOneWebView extends FrameLayout implements IXoneView, I, View.OnTouchListener, View.OnKeyListener, InterfaceC1012B {
    public String A;
    public String B;
    public String C;
    public E D;
    public IXoneObject E;
    public C1066a F;
    public Handler G;
    public boolean H;
    public int I;
    public int J;
    public int K;
    public int L;
    public int M;
    public int N;
    public h O;
    public f P;
    public boolean Q;
    public HashMap R;
    public p S;
    public boolean T;
    public boolean l;
    public b m;
    public L n;
    public boolean o;
    public String p;
    public String q;
    public boolean r;
    public String[] s;
    public boolean t;
    public boolean u;
    public String v;
    public String w;
    public String x;
    public String y;
    public int z;

    public XOneWebView(Context context) {
        super(context);
        this.r = true;
        this.s = null;
        this.t = false;
        this.u = true;
    }

    private void A() {
        boolean z;
        boolean z2;
        XOneWebView xOneWebView = this;
        Context context = xOneWebView.getContext();
        xOneWebView.setBackgroundColor(0);
        if (xOneWebView.F.v()) {
            xOneWebView.setVisibility(8);
            return;
        }
        if (!xOneWebView.H) {
            xOneWebView.H = !xOneWebView.o;
        }
        if (!xOneWebView.H) {
            xOneWebView.H = AbstractC0399a.h(xOneWebView.E, xOneWebView.F, xOneWebView.B);
        }
        AbstractC0399a.c(xOneWebView, xOneWebView.E, xOneWebView.B, xOneWebView.I, xOneWebView.J, xOneWebView.K, xOneWebView.L, xOneWebView.M, xOneWebView.N);
        InterfaceC1038m0 app = xOneWebView.getApp();
        int V = app.V();
        int l = app.l();
        String F = xOneWebView.F("width");
        String F2 = xOneWebView.F("height");
        int e1 = Utils.e1(context, F, V, xOneWebView.I, xOneWebView.K);
        int e12 = Utils.e1(context, F2, l, xOneWebView.J, xOneWebView.L);
        xOneWebView.C = xOneWebView.E.GetRawStringField(xOneWebView.B);
        xOneWebView.r = xOneWebView.D("handle-links", true);
        xOneWebView.s = s(xOneWebView.F("handle-links-ext"));
        xOneWebView.A = xOneWebView.F("link-handler-callback-node");
        xOneWebView.t = xOneWebView.D("enable-back-key", false);
        boolean D = xOneWebView.D("unescape-characters", false);
        xOneWebView.u = xOneWebView.D("zoom-controls", true);
        xOneWebView.v = xOneWebView.F("user-agent");
        xOneWebView.w = xOneWebView.F("webview-username");
        xOneWebView.x = xOneWebView.F("webview-password");
        xOneWebView.y = xOneWebView.F("webview-auth-dialog-title");
        xOneWebView.q = xOneWebView.G("encoding", "UTF-8");
        boolean D2 = xOneWebView.D("scales-to-fit", false);
        xOneWebView.z = q.p(xOneWebView.F("zoom"), 1);
        String F3 = xOneWebView.F("image-error");
        xOneWebView.p = F3;
        if (TextUtils.isEmpty(F3)) {
            z = D;
            z2 = D2;
        } else {
            z2 = D2;
            z = D;
            C0037d c0037d = new C0037d(xOneWebView.E, this, xOneWebView.B, "image-error", false, false, false, false, "cache/media");
            xOneWebView = this;
            c0037d.runExecutor(j.d());
        }
        boolean D3 = xOneWebView.D("show-progress-bar", false);
        ViewGroup.LayoutParams layoutParams = xOneWebView.getLayoutParams();
        if (e1 >= 0) {
            layoutParams.width = Utils.W2(e1, xOneWebView.M);
        } else {
            layoutParams.width = -2;
        }
        if (e12 >= 0) {
            layoutParams.height = Utils.W2(e12, xOneWebView.N);
        } else {
            layoutParams.height = -2;
        }
        xOneWebView.setLayoutParams(layoutParams);
        xOneWebView.setTag(xOneWebView.B);
        if (xOneWebView.K()) {
            L l2 = new L(context);
            xOneWebView.n = l2;
            l2.setScaleToFit(z2);
            xOneWebView.n.setUnescapeCharacters(z);
            xOneWebView.n.setLocked(xOneWebView.H);
            xOneWebView.n.setOnKeyListener(xOneWebView);
            p pVar = new p(xOneWebView);
            xOneWebView.S = pVar;
            xOneWebView.n.setDownloadListener(pVar);
            FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-1, -1);
            layoutParams2.gravity = 119;
            layoutParams2.setMargins(0, 0, 0, 0);
            xOneWebView.O = new h(xOneWebView);
            xOneWebView.P = new f(xOneWebView);
            xOneWebView.addView(xOneWebView.n);
            if (D3) {
                K4.p pVar2 = new K4.p(context);
                xOneWebView.m = pVar2;
                if (Build.VERSION.SDK_INT >= 26) {
                    c.a(pVar2, 0);
                }
                xOneWebView.m.setMax(100);
                xOneWebView.m.setProgress(0);
                xOneWebView.m.setIndicatorColor(new int[]{Color.parseColor("#7100F8")});
                xOneWebView.m.setTrackColor(Color.parseColor("#DCBAFF"));
                xOneWebView.m.setLayoutParams(new FrameLayout.LayoutParams(-1, -2));
                xOneWebView.m.setVisibility(8);
                xOneWebView.addView(xOneWebView.m);
            }
            xOneWebView.n.post(new b4(xOneWebView));
            xOneWebView.l = true;
        }
    }

    private void B() {
        if (this.F.v()) {
            setVisibility(8);
            Q("about:blank");
            return;
        }
        setVisibility(0);
        if (!this.H) {
            this.H = !this.o;
        }
        if (!this.H) {
            this.H = AbstractC0399a.h(this.E, this.F, this.B);
        }
        L l = this.n;
        if (l != null) {
            l.setLocked(this.H);
        }
        Context context = getContext();
        AbstractC0399a.c(this, this.E, this.B, this.I, this.J, this.K, this.L, this.M, this.N);
        this.p = F("image-error");
        String F = F("width");
        String F2 = F("height");
        InterfaceC1038m0 app = getApp();
        int V = app.V();
        int l2 = app.l();
        int e1 = Utils.e1(context, F, V, this.I, this.K);
        int e12 = Utils.e1(context, F2, l2, this.J, this.L);
        this.C = this.E.GetRawStringField(this.B);
        this.w = F("webview-username");
        this.x = F("webview-password");
        ViewGroup.LayoutParams layoutParams = getLayoutParams();
        if (e1 >= 0) {
            layoutParams.width = Utils.W2(e1, this.M);
        } else {
            layoutParams.width = -2;
        }
        if (e12 >= 0) {
            layoutParams.height = Utils.W2(e12, this.N);
        } else {
            layoutParams.height = -2;
        }
        setLayoutParams(layoutParams);
        if (this.Q) {
            return;
        }
        Q(this.C);
    }

    private IXoneObject getSelfObject() {
        Q0 m = XOneJavascript.m();
        if (m == null) {
            return null;
        }
        Object obj = m.get("self");
        if (obj instanceof IXoneObject) {
            return (IXoneObject) obj;
        }
        return null;
    }

    public static String[] s(String str) {
        if (str == null) {
            return null;
        }
        String[] split = str.split(";");
        if (split.length == 0) {
            return null;
        }
        return split;
    }

    public void C(String str) {
        L l;
        if (TextUtils.isEmpty(str) || (l = this.n) == null) {
            return;
        }
        l.evaluateJavascript(str, null);
    }

    public final boolean D(String str, boolean z) {
        try {
            return t.l(this.E.FieldPropertyValue(this.B, str), z);
        } catch (Exception e) {
            throw AbstractC0751f.e(e);
        }
    }

    public final String F(String str) {
        return G(str, "");
    }

    public final String G(String str, String str2) {
        try {
            return t.z(this.E.FieldPropertyValue(this.B, str), str2);
        } catch (Exception e) {
            throw AbstractC0751f.e(e);
        }
    }

    public void P(int i) {
        L l = this.n;
        if (l == null) {
            return;
        }
        l.goBackOrForward(i);
    }

    public void I(Throwable th) {
        if (th == null) {
            return;
        }
        Object context = getContext();
        if (context instanceof InterfaceC1036l0) {
            ((InterfaceC1036l0) context).b(th);
        } else {
            th.printStackTrace();
        }
    }

    public boolean J() {
        return this.E.getEventCallback("onwebviewmessage", this.B) != null;
    }

    public final boolean K() {
        Context context = (Context) getApp();
        if (Utils.t3(context)) {
            return context.getPackageManager().hasSystemFeature("android.software.webview");
        }
        return true;
    }

    public final Boolean M(int i) {
        return Boolean.valueOf(v(i));
    }

    public final void N(View view) {
        if (TextUtils.isEmpty(this.C)) {
            this.n.loadData("", "text/html", "utf-8");
        } else {
            this.n.loadUrl(Uri.parse(this.C).toString());
        }
        this.n.setVisibility(0);
    }

    @Override
    public void Refresh(Context context, InterfaceC1038m0 interfaceC1038m0, E e, IXoneObject iXoneObject, C1066a c1066a, Boolean bool, InterfaceC1042o0 interfaceC1042o0, int i, int i2, int i3, int i4, int i5, List list, int i6, int i7) {
        if (!isCreated()) {
            Boolean bool2 = Boolean.FALSE;
            createView(context, interfaceC1038m0, e, iXoneObject, c1066a, bool2, bool2, bool2, bool, interfaceC1042o0, i, i2, i3, i4, i5, list, i6, i7);
            return;
        }
        this.D = e;
        this.E = iXoneObject;
        this.F = c1066a;
        this.H = bool.booleanValue();
        this.I = i;
        this.J = i2;
        this.K = i3;
        this.L = i4;
        this.M = i6;
        this.N = i7;
        B();
    }

    public final Boolean S(boolean z) {
        return Boolean.valueOf(X(z));
    }

    public final Boolean T(boolean z) {
        return Boolean.valueOf(Y(z));
    }

    public final void U(IXoneObject iXoneObject, Function function) {
        this.O.n(iXoneObject, function);
    }

    public void Q(final String str) {
        if (this.n == null) {
            return;
        }
        if (!Utils.s3()) {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.Q(str);
                }
            });
        } else if (URLUtil.isValidUrl(str)) {
            this.n.loadUrl(str);
        } else {
            this.n.loadDataWithBaseURL(null, str, "text/html", this.q, null);
        }
    }

    public boolean X(boolean z) {
        L l = this.n;
        if (l == null) {
            return false;
        }
        return l.pageDown(z);
    }

    public boolean Y(boolean z) {
        L l = this.n;
        if (l == null) {
            return false;
        }
        return l.pageUp(z);
    }

    public void Z() {
        L l = this.n;
        if (l == null) {
            return;
        }
        l.stopLoading();
    }

    public void V(float f) {
        L l;
        if (f == 0.0f || (l = this.n) == null) {
            return;
        }
        l.zoomBy(f);
    }

    @ScriptAllowed
    public String addPrintJob(Object... objArr) {
        final String str = (String) Utils.A(objArr, 0, "");
        if (TextUtils.isEmpty(str)) {
            str = Utils.q2(5);
        }
        if (Utils.s3()) {
            L(str);
            return str;
        }
        j.p(new Runnable() {
            @Override
            public final void run() {
                XOneWebView.this.L(str);
            }
        });
        return str;
    }

    public void b0() {
        L l = this.n;
        if (l == null) {
            return;
        }
        l.zoomIn();
    }

    public void c0() {
        L l = this.n;
        if (l == null) {
            return;
        }
        l.zoomOut();
    }

    @ScriptAllowed
    public boolean canGoBack() {
        return Utils.s3() ? u() : ((Boolean) j.o(new Callable() {
            @Override
            public final Object call() {
                return Boolean.valueOf(XOneWebView.this.u());
            }
        })).booleanValue();
    }

    @ScriptAllowed
    public boolean canGoBackOrForward(Object... objArr) {
        Utils.g("CanGoBackOrForward", objArr, 1);
        final int p = q.p(objArr[0], 1);
        return Utils.s3() ? v(p) : ((Boolean) j.o(new Callable() {
            @Override
            public final Object call() {
                Boolean M;
                M = XOneWebView.this.M(p);
                return M;
            }
        })).booleanValue();
    }

    @ScriptAllowed
    public boolean canGoForward() {
        return Utils.s3() ? w() : ((Boolean) j.o(new Callable() {
            @Override
            public final Object call() {
                return Boolean.valueOf(XOneWebView.this.w());
            }
        })).booleanValue();
    }

    @ScriptAllowed
    public void clearCache() {
        if (Utils.s3()) {
            x();
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.x();
                }
            });
        }
    }

    @ScriptAllowed
    public void clearClientCertificates() {
        if (Utils.s3()) {
            WebView.clearClientCertPreferences(null);
        } else {
            j.p(new Runnable() {
                @Override
                public final void run() {
                    WebView.clearClientCertPreferences(null);
                }
            });
        }
    }

    @ScriptAllowed
    public void clearNavigationHistory() {
        if (Utils.s3()) {
            y();
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.y();
                }
            });
        }
    }

    @Override
    public void createView(Context context, InterfaceC1038m0 interfaceC1038m0, E e, IXoneObject iXoneObject, C1066a c1066a, Boolean bool, Boolean bool2, Boolean bool3, Boolean bool4, InterfaceC1042o0 interfaceC1042o0, int i, int i2, int i3, int i4, int i5, List list, int i6, int i7) {
        this.l = false;
        this.D = e;
        this.E = iXoneObject;
        this.F = c1066a;
        this.H = bool4.booleanValue();
        this.I = i;
        this.J = i2;
        this.K = i3;
        this.L = i4;
        this.M = i6;
        this.N = i7;
        this.o = true;
        this.B = c1066a.q().f();
        this.G = e.getUiHandler();
        A();
    }

    @Override
    public void dispose() {
        this.s = null;
        this.A = null;
        this.w = null;
        this.x = null;
        this.E = null;
        this.B = null;
        this.C = null;
    }

    @Override
    public boolean e() {
        return this.T;
    }

    public InterfaceC1038m0 getApp() {
        return xoneApp.Z0();
    }

    public XoneBaseActivity getBaseActivity() {
        return (XoneBaseActivity) getContext();
    }

    @Override
    public InterfaceC1042o0 getCssItem() {
        return null;
    }

    @ScriptAllowed
    public int getCurrentHistoryIndex() {
        if (Utils.s3()) {
            return getCurrentHistoryIndexInternal();
        }
        Integer num = (Integer) j.o(new Callable() {
            @Override
            public final Object call() {
                return Integer.valueOf(XOneWebView.this.getCurrentHistoryIndexInternal());
            }
        });
        if (num == null) {
            return 0;
        }
        return num.intValue();
    }

    public int getCurrentHistoryIndexInternal() {
        L l = this.n;
        if (l == null) {
            return 0;
        }
        return l.copyBackForwardList().getCurrentIndex();
    }

    @Override
    public IXoneObject getDataObject() {
        return this.E;
    }

    public p getDownloadListener() {
        return this.S;
    }

    public String getErrorImage() {
        return this.p;
    }

    @ScriptAllowed
    public String getFavicon(Object... objArr) {
        Utils.h("SaveCapture", objArr, 0, 1);
        FileOutputStream fileOutputStream = null;
        String x = Utils.x(objArr, 0, null);
        if (TextUtils.isEmpty(x)) {
            x = UUID.randomUUID().toString() + ".png";
        }
        InterfaceC1038m0 app = getApp();
        String C0 = Utils.C0(app.Y(), app.T(), x, 1);
        if (TextUtils.isEmpty(C0)) {
            throw new IOException("SaveCapture(): Cannot obtain favicon file path");
        }
        try {
            Bitmap bitmap = (Bitmap) j.o(new Callable() {
                @Override
                public final Object call() {
                    return XOneWebView.this.getFaviconInternal();
                }
            });
            if (bitmap == null) {
                Utils.N(null);
                return null;
            }
            File file = new File(C0);
            FileOutputStream fileOutputStream2 = new FileOutputStream(file);
            try {
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream2);
                String absolutePath = file.getAbsolutePath();
                Utils.N(fileOutputStream2);
                return absolutePath;
            } catch (Throwable th) {
                th = th;
                fileOutputStream = fileOutputStream2;
                Utils.N(fileOutputStream);
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public Bitmap getFaviconInternal() {
        L l = this.n;
        if (l == null) {
            return null;
        }
        return l.getFavicon();
    }

    public String[] getHandleLinkExtensions() {
        return this.s;
    }

    public boolean getHandleLinks() {
        return this.r;
    }

    @ScriptAllowed
    public C0893d0 getHistory() {
        return Utils.s3() ? m.u(getHistoryInternal()) : m.u((List) j.o(new Callable() {
            @Override
            public final Object call() {
                return XOneWebView.this.getHistoryInternal();
            }
        }));
    }

    public List<String> getHistoryInternal() {
        L l = this.n;
        if (l == null) {
            return null;
        }
        WebBackForwardList copyBackForwardList = l.copyBackForwardList();
        int size = copyBackForwardList.getSize();
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < size; i++) {
            arrayList.add(copyBackForwardList.getItemAtIndex(i).getOriginalUrl());
        }
        return arrayList;
    }

    public L getInnerWebView() {
        return this.n;
    }

    public String getLinkHandlerCallbackNode() {
        return this.A;
    }

    public String getPassword() {
        return this.x;
    }

    @ScriptAllowed
    public String getPrintJobStatus(Object... objArr) {
        PrintJob printJob;
        Utils.j("GetPrintJobStatus", objArr);
        Utils.g("GetPrintJobStatus", objArr, 1);
        String z = t.z(objArr[0], "");
        if (TextUtils.isEmpty(z)) {
            throw new IllegalArgumentException("GetPrintJobStatus(): Job name argument cannot be empty");
        }
        HashMap hashMap = this.R;
        if (hashMap == null || hashMap.isEmpty() || (printJob = (PrintJob) this.R.get(z)) == null) {
            return "not_found";
        }
        switch (printJob.getInfo().getState()) {
            case 1:
                return "created";
            case 2:
                return "queued";
            case 3:
                return "started";
            case 4:
                return "blocked";
            case 5:
                return "completed";
            case 6:
                return "failed";
            case org.mozilla.javascript.Context.FEATURE_DYNAMIC_SCOPE:
                return "cancelled";
            default:
                return "unknown";
        }
    }

    @ScriptAllowed
    public int getProgress() {
        return Utils.s3() ? getProgressInternal() : ((Integer) j.o(new Callable() {
            @Override
            public final Object call() {
                return Integer.valueOf(XOneWebView.this.getProgressInternal());
            }
        })).intValue();
    }

    public ProgressBar getProgressBar() {
        return this.m;
    }

    public int getProgressInternal() {
        L l = this.n;
        if (l == null) {
            return 0;
        }
        return l.getProgress();
    }

    @Override
    public String getPropName() {
        return this.B;
    }

    @ScriptAllowed
    public String getTitle() {
        return Utils.s3() ? getTitleInternal() : (String) j.o(new Callable() {
            @Override
            public final Object call() {
                return XOneWebView.this.getTitleInternal();
            }
        });
    }

    public String getTitleInternal() {
        L l = this.n;
        if (l == null) {
            return null;
        }
        return l.getTitle();
    }

    public Handler getUiHandler() {
        return this.G;
    }

    @ScriptAllowed
    public String getUrl() {
        return Utils.s3() ? getUrlInternal() : (String) j.o(new Callable() {
            @Override
            public final Object call() {
                return XOneWebView.this.getUrlInternal();
            }
        });
    }

    public String getUrlInternal() {
        L l = this.n;
        if (l == null) {
            return null;
        }
        return l.getUrl();
    }

    public String getUserName() {
        return this.w;
    }

    public String getWebViewAuthDialogTitle() {
        return this.y;
    }

    @ScriptAllowed
    public void goBack(Object... objArr) {
        Utils.h("GoBack", objArr, 0, 1);
        final int u = Utils.u(objArr, 0, 1) * (-1);
        if (Utils.s3()) {
            P(u);
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.O(u);
                }
            });
        }
    }

    @ScriptAllowed
    public void goForward(Object... objArr) {
        Utils.h("GoForward", objArr, 0, 1);
        final int u = Utils.u(objArr, 0, 1);
        if (Utils.s3()) {
            P(u);
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.P(u);
                }
            });
        }
    }

    @Override
    public boolean isCreated() {
        return this.l;
    }

    @ScriptAllowed
    public void load(Object... objArr) {
        Utils.j("Load", objArr);
        Utils.g("Load", objArr, 1);
        Q(t.z(objArr[0], null));
    }

    @ScriptAllowed
    public void loadFile(Object... objArr) {
        Utils.j("LoadFile", objArr);
        Utils.g("LoadFile", objArr, 1);
        String z = t.z(objArr[0], null);
        if (TextUtils.isEmpty(z)) {
            throw new IllegalArgumentException("LoadFile(): Empty file path");
        }
        InterfaceC1038m0 app = getApp();
        File x1 = Utils.x1(app.Y(), app.T(), z, false);
        if (!x1.exists()) {
            throw new IllegalArgumentException("LoadFile(): File does not exist");
        }
        if (!TextUtils.equals(Utils.t1(x1), "js")) {
            Q(Utils.B1((Context) getApp(), x1).toString());
            return;
        }
        if (Utils.s3()) {
            throw new IllegalStateException("LoadFile(): Cannot be invoked on the UI thread");
        }
        final String sb2 = Utils.z3(x1, "UTF-8").toString();
        final L innerWebView = getInnerWebView();
        if (innerWebView == null) {
            return;
        }
        j.p(new Runnable() {
            @Override
            public final void run() {
                innerWebView.loadUrl("javascript:" + sb2);
            }
        });
    }

    @ScriptAllowed
    public void lockReload() {
        this.Q = true;
    }

    @Override
    public void onDetachedFromWindow() {
        L l = this.n;
        if (l != null) {
            l.loadUrl("about:blank");
        }
        super.onDetachedFromWindow();
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        getParent().requestDisallowInterceptTouchEvent(true);
        return super.onInterceptTouchEvent(motionEvent);
    }

    @Override
    public boolean onKey(View view, int i, KeyEvent keyEvent) {
        if (!this.t || keyEvent.getAction() != 0 || i != 4) {
            return false;
        }
        WebView webView = (WebView) view;
        if (!webView.canGoBack()) {
            return false;
        }
        webView.goBack();
        return true;
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        if (view == this.n) {
            getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
        int action = motionEvent.getAction();
        if ((action == 0 || action == 1) && !view.hasFocus()) {
            view.requestFocus();
        }
        return false;
    }

    @ScriptAllowed
    public boolean pageDown(Object... objArr) {
        Utils.h("PageDown", objArr, 0, 1);
        final boolean q = Utils.q(objArr, 0, false);
        return Utils.s3() ? X(q) : ((Boolean) j.o(new Callable() {
            @Override
            public final Object call() {
                Boolean S;
                S = XOneWebView.this.S(q);
                return S;
            }
        })).booleanValue();
    }

    @ScriptAllowed
    public boolean pageUp(Object... objArr) {
        Utils.h("PageUp", objArr, 0, 1);
        final boolean q = Utils.q(objArr, 0, false);
        return Utils.s3() ? Y(q) : ((Boolean) j.o(new Callable() {
            @Override
            public final Object call() {
                Boolean T;
                T = XOneWebView.this.T(q);
                return T;
            }
        })).booleanValue();
    }

    @ScriptAllowed
    public void reload() {
        if (this.Q) {
            return;
        }
        Q("javascript:window.location.reload(true);");
    }

    @ScriptAllowed
    public void restartPrintJob(Object... objArr) {
        PrintJob printJob;
        Utils.j("RestartPrintJob", objArr);
        Utils.g("RestartPrintJob", objArr, 1);
        String z = t.z(objArr[0], "");
        if (TextUtils.isEmpty(z)) {
            throw new IllegalArgumentException("RestartPrintJob(): Job name argument cannot be empty");
        }
        HashMap hashMap = this.R;
        if (hashMap == null || hashMap.isEmpty() || (printJob = (PrintJob) this.R.get(z)) == null) {
            return;
        }
        printJob.restart();
    }

    @ScriptAllowed
    public void runScript(Object... objArr) {
        Utils.j("RunScript", objArr);
        Utils.g("RunScript", objArr, 1);
        final String y = t.y(objArr[0]);
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("RunScript(): Error, sScriptText == null");
        }
        final L innerWebView = getInnerWebView();
        if (innerWebView == null) {
            throw new NullPointerException("RunScript(): Error, cannot find inner webview in view hierarchy");
        }
        if (!Utils.s3()) {
            j.p(new Runnable() {
                @Override
                public final void run() {
                    L.this.loadUrl("javascript:" + y);
                }
            });
            return;
        }
        throw new IllegalStateException("RunScript(): Cannot be invoked on the UI thread");
    }

    @ScriptAllowed
    public void saveCapture(Object... objArr) {
        Picture picture;
        Bitmap bitmap;
        Utils.h("SaveCapture", objArr, 0, 1);
        FileOutputStream fileOutputStream = null;
        String x = Utils.x(objArr, 0, null);
        if (TextUtils.isEmpty(x)) {
            x = UUID.randomUUID().toString() + ".png";
        }
        InterfaceC1038m0 app = getApp();
        String C0 = Utils.C0(app.Y(), app.T(), x, 1);
        if (TextUtils.isEmpty(C0)) {
            throw new IOException("SaveCapture(): Cannot obtain capture file path");
        }
        if (this.n == null) {
            return;
        }
        File file = new File(C0);
        if (Utils.s3()) {
            picture = this.n.capturePicture();
        } else {
            final L l = this.n;
            Objects.requireNonNull(l);
            picture = (Picture) j.o(new Callable() {
                @Override
                public final Object call() {
                    return L.this.capturePicture();
                }
            });
        }
        if (picture == null) {
            throw new IOException("SaveCapture(): Cannot obtain WebView capture");
        }
        try {
            bitmap = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
            try {
                picture.draw(new Canvas(bitmap));
                FileOutputStream fileOutputStream2 = new FileOutputStream(file);
                try {
                    bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream2);
                    Utils.N(fileOutputStream2);
                    Utils.L3(bitmap);
                } catch (Throwable th) {
                    th = th;
                    fileOutputStream = fileOutputStream2;
                    Utils.N(fileOutputStream);
                    Utils.L3(bitmap);
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
            }
        } catch (Throwable th3) {
            th = th3;
            bitmap = null;
        }
    }

    @Override
    public void setExternalEnabled(boolean z) {
        this.o = z;
        L l = this.n;
        if (l != null) {
            l.setLocked(!z);
        }
    }

    @Override
    public void setFloating(boolean z) {
        this.T = z;
    }

    @ScriptAllowed
    public void setOnClientCertificateRequest(Object... objArr) {
        Utils.g("SetOnClientCertificateRequest", objArr, 1);
        final Function function = (Function) objArr[0];
        if (function != null) {
            final IXoneObject selfObject = getSelfObject();
            WebView.clearClientCertPreferences(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.U(selfObject, function);
                }
            });
        } else {
            throw new IllegalArgumentException("SetOnClientCertificateRequest(): onClientCertificateRequest callback argument cannot be null");
        }
    }

    @ScriptAllowed
    public void setOnPageLoadedCallback(Object... objArr) {
        Utils.g("SetOnPageLoadedCallback", objArr, 1);
        Function function = (Function) objArr[0];
        if (function == null) {
            throw new IllegalArgumentException("SetOnPageLoadedCallback(): onPageLoaded callback argument cannot be null");
        }
        IXoneObject selfObject = getSelfObject();
        if (selfObject != null) {
            selfObject.bind(false, this.B, "onpageloaded", function);
            return;
        }
        throw new IllegalArgumentException("SetOnPageLoadedCallback(): No data object found");
    }

    public void setPassword(String str) {
        this.x = str;
    }

    @ScriptAllowed
    public void setUserAgent(Object... objArr) {
        Utils.j("SetUserAgent", objArr);
        Utils.g("SetUserAgent", objArr, 1);
        this.v = t.z(objArr[0], "");
        if (getInnerWebView() == null) {
            throw new NullPointerException("SetUserAgent(): Error, cannot find inner webview in view hierarchy");
        }
        if (!Utils.s3()) {
            this.n.post(new b4(this));
            return;
        }
        throw new IllegalStateException("SetUserAgent(): Cannot be invoked on the UI thread");
    }

    public void setUserName(String str) {
        this.w = str;
    }

    @ScriptAllowed
    public void stopLoading() {
        if (Utils.s3()) {
            Z();
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.Z();
                }
            });
        }
    }

    public void L(String str) {
        if (this.n == null) {
            return;
        }
        PrintJob print = ((PrintManager) getContext().getSystemService("print")).print(str, this.n.createPrintDocumentAdapter(str), new PrintAttributes.Builder().build());
        if (this.R == null) {
            this.R = new HashMap();
        }
        this.R.put(str, print);
    }

    public boolean u() {
        L l = this.n;
        if (l == null) {
            return false;
        }
        return l.canGoBack();
    }

    @ScriptAllowed
    public void unlockReload() {
        this.Q = false;
    }

    public boolean v(int i) {
        L l = this.n;
        if (l == null) {
            return false;
        }
        return l.canGoBackOrForward(i);
    }

    public boolean w() {
        L l = this.n;
        if (l == null) {
            return false;
        }
        return l.canGoForward();
    }

    public void x() {
        L l = this.n;
        if (l == null) {
            return;
        }
        l.clearCache(true);
    }

    public void y() {
        L l = this.n;
        if (l == null) {
            return;
        }
        l.clearHistory();
    }

    public final void z() {
        try {
            L l = this.n;
            if (l == null) {
                return;
            }
            WebSettings settings = l.getSettings();
            settings.setUserAgentString(this.v);
            settings.setBuiltInZoomControls(true);
            settings.setDisplayZoomControls(this.u);
            settings.setJavaScriptEnabled(true);
            settings.setGeolocationEnabled(true);
            settings.setGeolocationDatabasePath(getContext().getFilesDir().getPath());
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setUseWideViewPort(true);
            settings.setLoadWithOverviewMode(true);
            settings.setMediaPlaybackRequiresUserGesture(false);
            settings.setAllowFileAccess(true);
            settings.setAllowFileAccessFromFileURLs(true);
            settings.setAllowUniversalAccessFromFileURLs(true);
            this.n.setInitialScale(this.z);
            settings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
            settings.setDomStorageEnabled(true);
            this.n.setWebViewClient(this.O);
            this.n.setWebChromeClient(this.P);
            this.n.setEnabled(true);
            this.n.setFocusableInTouchMode(true);
            this.n.setHorizontalScrollBarEnabled(true);
            this.n.setVerticalScrollBarEnabled(true);
            this.n.setOnTouchListener(this);
            setVisibility(0);
            if (!this.Q) {
                Q(this.C);
            }
            this.D.E(this);
            setClickable(true);
            setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    XOneWebView.this.N(view);
                }
            });
            this.n.addJavascriptInterface(new XOneWebViewJsBridge(this, getBaseActivity(), this.E, this.B), "xone");
        } catch (Exception e) {
            I(e);
        }
    }

    @ScriptAllowed
    public void zoomBy(Object... objArr) {
        Utils.j("ZoomBy", objArr);
        Utils.g("ZoomBy", objArr, 1);
        final float m = q.m(objArr[0], 0.0f);
        if (Utils.s3()) {
            V(m);
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.V(m);
                }
            });
        }
    }

    @ScriptAllowed
    public void zoomIn() {
        if (Utils.s3()) {
            b0();
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.b0();
                }
            });
        }
    }

    @ScriptAllowed
    public void zoomOut() {
        if (Utils.s3()) {
            c0();
        } else {
            j.m(new Runnable() {
                @Override
                public final void run() {
                    XOneWebView.this.c0();
                }
            });
        }
    }
}