com.tencent.smtt.export.external.interfaces.JsPromptResult Java Examples

The following examples show how to use com.tencent.smtt.export.external.interfaces.JsPromptResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
@Override
    public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {


        try {
            if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "onJsPrompt", "public boolean " + ChromePath + ".onJsPrompt", WebView.class, String.class, String.class, String.class, JsPromptResult.class)) {

                return super.onJsPrompt(view, url, message, defaultValue, result);
            }
            if (AgentWebX5Config.WEBVIEW_TYPE == AgentWebX5Config.WEBVIEW_AGENTWEB_SAFE_TYPE && mChromeClientCallbackManager != null && mChromeClientCallbackManager.getAgentWebCompatInterface() != null) {

                LogUtils.i(TAG, "mChromeClientCallbackManager.getAgentWebCompatInterface():" + mChromeClientCallbackManager.getAgentWebCompatInterface());
                if (mChromeClientCallbackManager.getAgentWebCompatInterface().onJsPrompt(view, url, message, defaultValue, result))
                    return true;
            }
            showJsPrompt(message, result, defaultValue);
        } catch (Exception e) {
//            e.printStackTrace();
        }

        return true;
    }
 
Example #2
Source File: X5WebChromeClient.java    From x5webview-cordova-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 *
 * Since we are hacking prompts for our own purposes, we should not be using them for
 * this purpose, perhaps we should hack console.log to do this instead!
 */
@Override
public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
    // Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.
    String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);
    if (handledRet != null) {
        result.confirm(handledRet);
    } else {
        dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
            @Override
            public void gotResult(boolean success, String value) {
                if (success) {
                    result.confirm(value);
                } else {
                    result.cancel();
                }
            }
        });
    }
    return true;
}
 
Example #3
Source File: X5WebChromeClient.java    From cordova-plugin-x5-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 *
 * Since we are hacking prompts for our own purposes, we should not be using them for
 * this purpose, perhaps we should hack console.log to do this instead!
 */
public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
    // Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.
    String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);
    if (handledRet != null) {
        result.confirm(handledRet);
    } else {
        dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
            @Override
            public void gotResult(boolean success, String value) {
                if (success) {
                    result.confirm(value);
                } else {
                    result.cancel();
                }
            }
        });
    }
    return true;
}
 
Example #4
Source File: X5WebChromeClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 * <p>
 * Since we are hacking prompts for our own purposes, we should not be using them for
 * this purpose, perhaps we should hack console.log to do this instead!
 */
@Override
public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
  // Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.
  String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);
  if (handledRet != null) {
    result.confirm(handledRet);
  } else {
    dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
      @Override
      public void gotResult(boolean success, String value) {
        if (success) {
          result.confirm(value);
        } else {
          result.cancel();
        }
      }
    });
  }
  return true;
}
 
Example #5
Source File: X5WebChromeClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 *
 * Since we are hacking prompts for our own purposes, we should not be using them for
 * this purpose, perhaps we should hack console.log to do this instead!
 */
@Override
public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
    // Unlike the @JavascriptInterface bridge, this method is always called on the UI thread.
    String handledRet = parentEngine.bridge.promptOnJsPrompt(origin, message, defaultValue);
    if (handledRet != null) {
        result.confirm(handledRet);
    } else {
        dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
            @Override
            public void gotResult(boolean success, String value) {
                if (success) {
                    result.confirm(value);
                } else {
                    result.cancel();
                }
            }
        });
    }
    return true;
}
 
Example #6
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 处理prompt弹出框
 * @param webView                           view
 * @param url                               url链接
 * @param message                           参数message:代表prompt()的内容(不是url)
 * @param defaultValue                      参数result:代表输入框的返回值
 * @param jsPromptResult                    jsPromptResult
 * @return
 */
