农商发展同盟 v1.0版本的 MD5 值为:19a7049686c0991b0d5f9a044d79c8bc

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


package io.dcloud.feature.x5;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ClipData;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.widget.EditText;
import androidx.core.content.FileProvider;
import com.tencent.smtt.export.external.interfaces.ConsoleMessage;
import com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback;
import com.tencent.smtt.export.external.interfaces.JsPromptResult;
import com.tencent.smtt.export.external.interfaces.JsResult;
import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebStorage;
import com.tencent.smtt.sdk.WebView;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.DHInterface.ISysEventListener;
import io.dcloud.common.DHInterface.ITitleNView;
import io.dcloud.common.adapter.ui.AdaWebview;
import io.dcloud.common.adapter.ui.FileChooseDialog;
import io.dcloud.common.adapter.util.AndroidResources;
import io.dcloud.common.adapter.util.DeviceInfo;
import io.dcloud.common.adapter.util.Logger;
import io.dcloud.common.adapter.util.PermissionUtil;
import io.dcloud.common.adapter.util.UEH;
import io.dcloud.common.constant.AbsoluteConst;
import io.dcloud.common.constant.StringConst;
import io.dcloud.common.util.AppConsoleLogUtil;
import io.dcloud.common.util.AppRuntime;
import io.dcloud.common.util.BaseInfo;
import io.dcloud.common.util.ExifInterface;
import io.dcloud.common.util.JSONUtil;
import io.dcloud.common.util.JSUtil;
import io.dcloud.common.util.PdrUtil;
import io.dcloud.common.util.TitleNViewUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import net.lingala.zip4j.util.InternalZipConstants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class X5WebJsEvent extends WebChromeClient {
    static final String TAG = "webview";
    FileChooseDialog dialog;
    AdaWebview mAdaWebview;
    ValueCallback<Uri> mUploadMessage;
    ValueCallback<Uri[]> mUploadMessage21Level;
    private boolean rptJsErr;
    DialogListener mListener = null;
    private Bitmap mDefaultVideoPoster = null;

    private boolean isUrlWhiteListed(String url) {
        return true;
    }

    public X5WebJsEvent(AdaWebview pWebview) {
        this.mAdaWebview = null;
        this.rptJsErr = true;
        this.mAdaWebview = pWebview;
        pWebview.mProgressIntValue = 0;
        this.rptJsErr = BaseInfo.getCmitInfo(BaseInfo.sLastRunApp).rptJse;
    }

    private boolean isCallbackId(String str) {
        return str != null && str.startsWith(IApp.ConfigProperty.CONFIG_PLUS);
    }

    private void handleMessage(final JsPromptResult result, final AdaWebview _webView, final String service, final String action, String message, final boolean async) {
        result.confirm(this.mAdaWebview.execScript(service, action, JSONUtil.createJSONArray(message), async));
    }

    @Override
    public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
        CharSequence charSequence;
        CharSequence charSequence2;
        CharSequence charSequence3;
        String str;
        int i;
        if (this.mAdaWebview == null) {
            return false;
        }
        boolean isUrlWhiteListed = isUrlWhiteListed(url);
        if (isUrlWhiteListed && defaultValue != null && defaultValue.length() > 3 && defaultValue.substring(0, 4).equals("pdr:")) {
            try {
                JSONArray jSONArray = new JSONArray(defaultValue.substring(4));
                String string = jSONArray.getString(0);
                String string2 = jSONArray.getString(1);
                boolean z = jSONArray.getBoolean(2);
                AdaWebview adaWebview = this.mAdaWebview;
                charSequence2 = "\\\"";
                charSequence3 = JSUtil.QUOTE;
                i = 4;
                str = "pdr:";
                try {
                    handleMessage(result, adaWebview, string, string2, message, z);
                    return true;
                } catch (JSONException e) {
                    e = e;
                    if (!PdrUtil.isEquals(defaultValue, defaultValue.replace(charSequence2, charSequence3))) {
                        String replace = message.replace(charSequence2, charSequence3);
                        String substring = replace.substring(1, replace.length() - 1);
                        String substring2 = defaultValue.replace(charSequence2, charSequence3).substring(i);
                        onJsPrompt(view, url, substring, str + substring2.substring(1, substring2.length() - 1), result);
                        return true;
                    }
                    e.printStackTrace();
                    Logger.e(TAG, "onJsPrompt js->native message=" + message + ";defaultValue=" + defaultValue);
                    return true;
                }
            } catch (JSONException e2) {
                e = e2;
                charSequence2 = "\\\"";
                charSequence3 = JSUtil.QUOTE;
                str = "pdr:";
                i = 4;
            }
        } else if (this.mAdaWebview.mReceiveJSValue_android42 != null && isUrlWhiteListed && defaultValue != null && defaultValue.length() > 5 && defaultValue.substring(0, 5).equals("sync:")) {
            try {
                JSONArray jSONArray2 = new JSONArray(defaultValue.substring(5));
                String __js__call__native__ = this.mAdaWebview.mReceiveJSValue_android42.__js__call__native__(jSONArray2.getString(0), jSONArray2.getString(1));
                charSequence = JSUtil.QUOTE;
                try {
                    result.confirm(__js__call__native__);
                    return true;
                } catch (JSONException e3) {
                    e = e3;
                    if (!PdrUtil.isEquals(defaultValue, defaultValue.replace("\\\"", charSequence))) {
                        String replace2 = message.replace("\\\"", charSequence);
                        String substring3 = replace2.substring(1, replace2.length() - 1);
                        String substring4 = defaultValue.replace("\\\"", charSequence).substring(4);
                        onJsPrompt(view, url, substring3, "pdr:" + substring4.substring(1, substring4.length() - 1), result);
                        return true;
                    }
                    e.printStackTrace();
                    Logger.e(TAG, "onJsPrompt js->native message=" + message + ";defaultValue=" + defaultValue);
                    return true;
                }
            } catch (JSONException e4) {
                e = e4;
                charSequence = JSUtil.QUOTE;
            }
        } else {
            final AlertDialog create = new AlertDialog.Builder(this.mAdaWebview.getActivity()).create();
            create.setMessage(message);
            create.setTitle(this.mAdaWebview.getAppName());
            final EditText editText = new EditText(this.mAdaWebview.getActivity());
            if (defaultValue != null) {
                editText.setText(defaultValue);
                editText.setSelection(0, defaultValue.length());
                DeviceInfo.showIME(editText);
            }
            create.setView(editText);
            create.setButton(StringConst.getString(17039370), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.confirm(editText.getText().toString());
                }
            });
            create.setButton2(StringConst.getString(17039360), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    result.cancel();
                }
            });
            create.setOnKeyListener(new DialogInterface.OnKeyListener() {
                @Override
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    if (!AndroidResources.sIMEAlive && event.getAction() == 0 && keyCode == 4) {
                        create.dismiss();
                        result.cancel();
                        return true;
                    }
                    return false;
                }
            });
            create.show();
            return true;
        }
    }

    @Override
    public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
        AdaWebview adaWebview = this.mAdaWebview;
        if (adaWebview != null && !PdrUtil.isEmpty(adaWebview.getAppName())) {
            final AlertDialog create = new AlertDialog.Builder(this.mAdaWebview.getActivity()).create();
            create.setTitle(this.mAdaWebview.getAppName());
            create.setMessage(message);
            if (this.mListener == null) {
                this.mListener = new DialogListener();
            }
            this.mListener.mResult = result;
            create.setButton(StringConst.getString(17039370), this.mListener);
            create.setCanceledOnTouchOutside(false);
            create.setOnKeyListener(new DialogInterface.OnKeyListener() {
                @Override
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    if (event.getAction() == 1 && keyCode == 4) {
                        result.cancel();
                        create.dismiss();
                        return true;
                    }
                    return false;
                }
            });
            create.show();
            return true;
        }
        return super.onJsAlert(view, url, message, result);
    }

    @Override
    public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
        AdaWebview adaWebview = this.mAdaWebview;
        if (adaWebview != null && !PdrUtil.isEmpty(adaWebview.getAppName())) {
            try {
                final AlertDialog create = new AlertDialog.Builder(this.mAdaWebview.getActivity()).create();
                create.setMessage(message);
                create.setTitle(this.mAdaWebview.getAppName());
                create.setButton(StringConst.getString(17039370), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        result.confirm();
                    }
                });
                create.setButton2(StringConst.getString(17039360), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        result.cancel();
                    }
                });
                create.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        result.cancel();
                    }
                });
                create.setOnKeyListener(new DialogInterface.OnKeyListener() {
                    @Override
                    public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                        if (event.getAction() == 0 && keyCode == 4) {
                            result.cancel();
                            create.dismiss();
                            return true;
                        }
                        return false;
                    }
                });
                create.show();
                return true;
            } catch (Exception e) {
                e.printStackTrace();
                return super.onJsConfirm(view, url, message, result);
            }
        }
        return super.onJsConfirm(view, url, message, result);
    }

    @Override
    public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> uploadMsg, WebChromeClient.FileChooserParams fileChooserParams) {
        openFileChooserLogic(null, uploadMsg, fileChooserParams.getAcceptTypes() != null ? fileChooserParams.getAcceptTypes()[0] : null, "", fileChooserParams);
        return true;
    }

    @Override
    public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
        openFileChooserLogic(uploadMsg, acceptType, capture);
    }

    private void openFileChooserLogic(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
        openFileChooserLogic(uploadMsg, null, acceptType, capture, null);
    }

    private void openFileChooserLogic(final ValueCallback<Uri> uploadMsg, final ValueCallback<Uri[]> uploadMsg21Level, final String acceptType, final String capture, final WebChromeClient.FileChooserParams fileChooserParams) {
        AdaWebview adaWebview = this.mAdaWebview;
        if (adaWebview == null) {
            return;
        }
        PermissionUtil.usePermission(adaWebview.getActivity(), "webview-x5", PermissionUtil.PMS_STORAGE, 2, new PermissionUtil.Request() {
            @Override
            public void onDenied(String perName) {
            }

            @Override
            public void onGranted(String perName) {
                X5WebJsEvent.this.showOpenFileChooser(uploadMsg, uploadMsg21Level, acceptType, capture, fileChooserParams);
            }
        });
    }

    public void showOpenFileChooser(ValueCallback<Uri> uploadMsg, ValueCallback<Uri[]> uploadMsg21Level, String acceptType, String capture, WebChromeClient.FileChooserParams fileChooserParams) {
        this.mUploadMessage = uploadMsg;
        this.mUploadMessage21Level = uploadMsg21Level;
        Intent intent = new Intent("android.intent.action.GET_CONTENT");
        intent.addCategory("android.intent.category.OPENABLE");
        if (!PdrUtil.isEmpty(acceptType)) {
            intent.setType(acceptType);
        } else {
            intent.setType("*/*");
        }
        if (fileChooserParams != null && fileChooserParams.getMode() == 1) {
            intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
        }
        this.dialog = new FileChooseDialog(this.mAdaWebview.getActivity(), this.mAdaWebview.getActivity(), intent);
        this.mAdaWebview.obtainFrameView().obtainApp().registerSysEventListener(new ISysEventListener() {
            @Override
            public boolean onExecute(ISysEventListener.SysEventType pEventType, Object pArgs) {
                Object[] objArr = (Object[]) pArgs;
                int intValue = ((Integer) objArr[0]).intValue();
                int intValue2 = ((Integer) objArr[1]).intValue();
                if (X5WebJsEvent.this.dialog != null) {
                    X5WebJsEvent.this.dialog.dismiss();
                }
                X5WebJsEvent.this.mAdaWebview.obtainFrameView().obtainApp().unregisterSysEventListener(this, ISysEventListener.SysEventType.onActivityResult);
                if (intValue2 != 0 && pEventType == ISysEventListener.SysEventType.onActivityResult) {
                    Intent intent2 = (Intent) objArr[2];
                    ArrayList arrayList = new ArrayList();
                    if (intValue == 1) {
                        if (intent2.getClipData() != null) {
                            ClipData clipData = intent2.getClipData();
                            for (int i = 0; i < clipData.getItemCount(); i++) {
                                Uri uri = clipData.getItemAt(i).getUri();
                                if (uri != null && "content".equals(uri.getScheme())) {
                                    arrayList.add(getUri(uri));
                                }
                            }
                        } else {
                            Uri data = intent2.getData();
                            if (data != null && "content".equals(data.getScheme())) {
                                data = getUri(data);
                            }
                            arrayList.add(data);
                            Logger.i(X5WebJsEvent.TAG, "openFileChooserLogic  OnActivityResult url=" + data);
                        }
                    } else if (intValue == 2 && X5WebJsEvent.this.dialog.uris != null) {
                        Iterator<File> it = X5WebJsEvent.this.dialog.uris.iterator();
                        while (true) {
                            if (!it.hasNext()) {
                                break;
                            }
                            File next = it.next();
                            if (next.exists()) {
                                Activity activity = X5WebJsEvent.this.mAdaWebview.getActivity();
                                arrayList.add(FileProvider.getUriForFile(activity, X5WebJsEvent.this.mAdaWebview.getActivity().getPackageName() + ".dc.fileprovider", next));
                                break;
                            }
                        }
                    }
                    Uri[] uriArr = arrayList.size() > 0 ? (Uri[]) arrayList.toArray(new Uri[arrayList.size()]) : null;
                    if (X5WebJsEvent.this.mUploadMessage21Level != null) {
                        X5WebJsEvent.this.mUploadMessage21Level.onReceiveValue(uriArr);
                    } else if (X5WebJsEvent.this.mUploadMessage != null) {
                        X5WebJsEvent.this.mUploadMessage.onReceiveValue(arrayList.isEmpty() ? null : (Uri) arrayList.get(0));
                    }
                    return true;
                }
                if (X5WebJsEvent.this.mUploadMessage21Level != null) {
                    X5WebJsEvent.this.mUploadMessage21Level.onReceiveValue(null);
                } else if (X5WebJsEvent.this.mUploadMessage != null) {
                    X5WebJsEvent.this.mUploadMessage.onReceiveValue(null);
                }
                return false;
            }

            private Uri getUri(Uri value) {
                Cursor query = X5WebJsEvent.this.mAdaWebview.getContext().getContentResolver().query(value, new String[]{"_data"}, null, null, null);
                if (query != null) {
                    if (Build.VERSION.SDK_INT < 29 && query.moveToFirst()) {
                        try {
                            int columnIndexOrThrow = query.getColumnIndexOrThrow("_data");
                            if (columnIndexOrThrow > -1) {
                                String string = query.getString(columnIndexOrThrow);
                                value = Uri.parse(string);
                                if (PdrUtil.isEmpty(value.getScheme())) {
                                    String str = string.startsWith(InternalZipConstants.ZIP_FILE_SEPARATOR) ? DeviceInfo.FILE_PROTOCOL : "file:///";
                                    value = Uri.parse(str + string);
                                }
                            }
                        } catch (Exception unused) {
                        }
                    }
                    query.close();
                }
                return value;
            }
        }, ISysEventListener.SysEventType.onActivityResult);
        try {
            this.dialog.show();
            this.dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    try {
                        if (X5WebJsEvent.this.mUploadMessage21Level != null) {
                            X5WebJsEvent.this.mUploadMessage21Level.onReceiveValue(null);
                        } else if (X5WebJsEvent.this.mUploadMessage != null) {
                            X5WebJsEvent.this.mUploadMessage.onReceiveValue(null);
                        }
                    } catch (Exception unused) {
                    }
                }
            });
        } catch (Exception unused) {
            Logger.e("openFileChooserLogic Exception");
        }
    }

    @Override
    public void onProgressChanged(WebView view, int newProgress) {
        AdaWebview adaWebview = this.mAdaWebview;
        if (adaWebview == null) {
            return;
        }
        if (newProgress < 20 && !adaWebview.unReceiveTitle) {
            this.mAdaWebview.unReceiveTitle = true;
        }
        this.mAdaWebview.mProgressIntValue = newProgress;
        this.mAdaWebview.dispatchWebviewStateEvent(3, Integer.valueOf(newProgress));
        this.mAdaWebview.mFrameView.dispatchFrameViewEvents(AbsoluteConst.EVENTS_PROGRESS_CHANGED, Integer.valueOf(newProgress));
        super.onProgressChanged(view, newProgress);
    }

    public void releaseDefaultVideoPoster() {
        Bitmap bitmap = this.mDefaultVideoPoster;
        if (bitmap != null) {
            bitmap.recycle();
            this.mDefaultVideoPoster = null;
        }
    }

    @Override
    public Bitmap getDefaultVideoPoster() {
        return super.getDefaultVideoPoster();
    }

    @Override
    public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
        handleConsoleMessage(consoleMessage);
        return true;
    }

    private void handleConsoleMessage(ConsoleMessage consoleMessage) {
        if (this.mAdaWebview == null) {
            return;
        }
        String message = consoleMessage.message();
        if (isFilterConsoleMessage(message)) {
            return;
        }
        int lineNumber = consoleMessage.lineNumber();
        String sourceId = consoleMessage.sourceId();
        String name = consoleMessage.messageLevel().name();
        ConsoleMessage.MessageLevel messageLevel = consoleMessage.messageLevel();
        if (PdrUtil.isEmpty(sourceId)) {
            AppConsoleLogUtil.DCLog(message, name);
        } else {
            try {
                sourceId = this.mAdaWebview.getDCWebView().convertRelPath(sourceId);
            } catch (Exception unused) {
            }
            message = message + " at " + sourceId + ":" + lineNumber;
            AppConsoleLogUtil.DCLog(message, name);
        }
        JSONObject createJSONObject = JSONUtil.createJSONObject(AppRuntime.getUniStatistics());
        boolean z = false;
        if (createJSONObject != null) {
            String string = JSONUtil.getString(createJSONObject, "version");
            boolean z2 = JSONUtil.getBoolean(createJSONObject, "enable");
            if (PdrUtil.isEquals(ExifInterface.GPS_MEASUREMENT_2D, string) && z2) {
                z = true;
            }
        }
        if (z && this.rptJsErr && messageLevel == ConsoleMessage.MessageLevel.ERROR && this.mAdaWebview.obtainApp() != null && !BaseInfo.isBase(this.mAdaWebview.getContext()) && this.mAdaWebview.obtainApp().isUniApp()) {
            JSONObject jSONObject = this.mAdaWebview.mFrameView.obtainFrameOptions().mUniPageUrl;
            String url = this.mAdaWebview.getDCWebView().getUrl();
            if (jSONObject != null && jSONObject.has(AbsoluteConst.XML_PATH)) {
                url = jSONObject.optString(AbsoluteConst.XML_PATH);
                if (jSONObject.has("query")) {
                    String optString = jSONObject.optString("query");
                    if (!TextUtils.isEmpty(optString)) {
                        url = url + "?" + optString;
                    }
                }
            }
            UEH.commitUncatchException(this.mAdaWebview.getContext(), url, message, 2);
        }
    }

    private boolean isFilterConsoleMessage(String message) {
        return !PdrUtil.isEmpty(message) && (message.contains("viewport-fit") || message.contains("Ignored attempt to cancel a touchend event with cancelable=false"));
    }

    @Override
    public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
        Logger.i(TAG, "onExceededDatabaseQuota url=" + url);
        quotaUpdater.updateQuota(estimatedSize * 2);
    }

    @Override
    public void onReachedMaxAppCacheSize(long requiredStorage, long quota, WebStorage.QuotaUpdater quotaUpdater) {
        Logger.i(TAG, "onReachedMaxAppCacheSize");
        super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
    }

    @Override
    public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissionsCallback callback) {
        if (this.mAdaWebview == null) {
            return;
        }
        Logger.i(TAG, "onGeolocationPermissionsShowPrompt origin=" + origin);
        IApp obtainApp = this.mAdaWebview.obtainFrameView().obtainApp();
        if (obtainApp != null) {
            PermissionUtil.usePermission(this.mAdaWebview.getActivity(), "webview-x5", PermissionUtil.PMS_LOCATION, 2, new PermissionUtil.StreamPermissionRequest(obtainApp) {
                @Override
                public void onGranted(String streamPerName) {
                    callback.invoke(origin, true, false);
                }

                @Override
                public void onDenied(String streamPerName) {
                    callback.invoke(origin, false, false);
                }
            });
        }
    }

    @Override
    public void onGeolocationPermissionsHidePrompt() {
        Logger.i(TAG, "onGeolocationPermissionsHidePrompt");
        super.onGeolocationPermissionsHidePrompt();
    }

    @Override
    public void onRequestFocus(WebView view) {
        Logger.i(TAG, "onRequestFocus");
        super.onRequestFocus(view);
    }

    @Override
    public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) {
        Logger.d("super.onReceivedTouchIconUrl(view, url, precomposed");
        super.onReceivedTouchIconUrl(view, url, precomposed);
    }

    @Override
    public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
        return super.onJsBeforeUnload(view, url, message, result);
    }

    @Override
    public void onReceivedTitle(WebView view, String title) {
        AdaWebview adaWebview = this.mAdaWebview;
        if (adaWebview == null) {
            return;
        }
        adaWebview.unReceiveTitle = false;
        this.mAdaWebview.dispatchWebviewStateEvent(4, title);
        this.mAdaWebview.mFrameView.dispatchFrameViewEvents(AbsoluteConst.EVENTS_TITLE_UPDATE, title);
        this.mAdaWebview.getDCWebView().setPageTitle(title);
        Logger.i(TAG, "onReceivedTitle title=" + title);
        this.mAdaWebview.mLoadCompleted = true;
        updateTitleNViewTitle(title);
        initUniLoadUrl();
        super.onReceivedTitle(view, title);
    }

    private void initUniLoadUrl() {
        if (this.mAdaWebview.isDisposed() || this.mAdaWebview.obtainApp() == null || !BaseInfo.isUniAppAppid(this.mAdaWebview.obtainApp()) || BaseInfo.isWeexUniJs(this.mAdaWebview.obtainApp())) {
        }
    }

    private void updateTitleNViewTitle(String webViewTitle) {
        JSONObject jSONObject = this.mAdaWebview.mFrameView.obtainFrameOptions().titleNView;
        if (jSONObject != null) {
            Object obj = null;
            try {
                if (jSONObject.has("titleText")) {
                    obj = jSONObject.get("titleText");
                } else if (jSONObject.has("titletext")) {
                    obj = jSONObject.get("titletext");
                }
                if (obj == null || !(obj instanceof String)) {
                    String optString = jSONObject.optString("titleColor");
                    if (TextUtils.isEmpty(optString)) {
                        optString = jSONObject.optString("titlecolor");
                    }
                    String optString2 = jSONObject.optString("titleSize");
                    if (TextUtils.isEmpty(optString2)) {
                        optString2 = jSONObject.optString("titlesize");
                    }
                    String str = optString2;
                    String optString3 = jSONObject.optString("titleOverflow");
                    String optString4 = jSONObject.optString("titleIcon");
                    String optString5 = jSONObject.optString("titleIconRadius");
                    String optString6 = jSONObject.optString("subtitleText");
                    String optString7 = jSONObject.optString("subtitleColor");
                    String optString8 = jSONObject.optString("subtitleSize");
                    String optString9 = jSONObject.optString("subtitleOverflow");
                    String optString10 = jSONObject.optString("titleIconWidth");
                    if (TextUtils.isEmpty(webViewTitle) || TextUtils.isEmpty(optString) || TextUtils.isEmpty(str)) {
                        return;
                    }
                    Object titleNView = TitleNViewUtil.getTitleNView(this.mAdaWebview.mFrameView.obtainWindowMgr(), this.mAdaWebview.mFrameView.obtainWebView(), this.mAdaWebview.mFrameView, TitleNViewUtil.getTitleNViewId(this.mAdaWebview.obtainFrameView()));
                    if (titleNView instanceof ITitleNView) {
                        ITitleNView iTitleNView = (ITitleNView) titleNView;
                        if ("transparent".equals(jSONObject.optString("type")) && !TextUtils.isEmpty(optString) && Color.alpha(iTitleNView.getTitleColor()) == 0) {
                            optString = TitleNViewUtil.changeColorAlpha(optString, 0.0f);
                        }
                        TitleNViewUtil.drawTitle(this.mAdaWebview.mFrameView, iTitleNView, webViewTitle, optString, str, optString3, jSONObject.optString("titleAlign"), optString4, optString5, optString6, optString7, optString8, optString9, optString10);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    class DialogListener implements DialogInterface.OnClickListener {
        JsResult mResult = null;

        DialogListener() {
        }

        @Override
        public void onClick(DialogInterface dialog, int which) {
            this.mResult.cancel();
        }
    }
}