org.xwalk.core.XWalkJavascriptResult Java Examples

The following examples show how to use org.xwalk.core.XWalkJavascriptResult. 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: CornUIClient.java    From Cornowser with MIT License 6 votes vote down vote up
@Override
public boolean onJsPrompt(XWalkView view, String url, String message, String defaultValue, XWalkJavascriptResult result) {
    final XWalkJavascriptResult fResult = result;
    final EditTextDialog d = new EditTextDialog(CornBrowser.getContext(),
            (XquidCompatActivity) CornBrowser.getActivity(),
            message,
            defaultValue);
    d.setOnClickListener(new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            fResult.confirmWithResult(d.getEnteredText());
            dialog.dismiss();
        }
    });
    d.showDialog();


    return true;
}
 
Example #2
Source File: XWalkCordovaUiClient.java    From cordova-crosswalk-engine with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType type, String url,
                                       String message, String defaultValue, XWalkJavascriptResult result) {
    switch (type) {
        case JAVASCRIPT_ALERT:
            return onJsAlert(view, url, message, result);
        case JAVASCRIPT_CONFIRM:
            return onJsConfirm(view, url, message, result);
        case JAVASCRIPT_PROMPT:
            return onJsPrompt(view, url, message, defaultValue, result);
        case JAVASCRIPT_BEFOREUNLOAD:
            // Reuse onJsConfirm to show the dialog.
            return onJsConfirm(view, url, message, result);
        default:
            break;
    }
    assert (false);
    return false;
}
 
Example #3
Source File: XWalkCordovaUiClient.java    From cordova-crosswalk-engine 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!
 */
public boolean onJsPrompt(XWalkView view, String origin, String message, String defaultValue,
                           final XWalkJavascriptResult 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.confirmWithResult(handledRet);
    } else {
        dialogsHelper.showPrompt(message, defaultValue, new CordovaDialogsHelper.Result() {
            @Override
            public void gotResult(boolean success, String value) {
                if (success) {
                    result.confirmWithResult(value);
                } else {
                    result.cancel();
                }
            }
        });

    }
    return true;
}
 
Example #4
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void appCanJsParse(final XWalkJavascriptResult result, XWalkView view, String parseStr) {
    try {
        if (!(view instanceof EBrowserView)) {
            return;
        }
        EBrowserView browserView = (EBrowserView) view;
        final EUExManager uexManager = browserView.getEUExManager();
        if (uexManager != null) {
            result.confirmWithResult(uexManager.dispatch(parseStr));
        }
    } catch (Exception e) {
        if (BDebug.DEBUG) {
            e.printStackTrace();
        }
    }
}
 
Example #5
Source File: CordovaChromeClient.java    From crosswalk-cordova-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onJavascriptModalDialog(XWalkView view, JavascriptMessageType type, String url,
        String message, String defaultValue, XWalkJavascriptResult result) {
    switch(type) {
        case JAVASCRIPT_ALERT:
            return onJsAlert(view, url, message, result);
        case JAVASCRIPT_CONFIRM:
            return onJsConfirm(view, url, message, result);
        case JAVASCRIPT_PROMPT:
            return onJsPrompt(view, url, message, defaultValue, result);
        case JAVASCRIPT_BEFOREUNLOAD:
            // Reuse onJsConfirm to show the dialog.
            return onJsConfirm(view, url, message, result);
        default:
            break;
    }
    assert(false);
    return false;
}
 
Example #6
Source File: CornUIClient.java    From Cornowser with MIT License 5 votes vote down vote up
@Override
public boolean onJsAlert(XWalkView view, String url, String message, XWalkJavascriptResult result) {
    AlertDialog.Builder b = new AlertDialog.Builder(CornBrowser.getActivity());
    b
            .setCancelable(true)
            .setTitle(view.getTitle())
            .setMessage(message)
            .setPositiveButton(CornBrowser.getContext().getString(R.string.answer_ok), new DismissDialogButton())
            .create()
            .show()
    ;
    result.confirm();
    return true;
}
 
Example #7
Source File: XWalkCordovaUiClient.java    From cordova-crosswalk-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a javascript alert dialog.
 */
public boolean onJsAlert(XWalkView view, String url, String message,
                          final XWalkJavascriptResult result) {
    dialogsHelper.showAlert(message, new CordovaDialogsHelper.Result() {
        @Override
        public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #8
Source File: XWalkCordovaUiClient.java    From cordova-crosswalk-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the client to display a confirm dialog to the user.
 */
public boolean onJsConfirm(XWalkView view, String url, String message,
                            final XWalkJavascriptResult result) {
    dialogsHelper.showConfirm(message, new CordovaDialogsHelper.Result() {
        @Override
        public void gotResult(boolean success, String value) {
            if (success) {
                result.confirm();
            } else {
                result.cancel();
            }
        }
    });
    return true;
}
 
Example #9
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onJavascriptModalDialog(XWalkView view,
                                       JavascriptMessageType type, String url, String message,
                                       String defaultValue, final XWalkJavascriptResult result) {
    if (type == JavascriptMessageType.JAVASCRIPT_PROMPT) {
        return onJsPrompt(view, url, message, defaultValue, result);
    } else if (type == JavascriptMessageType.JAVASCRIPT_ALERT) {
        return onJsAlert(view, url, message, result);
    } else if (type == JavascriptMessageType.JAVASCRIPT_CONFIRM) {
        return onJsConfirm(view, url, message, result);
    } else {
        return true;
    }
}
 
Example #10
Source File: CornUIClient.java    From Cornowser with MIT License 4 votes vote down vote up
@Override
public boolean onJavascriptModalDialog(XWalkView view, XWalkUIClient.JavascriptMessageType type,
                                       String url, String message, String defaultValue, XWalkJavascriptResult result) {
    return super.onJavascriptModalDialog(view, type, url, message, defaultValue, result);
}
 
Example #11
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean onJsAlert(XWalkView view, String url, String message, XWalkJavascriptResult result) {
    return super.onJsAlert(view, url, message, result);
}
 
Example #12
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean onJsConfirm(XWalkView view, String url, String message, XWalkJavascriptResult result) {
    return super.onJsConfirm(view, url, message, result);
}