@Override
public boolean onJsPrompt(WebView webView, String url, String message,
                          String defaultValue, JsPromptResult jsPromptResult) {
    //根据协议的参数,判断是否是所需要的url
    //假定传入进来的 message = "js://openActivity?arg1=111&arg2=222",代表需要打开本地页面,并且带入相应的参数
    //同时也是约定好的需要拦截的
    /*Uri uri = Uri.parse(message);
    String scheme = uri.getScheme();
    if ("js".equals(scheme)) {
        if (uri.getAuthority().equals("openActivity")) {
            HashMap<String, String> params = new HashMap<>();
            Set<String> collection = uri.getQueryParameterNames();
            for (String name : collection) {
                params.put(name, uri.getQueryParameter(name));
            }
            Intent intent = new Intent(webView.getContext(), MainActivity.class);
            intent.putExtra("params", params);
            webView.getContext().startActivity(intent);
            //代表应用内部处理完成
            jsPromptResult.confirm("success");
        } else if("demo".equals(uri.getAuthority()));{
            //代表应用内部处理完成
            jsPromptResult.confirm("js调用了Android的方法成功啦");
            return true;
        }
        return true;
    }*/
    return super.onJsPrompt(webView, url, message, defaultValue, jsPromptResult);
}
 
Example #7
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void appCanJsParse(final JsPromptResult result, WebView view, String parseStr) {
    try {
        if (!(view instanceof EBrowserView)) {
            return;
        }
        EBrowserView browserView = (EBrowserView) view;
        final EUExManager uexManager = browserView.getEUExManager();
        if (uexManager != null) {
            result.confirm(uexManager.dispatch(parseStr));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #8
Source File: MyTestActivity.java    From AndroidFrame with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onJsPrompt(WebView webView, String s, String s1, String s2, JsPromptResult jsPromptResult) {
    //可以在这个回调中与h5交互
    return super.onJsPrompt(webView, s, s1, s2, jsPromptResult);
}
 
Example #9
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public boolean onJsPrompt(WebView view, String url, String message,
                          String defaultValue, JsPromptResult result) {
    if (this.mRealWebChromeClient != null)
        return this.mRealWebChromeClient.onJsPrompt(view, url, message, defaultValue, result);
    return super.onJsPrompt(view,url,message,defaultValue,result);
}
 
Example #10
Source File: WvWebView.java    From YCWebView with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onJsPrompt(WebView view, String url, final String message,
                          String defaultValue, final JsPromptResult result) {
    if(Build.VERSION.SDK_INT<= Build.VERSION_CODES.JELLY_BEAN){
        String prefix="_wvjbxx";
        if(message.equals(prefix)){
            Message msg = mainThreadHandler.obtainMessage(HANDLE_MESSAGE, defaultValue);
            mainThreadHandler.sendMessage(msg);
        }
        return true;
    }
    if(!alertBoxBlock){
        result.confirm();
    }
    final EditText editText = new EditText(getContext());
    editText.setText(defaultValue);
    if (defaultValue != null) {
        editText.setSelection(defaultValue.length());
    }
    float dpi = getContext().getResources().getDisplayMetrics().density;
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if(alertBoxBlock) {
                if (which == Dialog.BUTTON_POSITIVE) {
                    result.confirm(editText.getText().toString());
                } else {
                    result.cancel();
                }
            }
        }
    };
    new AlertDialog.Builder(getContext())
            .setTitle(message)
            .setView(editText)
            .setCancelable(false)
            .setPositiveButton(android.R.string.ok, listener)
            .setNegativeButton(android.R.string.cancel, listener)
            .show();
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int t = (int) (dpi * 16);
    layoutParams.setMargins(t, 0, t, 0);
    layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
    editText.setLayoutParams(layoutParams);
    int padding = (int) (15 * dpi);
    editText.setPadding(padding - (int) (5 * dpi), padding, padding, padding);
    return true;
}
 
Example #11
Source File: WebChromeClientListener.java    From JsBridge with MIT License 4 votes vote down vote up
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
    return false;
}
 
Example #12
Source File: ChromeClientCallbackManager.java    From AgentWebX5 with Apache License 2.0 votes vote down vote up
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result); 
Example #13
Source File: OnWebChromeClientListener.java    From JsBridge with MIT License votes vote down vote up
boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result);