导航菜单

页面标题

页面副标题

Pulsar v1.0.0 - m.java 源代码

正在查看: Pulsar v1.0.0 应用的 m.java JAVA 源代码文件

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


package com.reactnativecommunity.webview;

import android.app.Activity;
import android.app.DownloadManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.webkit.k0;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.ThemedReactContext;
import com.xly.analytics.android.sdk.util.Base64Coder;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Charsets;
import kotlin.text.w;
import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;

public final class m {

    @NotNull
    public static final a C = new a(null);

    @NotNull
    public static final String D = "RNCWebView";
    private final int A;
    private final int B;
    private final boolean a;

    @NotNull
    private final String b;

    @NotNull
    private j c;
    private boolean d;
    private boolean e;

    @f8.d
    private String f;

    @f8.d
    private String g;
    private boolean h;

    @f8.d
    private ReadableMap i;

    @f8.d
    private String j;

    @f8.d
    private String k;

    @NotNull
    private final String l;

    @NotNull
    private final String m;

    @NotNull
    private final String n;

    @NotNull
    private final String o;

    @NotNull
    private final String p;

    @NotNull
    private final String q;
    private final int r;
    private final int s;
    private final int t;
    private final int u;
    private final int v;
    private final int w;
    private final int x;
    private final int y;
    private final int z;

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

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

    public static final class b extends e {
        b(RNCWebView rNCWebView) {
            super(rNCWebView);
        }

        @Override
        @f8.d
        public Bitmap getDefaultVideoPoster() {
            return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
        }
    }

    public static final class c extends e {
        final Activity Z;
        final int a0;

        c(RNCWebView rNCWebView, Activity activity, int i) {
            super(rNCWebView);
            this.Z = activity;
            this.a0 = i;
        }

        @Override
        @f8.d
        public Bitmap getDefaultVideoPoster() {
            return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
        }

        @Override
        public void onHideCustomView() {
            if (this.b == null) {
                return;
            }
            ViewGroup c = c();
            (c.getRootView() != this.a.getRootView() ? this.a.getRootView() : this.a).setVisibility(0);
            this.Z.getWindow().clearFlags(512);
            c.removeView(this.b);
            this.c.onCustomViewHidden();
            this.b = null;
            this.c = null;
            this.Z.setRequestedOrientation(this.a0);
            this.a.getThemedReactContext().removeLifecycleEventListener(this);
        }

        @Override
        public void onShowCustomView(@NotNull View view, @NotNull WebChromeClient.CustomViewCallback callback) {
            Intrinsics.checkNotNullParameter(view, "view");
            Intrinsics.checkNotNullParameter(callback, "callback");
            if (this.b != null) {
                callback.onCustomViewHidden();
                return;
            }
            this.b = view;
            this.c = callback;
            this.Z.setRequestedOrientation(-1);
            this.b.setSystemUiVisibility(7942);
            this.Z.getWindow().setFlags(512, 512);
            this.b.setBackgroundColor(-16777216);
            ViewGroup c = c();
            c.addView(this.b, e.w);
            (c.getRootView() != this.a.getRootView() ? this.a.getRootView() : this.a).setVisibility(8);
            this.a.getThemedReactContext().addLifecycleEventListener(this);
        }
    }

    public m() {
        this(false, 1, null);
    }

