Wallkin v1.86859532693版本的 MD5 值为:c3099a56aae2c3706b2239994117cc3a

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


package net.dinglisch.android.taskerm;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.LinearLayout;
import net.danlew.android.joda.R;
public class WebChromeClientCommon extends WebChromeClient {
    private Handler f11950a;
    private Dialog f11951b;
    private String f11952c;
    private Context f11953d;

    public enum a {
        DEBUG,
        ERROR,
        LOG,
        TIP,
        WARNING
    }

    public WebChromeClientCommon() {
        this.f11950a = null;
        this.f11951b = null;
        this.f11952c = null;
        this.f11953d = null;
    }

    public WebChromeClientCommon(Context context) {
        this.f11950a = null;
        this.f11951b = null;
        this.f11952c = null;
        this.f11953d = null;
        this.f11953d = context;
    }

    public void setElementName(String str) {
        this.f11952c = str;
    }

    public void setHandler(Handler handler) {
        this.f11950a = handler;
    }

    public void destroy() {
        destroyDialog();
        this.f11953d = null;
    }

    public void destroyDialog() {
        if (this.f11951b != null) {
            this.f11951b.cancel();
            this.f11951b = null;
        }
    }

    @Override
    public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
        return dialogAux(str, str2, false, R.string.dt_alert, null, jsResult);
    }

    @Override
    public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
        return dialogAux(str, str2, true, R.string.dt_alert, str3, jsPromptResult);
    }

    @Override
    public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
        return dialogAux(str, str2, true, R.string.dt_confirm, null, jsResult);
    }

    private boolean dialogAux(String str, String str2, boolean z, int i, String str3, final JsResult jsResult) {
        try {
            if (this.f11953d == null) {
                bo.c("WCCC", "dialogAux: no context");
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(this.f11953d);
                final EditText editText = null;
                if (str3 != null) {
                    LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this.f11953d).inflate(R.layout.js_prompt, (ViewGroup) null);
                    editText = (EditText) linearLayout.findViewById(R.id.value);
                    editText.setText(str3);
                    builder.setView(linearLayout);
                } else {
                    builder.setTitle(urlToTitle(str, ct.a(this.f11953d, i, new Object[0])));
                }
                builder.setCancelable(true);
                builder.setPositiveButton(ct.a(this.f11953d, (int) R.string.button_label_ok, new Object[0]), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i2) {
                        if (editText == null) {
                            WebChromeClientCommon.this.doConfirm(dialogInterface, jsResult);
                        } else {
                            WebChromeClientCommon.this.doConfirm(dialogInterface, jsResult, editText.getText().toString());
                        }
                    }
                });
                builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialogInterface) {
                        WebChromeClientCommon.this.doCancel(dialogInterface, jsResult);
                    }
                });
                if (z) {
                    builder.setNegativeButton(ct.a(this.f11953d, (int) R.string.button_label_cancel, new Object[0]), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i2) {
                            WebChromeClientCommon.this.doNegative(dialogInterface, jsResult);
                        }
                    });
                }
                builder.setMessage(str2);
                this.f11951b = builder.create();
                this.f11951b.show();
            }
            return true;
        } catch (Exception e2) {
            bo.a("WCCC", "dialogAux", e2);
            return false;
        }
    }

    public void doNegative(DialogInterface dialogInterface, JsResult jsResult) {
        dialogInterface.dismiss();
        jsResult.cancel();
        this.f11951b = null;
    }

    public void doCancel(DialogInterface dialogInterface, JsResult jsResult) {
        dialogInterface.cancel();
        jsResult.cancel();
        this.f11951b = null;
    }

    public void doConfirm(DialogInterface dialogInterface, JsResult jsResult) {
        dialogInterface.dismiss();
        jsResult.confirm();
        this.f11951b = null;
    }

    public void doConfirm(DialogInterface dialogInterface, JsResult jsResult, String str) {
        dialogInterface.dismiss();
        ((JsPromptResult) jsResult).confirm(str);
        this.f11951b = null;
    }

    private String urlToTitle(String str, String str2) {
        return ("about:blank".equals(str) || "file:".equals(str) || "file:///".equals(str)) ? this.f11952c != null ? this.f11952c : str2 : str;
    }

    @Override
    public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
        return onConsoleMessage(a.valueOf(consoleMessage.messageLevel().toString()), consoleMessage.message(), consoleMessage.lineNumber());
    }

    public boolean onConsoleMessage(a aVar, String str, int i) {
        if (this.f11950a != null) {
            Message obtainMessage = this.f11950a.obtainMessage();
            obtainMessage.what = 1;
            Bundle bundle = new Bundle();
            bundle.putString("m", str);
            bundle.putInt("l", i);
            bundle.putString("r", aVar.toString());
            obtainMessage.setData(bundle);
            this.f11950a.sendMessage(obtainMessage);
            return true;
        }
        return false;
    }
}