Wolves Themes v1.0版本的 MD5 值为:cddc92b47f6b7c4a195c9625507eb51c

以下内容为反编译后的 VungleWebClient.java 源代码,内容仅作参考


package com.vungle.warren.ui;

import android.net.Uri;
import android.os.Build;
import android.support.annotation.Nullable;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.gson.JsonObject;
import com.ironsource.sdk.constants.Constants;
import com.mopub.common.AdType;
import com.vungle.warren.DirectDownloadAdapter;
import com.vungle.warren.SDKDownloadClient;
import com.vungle.warren.model.Advertisement;
import com.vungle.warren.model.Placement;
import org.nexage.sourcekit.mraid.MRAIDNativeFeature;
public class VungleWebClient extends WebViewClient {
    private MRAIDDelegate MRAIDDelegate;
    private Advertisement advertisement;
    private boolean collectConsent;
    private DirectDownloadAdapter directDownloadAdapter;
    private String gdprAccept;
    private String gdprBody;
    private String gdprDeny;
    private String gdprTitle;
    private WebView loadedWebView;
    private Placement placement;
    private boolean ready = false;

    public interface MRAIDDelegate {
        boolean processCommand(String str, JsonObject jsonObject);
    }

    public VungleWebClient(Advertisement advertisement, Placement placement, DirectDownloadAdapter directDownloadAdapter) {
        this.advertisement = advertisement;
        this.placement = placement;
        this.directDownloadAdapter = directDownloadAdapter;
    }

    public VungleWebClient(Advertisement advertisement, Placement placement) {
        this.advertisement = advertisement;
        this.placement = placement;
    }

    public void setConsentStatus(boolean collectedConsent, @Nullable String title, @Nullable String message, @Nullable String accept, @Nullable String deny) {
        this.collectConsent = collectedConsent;
        this.gdprTitle = title;
        this.gdprBody = message;
        this.gdprAccept = accept;
        this.gdprDeny = deny;
    }

    public void setMRAIDDelegate(MRAIDDelegate MRAIDDelegate2) {
        this.MRAIDDelegate = MRAIDDelegate2;
    }

    @Override
    public boolean shouldOverrideUrlLoading(final WebView view, String url) {
        Log.d("Vungle", "MRAID Command " + url);
        Uri uri = Uri.parse(url);
        if (uri.getScheme().equals(AdType.MRAID)) {
            String command = uri.getHost();
            if (command.equals("propertiesChangeCompleted") && !this.ready) {
                final JsonObject mraidArgs = this.advertisement.getMRAIDArgs();
                if (this.directDownloadAdapter != null) {
                    this.directDownloadAdapter.getSdkDownloadClient().setInstallStatusCheck(new SDKDownloadClient.InstallStatusCheck() {
                        @Override
                        public void isAppInstalled(boolean isInstalled, boolean isInAppPurchase) {
                            mraidArgs.addProperty("isDirectDownload", (Boolean) true);
                            mraidArgs.addProperty("isDisplayIAP", Boolean.valueOf(isInAppPurchase));
                            mraidArgs.addProperty("isInstalled", Boolean.valueOf(isInstalled));
                            view.loadUrl("javascript:window.vungle.mraidBridge.notifyReadyEvent(" + mraidArgs + ")");
                        }
                    });
                    this.directDownloadAdapter.getSdkDownloadClient().installStatusRequest();
                } else {
                    view.loadUrl("javascript:window.vungle.mraidBridge.notifyReadyEvent(" + this.advertisement.getMRAIDArgs() + ")");
                }
                this.ready = true;
                return true;
            } else if (this.MRAIDDelegate != null) {
                JsonObject args = new JsonObject();
                for (String param : uri.getQueryParameterNames()) {
                    args.addProperty(param, uri.getQueryParameter(param));
                }
                if (this.MRAIDDelegate.processCommand(command, args)) {
                    view.loadUrl("javascript:window.vungle.mraidBridge.notifyCommandComplete()");
                    return true;
                }
                return true;
            } else {
                return true;
            }
        }
        return false;
    }

    @Override
    public void onPageFinished(WebView webView, String url) {
        super.onPageFinished(webView, url);
        switch (this.advertisement.getAdType()) {
            case 0:
                webView.loadUrl("javascript:vungleInit({\"privacyPolicyEnabled\": \"true\"})");
                webView.loadUrl("javascript:function actionClicked(action){Android.performAction(action);};");
                return;
            case 1:
                this.loadedWebView = webView;
                notifyPropertiesChange();
                return;
            default:
                throw new IllegalArgumentException("Unknown Client Type!");
        }
    }

    public void setReady(boolean ready) {
        this.ready = ready;
    }

    public void notifyPropertiesChange() {
        if (this.loadedWebView != null) {
            JsonObject screenJson = new JsonObject();
            JsonObject size = new JsonObject();
            size.addProperty("width", Integer.valueOf(this.loadedWebView.getWidth()));
            size.addProperty("height", Integer.valueOf(this.loadedWebView.getHeight()));
            JsonObject position = new JsonObject();
            position.addProperty("x", (Number) 0);
            position.addProperty("y", (Number) 0);
            position.addProperty("width", Integer.valueOf(this.loadedWebView.getWidth()));
            position.addProperty("height", Integer.valueOf(this.loadedWebView.getHeight()));
            JsonObject supports = new JsonObject();
            supports.addProperty("sms", (Boolean) false);
            supports.addProperty("tel", (Boolean) false);
            supports.addProperty(MRAIDNativeFeature.CALENDAR, (Boolean) false);
            supports.addProperty(MRAIDNativeFeature.STORE_PICTURE, (Boolean) false);
            supports.addProperty(MRAIDNativeFeature.INLINE_VIDEO, (Boolean) false);
            screenJson.add("maxSize", size);
            screenJson.add("screenSize", size);
            screenJson.add("defaultPosition", position);
            screenJson.add("currentPosition", position);
            screenJson.add("supports", supports);
            screenJson.addProperty("placementType", this.advertisement.getTemplateType());
            screenJson.addProperty(Constants.ParametersKeys.IS_VIEWABLE, Boolean.valueOf(this.loadedWebView.getVisibility() == 0));
            screenJson.addProperty("osVersion", Integer.toString(Build.VERSION.SDK_INT));
            screenJson.addProperty("incentivized", Boolean.valueOf(this.placement.isIncentivized()));
            screenJson.addProperty("enableBackImmediately", Boolean.valueOf(this.advertisement.getShowCloseDelay(this.placement.isIncentivized()) == 0));
            screenJson.addProperty("version", "1.0");
            if (this.collectConsent) {
                screenJson.addProperty("consentRequired", (Boolean) true);
                screenJson.addProperty("consentTitleText", this.gdprTitle);
                screenJson.addProperty("consentBodyText", this.gdprBody);
                screenJson.addProperty("consentAcceptButtonText", this.gdprAccept);
                screenJson.addProperty("consentDenyButtonText", this.gdprDeny);
            } else {
                screenJson.addProperty("consentRequired", (Boolean) false);
            }
            Log.d("VungleWebClient", "loadJsjavascript:window.vungle.mraidBridge.notifyPropertiesChange(" + screenJson + ", true)");
            this.loadedWebView.loadUrl("javascript:window.vungle.mraidBridge.notifyPropertiesChange(" + screenJson + ", true)");
        }
    }

    public boolean isReady() {
        return this.ready;
    }
}