    public static final void c(RNCWebView webView, m this$0, String str, String str2, String str3, String str4, long j) {
        Intrinsics.checkNotNullParameter(webView, "$webView");
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        webView.setIgnoreErrFailedForThisURL(str);
        RNCWebViewModule nativeModule = webView.getReactApplicationContext().getNativeModule(RNCWebViewModule.class);
        if (nativeModule == null) {
            return;
        }
        try {
            DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
            String guessFileName = q.guessFileName(str, str3, str4);
            Intrinsics.checkNotNull(guessFileName);
            String replace = n.getInvalidCharRegex().replace(guessFileName, "_");
            String str5 = "Downloading " + replace;
            try {
                URL url = new URL(str);
                request.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url.getProtocol() + "://" + url.getHost()));
            } catch (MalformedURLException e) {
                Log.w(this$0.b, "Error getting cookie for DownloadManager", e);
            }
            request.addRequestHeader("User-Agent", str2);
            request.setTitle(replace);
            request.setDescription(str5);
            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(1);
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, replace);
            nativeModule.setDownloadRequest(request);
            if (nativeModule.grantFileDownloaderPermissions(this$0.d(), this$0.e())) {
                nativeModule.downloadFile(this$0.d());
            }
        } catch (IllegalArgumentException e2) {
            Log.w(this$0.b, "Unsupported URI, aborting download", e2);
        }
    }

    private final String d() {
        String str = this.f;
        return str == null ? this.p : str;
    }

    private final String e() {
        String str = this.g;
        return str == null ? this.q : str;
    }

    private final void f(RNCWebViewWrapper rNCWebViewWrapper, ReadableMap readableMap) {
        byte[] bArr;
        RNCWebView webView = rNCWebViewWrapper.getWebView();
        if (readableMap != null) {
            if (readableMap.hasKey("html")) {
                String string = readableMap.getString("html");
                String string2 = readableMap.hasKey("baseUrl") ? readableMap.getString("baseUrl") : "";
                Intrinsics.checkNotNull(string);
                webView.loadDataWithBaseURL(string2, string, this.m, this.l, null);
                return;
            }
            if (readableMap.hasKey("uri")) {
                String string3 = readableMap.getString("uri");
                String url = webView.getUrl();
                if (url == null || !Intrinsics.areEqual(url, string3)) {
                    if (readableMap.hasKey("method") && w.equals(readableMap.getString("method"), this.n, true)) {
                        if (readableMap.hasKey("body")) {
                            String string4 = readableMap.getString("body");
                            try {
                                Intrinsics.checkNotNull(string4);
                                Charset forName = Charset.forName(Base64Coder.CHARSET_UTF8);
                                Intrinsics.checkNotNullExpressionValue(forName, "forName(...)");
                                bArr = string4.getBytes(forName);
                                Intrinsics.checkNotNullExpressionValue(bArr, "getBytes(...)");
                            } catch (UnsupportedEncodingException unused) {
                                Intrinsics.checkNotNull(string4);
                                bArr = string4.getBytes(Charsets.UTF_8);
                                Intrinsics.checkNotNullExpressionValue(bArr, "getBytes(...)");
                            }
                        } else {
                            bArr = null;
                        }
                        if (bArr == null) {
                            bArr = new byte[0];
                        }
                        Intrinsics.checkNotNull(string3);
                        webView.postUrl(string3, bArr);
                        return;
                    }
                    HashMap hashMap = new HashMap();
                    if (readableMap.hasKey("headers")) {
                        if (this.a) {
                            ReadableArray array = readableMap.getArray("headers");
                            Intrinsics.checkNotNull(array);
                            Iterator it = array.toArrayList().iterator();
                            while (it.hasNext()) {
                                Object next = it.next();
                                Intrinsics.checkNotNull(next, "null cannot be cast to non-null type java.util.HashMap<kotlin.String, kotlin.String>{ kotlin.collections.TypeAliasesKt.HashMap<kotlin.String, kotlin.String> }");
                                HashMap hashMap2 = (HashMap) next;
                                String str = (String) hashMap2.get("name");
                                if (str == null) {
                                    str = "";
                                }
                                String str2 = (String) hashMap2.get("value");
                                if (str2 == null) {
                                    str2 = "";
                                }
                                Locale ENGLISH = Locale.ENGLISH;
                                Intrinsics.checkNotNullExpressionValue(ENGLISH, "ENGLISH");
                                String lowerCase = str.toLowerCase(ENGLISH);
                                Intrinsics.checkNotNullExpressionValue(lowerCase, "toLowerCase(...)");
                                if (Intrinsics.areEqual("user-agent", lowerCase)) {
                                    webView.getSettings().setUserAgentString(str2);
                                } else {
                                    hashMap.put(str, str2);
                                }
                            }
                        } else {
                            ReadableMap map = readableMap.getMap("headers");
                            Intrinsics.checkNotNull(map);
                            ReadableMapKeySetIterator keySetIterator = map.keySetIterator();
                            Intrinsics.checkNotNullExpressionValue(keySetIterator, "keySetIterator(...)");
                            while (keySetIterator.hasNextKey()) {
                                String nextKey = keySetIterator.nextKey();
                                Intrinsics.checkNotNull(nextKey);
                                Locale ENGLISH2 = Locale.ENGLISH;
                                Intrinsics.checkNotNullExpressionValue(ENGLISH2, "ENGLISH");
                                String lowerCase2 = nextKey.toLowerCase(ENGLISH2);
                                Intrinsics.checkNotNullExpressionValue(lowerCase2, "toLowerCase(...)");
                                if (Intrinsics.areEqual("user-agent", lowerCase2)) {
                                    webView.getSettings().setUserAgentString(map.getString(nextKey));
                                } else {
                                    hashMap.put(nextKey, map.getString(nextKey));
                                }
                            }
                        }
                    }
                    Intrinsics.checkNotNull(string3);
                    webView.loadUrl(string3, hashMap);
                    return;
                }
                return;
            }
        }
        webView.loadUrl(this.o);
    }

    public static final void g(WebView webView) {
    }

    private final void h(RNCWebViewWrapper rNCWebViewWrapper) {
        WebSettings settings;
        String str;
        RNCWebView webView = rNCWebViewWrapper.getWebView();
        if (this.j != null) {
            settings = webView.getSettings();
            str = this.j;
        } else if (this.k == null) {
            webView.getSettings().setUserAgentString(WebSettings.getDefaultUserAgent(webView.getContext()));
            return;
        } else {
            settings = webView.getSettings();
            str = this.k;
        }
        settings.setUserAgentString(str);
    }

    private final void i(RNCWebView rNCWebView) {
        Activity currentActivity = rNCWebView.getThemedReactContext().getCurrentActivity();
        if (this.d && currentActivity != null) {
            c cVar = new c(rNCWebView, currentActivity, currentActivity.getRequestedOrientation());
            cVar.setAllowsProtectedMedia(this.e);
            cVar.setHasOnOpenWindowEvent(this.h);
            rNCWebView.setWebChromeClient(cVar);
            return;
        }
        e eVar = (e) rNCWebView.getWebChromeClient();
        if (eVar != null) {
            eVar.onHideCustomView();
        }
        b bVar = new b(rNCWebView);
        bVar.setAllowsProtectedMedia(this.e);
        bVar.setHasOnOpenWindowEvent(this.h);
        rNCWebView.setWebChromeClient(bVar);
    }

    @NotNull
    public final RNCWebView createRNCWebViewInstance(@NotNull ThemedReactContext context) {
        Intrinsics.checkNotNullParameter(context, "context");
        return new RNCWebView(context);
    }

    @NotNull
    public final RNCWebViewWrapper createViewInstance(@NotNull ThemedReactContext context) {
        Intrinsics.checkNotNullParameter(context, "context");
        return createViewInstance(context, createRNCWebViewInstance(context));
    }

    public final int getCOMMAND_CLEAR_CACHE() {
        return this.A;
    }

    public final int getCOMMAND_CLEAR_FORM_DATA() {
        return this.z;
    }

    public final int getCOMMAND_CLEAR_HISTORY() {
        return this.B;
    }

    public final int getCOMMAND_FOCUS() {
        return this.y;
    }

    public final int getCOMMAND_GO_BACK() {
        return this.r;
    }

    public final int getCOMMAND_GO_FORWARD() {
        return this.s;
    }

    public final int getCOMMAND_INJECT_JAVASCRIPT() {
        return this.w;
    }

    public final int getCOMMAND_LOAD_URL() {
        return this.x;
    }

    public final int getCOMMAND_POST_MESSAGE() {
        return this.v;
    }

    public final int getCOMMAND_RELOAD() {
        return this.t;
    }

    public final int getCOMMAND_STOP_LOADING() {
        return this.u;
    }

    @f8.d
    public final Map<String, Integer> getCommandsMap() {
        return MapBuilder.builder().put("goBack", Integer.valueOf(this.r)).put("goForward", Integer.valueOf(this.s)).put("reload", Integer.valueOf(this.t)).put("stopLoading", Integer.valueOf(this.u)).put("postMessage", Integer.valueOf(this.v)).put("injectJavaScript", Integer.valueOf(this.w)).put("loadUrl", Integer.valueOf(this.x)).put("requestFocus", Integer.valueOf(this.y)).put("clearFormData", Integer.valueOf(this.z)).put("clearCache", Integer.valueOf(this.A)).put("clearHistory", Integer.valueOf(this.B)).build();
    }

    public final void onAfterUpdateTransaction(@NotNull RNCWebViewWrapper viewWrapper) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        ReadableMap readableMap = this.i;
        if (readableMap != null) {
            f(viewWrapper, readableMap);
        }
        this.i = null;
    }

    public final void onDropViewInstance(@NotNull RNCWebViewWrapper viewWrapper) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        webView.getThemedReactContext().removeLifecycleEventListener(webView);
        webView.a();
        webView.c0 = null;
    }

    public final void receiveCommand(@NotNull RNCWebViewWrapper viewWrapper, @NotNull String commandId, @NotNull ReadableArray args) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        Intrinsics.checkNotNullParameter(commandId, "commandId");
        Intrinsics.checkNotNullParameter(args, "args");
        RNCWebView webView = viewWrapper.getWebView();
        switch (commandId.hashCode()) {
            case -1241591313:
                if (commandId.equals("goBack")) {
                    webView.goBack();
                    return;
                }
                return;
            case -948122918:
                if (commandId.equals("stopLoading")) {
                    webView.stopLoading();
                    return;
                }
                return;
            case -934641255:
                if (commandId.equals("reload")) {
                    webView.reload();
                    return;
                }
                return;
            case -759238347:
                if (commandId.equals("clearCache")) {
                    webView.clearCache(args.getBoolean(0));
                    return;
                }
                return;
            case -318289731:
                if (commandId.equals("goForward")) {
                    webView.goForward();
                    return;
                }
                return;
            case -265032709:
                if (commandId.equals("clearFormData")) {
                    webView.clearFormData();
                    return;
                }
                return;
            case 336631465:
                if (commandId.equals("loadUrl")) {
                    String string = args.getString(0);
                    if (string == null) {
                        throw new RuntimeException("Arguments for loading an url are null!");
                    }
                    webView.a0.setWaitingForCommandLoadUrl(false);
                    webView.loadUrl(string);
                    return;
                }
                return;
            case 903120263:
                if (commandId.equals("clearHistory")) {
                    webView.clearHistory();
                    return;
                }
                return;
            case 1280029577:
                if (commandId.equals("requestFocus")) {
                    webView.requestFocus();
                    return;
                }
                return;
            case 1490029383:
                if (commandId.equals("postMessage")) {
                    try {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("data", args.getString(0));
                        webView.f("(function () {var event;var data = " + jSONObject + ";try {event = new MessageEvent('message', data);} catch (e) {event = document.createEvent('MessageEvent');event.initMessageEvent('message', true, true, data.data, data.origin, data.lastEventId, data.source);}document.dispatchEvent(event);})();");
                        return;
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                }
                return;
            case 2104576510:
                if (commandId.equals("injectJavaScript")) {
                    webView.f(args.getString(0));
                    return;
                }
                return;
            default:
                return;
        }
    }

    public final void setAllowFileAccess(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setAllowFileAccess(z);
    }

    public final void setAllowFileAccessFromFileURLs(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setAllowFileAccessFromFileURLs(z);
    }

    public final void setAllowUniversalAccessFromFileURLs(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setAllowUniversalAccessFromFileURLs(z);
    }

    public final void setAllowsFullscreenVideo(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        this.d = z;
        i(webView);
    }

    public final void setAllowsProtectedMedia(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        WebChromeClient webChromeClient;
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        this.e = z;
        if (Build.VERSION.SDK_INT < 26 || (webChromeClient = webView.getWebChromeClient()) == null || !(webChromeClient instanceof e)) {
            return;
        }
        ((e) webChromeClient).setAllowsProtectedMedia(z);
    }

    public final void setAndroidLayerType(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setLayerType(Intrinsics.areEqual(str, "hardware") ? 2 : Intrinsics.areEqual(str, "software") ? 1 : 0, null);
    }

    public final void setApplicationNameForUserAgent(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        String str2;
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        if (str != null) {
            str2 = WebSettings.getDefaultUserAgent(viewWrapper.getWebView().getContext()) + " " + str;
        } else {
            str2 = null;
        }
        this.k = str2;
        h(viewWrapper);
    }

    public final void setBasicAuthCredential(@NotNull RNCWebViewWrapper viewWrapper, @f8.d ReadableMap readableMap) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setBasicAuthCredential((readableMap != null && readableMap.hasKey("username") && readableMap.hasKey("password")) ? new com.reactnativecommunity.webview.c(readableMap.getString("username"), readableMap.getString("password")) : null);
    }

    public final void setCacheEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setCacheMode(z ? -1 : 2);
    }

    public final void setCacheMode(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        WebSettings settings = viewWrapper.getWebView().getSettings();
        int i = -1;
        if (str != null) {
            switch (str.hashCode()) {
                case -2059164003:
                    if (str.equals("LOAD_NO_CACHE")) {
                        i = 2;
                        break;
                    }
                    break;
                case -1215135800:
                    str.equals("LOAD_DEFAULT");
                    break;
                case -873877826:
                    if (str.equals("LOAD_CACHE_ELSE_NETWORK")) {
                        i = 1;
                        break;
                    }
                    break;
                case 1548620642:
                    if (str.equals("LOAD_CACHE_ONLY")) {
                        i = 3;
                        break;
                    }
                    break;
            }
        }
        settings.setCacheMode(i);
    }

    public final void setDomStorageEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setDomStorageEnabled(z);
    }

    public final void setDownloadingMessage(@f8.d String str) {
        this.f = str;
    }

    public final void setForceDarkOn(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        if (Build.VERSION.SDK_INT > 28) {
            if (k0.isFeatureSupported("FORCE_DARK")) {
                androidx.webkit.w.setForceDark(webView.getSettings(), z ? 2 : 0);
            }
            if (z && k0.isFeatureSupported("FORCE_DARK_STRATEGY")) {
                androidx.webkit.w.setForceDarkStrategy(webView.getSettings(), 2);
            }
        }
    }

    public final void setGeolocationEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setGeolocationEnabled(z);
    }

    public final void setHasOnOpenWindowEvent(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        this.h = z;
        i(webView);
    }

    public final void setHasOnScroll(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setHasScrollEvent(z);
    }

    public final void setIncognito(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        if (z) {
            CookieManager.getInstance().removeAllCookies(null);
            webView.getSettings().setCacheMode(2);
            webView.clearHistory();
            webView.clearCache(true);
            webView.clearFormData();
            webView.getSettings().setSavePassword(false);
            webView.getSettings().setSaveFormData(false);
        }
    }

    public final void setInjectedJavaScript(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().a = str;
    }

    public final void setInjectedJavaScriptBeforeContentLoaded(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().b = str;
    }

    public final void setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().f = z;
    }

    public final void setInjectedJavaScriptForMainFrameOnly(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().e = z;
    }

    public final void setInjectedJavaScriptObject(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setInjectedJavaScriptObject(str);
    }

    public final void setJavaScriptCanOpenWindowsAutomatically(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setJavaScriptCanOpenWindowsAutomatically(z);
    }

    public final void setJavaScriptEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setJavaScriptEnabled(z);
    }

    public final void setLackPermissionToDownloadMessage(@f8.d String str) {
        this.g = str;
    }

    public final void setMediaPlaybackRequiresUserAction(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setMediaPlaybackRequiresUserGesture(z);
    }

    public final void setMenuCustomItems(@NotNull RNCWebViewWrapper viewWrapper, @f8.d ReadableArray readableArray) {
        ArrayList arrayList;
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        if (readableArray == null) {
            arrayList = null;
        } else {
            arrayList = readableArray.toArrayList();
            Intrinsics.checkNotNull(arrayList, "null cannot be cast to non-null type kotlin.collections.List<kotlin.collections.Map<kotlin.String, kotlin.String>>");
        }
        webView.setMenuCustomItems(arrayList);
    }

    public final void setMessagingEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setMessagingEnabled(z);
    }

    public final void setMessagingModuleName(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().i = str;
    }

    public final void setMinimumFontSize(@NotNull RNCWebViewWrapper viewWrapper, int i) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setMinimumFontSize(i);
    }

    public final void setMixedContentMode(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        WebSettings settings;
        int i;
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        if (str == null || Intrinsics.areEqual("never", str)) {
            settings = webView.getSettings();
            i = 1;
        } else if (Intrinsics.areEqual("always", str)) {
            settings = webView.getSettings();
            i = 0;
        } else {
            if (!Intrinsics.areEqual("compatibility", str)) {
                return;
            }
            settings = webView.getSettings();
            i = 2;
        }
        settings.setMixedContentMode(i);
    }

    public final void setNestedScrollEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().w = z;
    }

    public final void setOverScrollMode(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        int i = 0;
        if (str != null) {
            int hashCode = str.hashCode();
            if (hashCode == -1414557169) {
                str.equals("always");
            } else if (hashCode != 104712844) {
                if (hashCode == 951530617 && str.equals(v6.a.d)) {
                    i = 1;
                }
            } else if (str.equals("never")) {
                i = 2;
            }
        }
        webView.setOverScrollMode(i);
    }

    public final void setSaveFormDataDisabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setSaveFormData(!z);
    }

    public final void setScalesPageToFit(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        RNCWebView webView = viewWrapper.getWebView();
        webView.getSettings().setLoadWithOverviewMode(z);
        webView.getSettings().setUseWideViewPort(z);
    }

    public final void setSetBuiltInZoomControls(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setBuiltInZoomControls(z);
    }

    public final void setSetDisplayZoomControls(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setDisplayZoomControls(z);
    }

    public final void setSetSupportMultipleWindows(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setSupportMultipleWindows(z);
    }

    public final void setShowsHorizontalScrollIndicator(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setHorizontalScrollBarEnabled(z);
    }

    public final void setShowsVerticalScrollIndicator(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().setVerticalScrollBarEnabled(z);
    }

    public final void setSource(@NotNull RNCWebViewWrapper viewWrapper, @f8.d ReadableMap readableMap) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        this.i = readableMap;
    }

    public final void setTextZoom(@NotNull RNCWebViewWrapper viewWrapper, int i) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        viewWrapper.getWebView().getSettings().setTextZoom(i);
    }

    public final void setThirdPartyCookiesEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        CookieManager.getInstance().setAcceptThirdPartyCookies(viewWrapper.getWebView(), z);
    }

    public final void setUserAgent(@NotNull RNCWebViewWrapper viewWrapper, @f8.d String str) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        this.j = str;
        h(viewWrapper);
    }

    public final void setWebviewDebuggingEnabled(@NotNull RNCWebViewWrapper viewWrapper, boolean z) {
        Intrinsics.checkNotNullParameter(viewWrapper, "viewWrapper");
        WebView.setWebContentsDebuggingEnabled(z);
    }

    public m(boolean z) {
        this.a = z;
        this.b = "RNCWebViewManagerImpl";
        this.c = new j() {
            @Override
            public final void configWebView(WebView webView) {
                m.g(webView);
            }
        };
        this.l = Base64Coder.CHARSET_UTF8;
        this.m = "text/html";
        this.n = "POST";
        this.o = "about:blank";
        this.p = "Downloading";
        this.q = "Cannot download files as permission was denied. Please provide permission to write to storage, in order to download files.";
        this.r = 1;
        this.s = 2;
        this.t = 3;
        this.u = 4;
        this.v = 5;
        this.w = 6;
        this.x = 7;
        this.y = 8;
        this.z = 1000;
        this.A = 1001;
        this.B = 1002;
    }

    @NotNull
    public final RNCWebViewWrapper createViewInstance(@NotNull ThemedReactContext context, @NotNull final RNCWebView webView) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(webView, "webView");
        i(webView);
        context.addLifecycleEventListener(webView);
        this.c.configWebView(webView);
        WebSettings settings = webView.getSettings();
        Intrinsics.checkNotNullExpressionValue(settings, "getSettings(...)");
        settings.setBuiltInZoomControls(true);
        settings.setDisplayZoomControls(false);
        settings.setDomStorageEnabled(true);
        settings.setSupportMultipleWindows(true);
        settings.setAllowFileAccess(false);
        settings.setAllowContentAccess(false);
        settings.setAllowFileAccessFromFileURLs(false);
        settings.setAllowUniversalAccessFromFileURLs(false);
        settings.setMixedContentMode(1);
        webView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        webView.setDownloadListener(new DownloadListener() {
            @Override
            public final void onDownloadStart(String str, String str2, String str3, String str4, long j) {
                m.c(RNCWebView.this, this, str, str2, str3, str4, j);
            }
        });
        return new RNCWebViewWrapper(context, webView);
    }

    public m(boolean z, int i, DefaultConstructorMarker defaultConstructorMarker) {
        this((i & 1) != 0 ? false : z);
    }
}