com.tencent.smtt.sdk.ValueCallback Java Examples

The following examples show how to use com.tencent.smtt.sdk.ValueCallback. 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: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
public void linkBridge() {
    if (messagingEnabled) {
        if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // See isNative in lodash
            String testPostMessageNative = "String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
            evaluateJavascript(testPostMessageNative, new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String value) {
                    if (value.equals("true")) {
                        FLog.w(ReactConstants.TAG, "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
                    }
                }
            });
        }

        loadUrl("javascript:(" +
                "window.originalPostMessage = window.postMessage," +
                "window.postMessage = function(data) {" +
                BRIDGE_NAME + ".postMessage(String(data));" +
                "}" +
                ")");
    }
}
 
Example #2
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
private void createAndOpenCommonFileLoader(ValueCallback valueCallback) {
    Activity mActivity = this.mActivityWeakReference.get();
    if (mActivity == null||mActivity.isFinishing()){
        valueCallback.onReceiveValue(new Object());
        return;
    }
    this.mIFileUploadChooser = new FileUpLoadChooserImpl.Builder()
            .setWebView(this.mWebView)
            .setActivity(mActivity)
            .setUriValueCallback(valueCallback)
            .setFileUploadMsgConfig(mChromeClientMsgCfg.getFileUploadMsgConfig())
            .setPermissionInterceptor(this.mPermissionInterceptor)
            .build();
    this.mIFileUploadChooser.openFileChooser();

}
 
Example #3
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
private void openFileChooserAboveL(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {


        Activity mActivity = this.mActivityWeakReference.get();
        if (mActivity == null||mActivity.isFinishing()){
            filePathCallback.onReceiveValue(new Uri[]{});
            return;
        }
        IFileUploadChooser mIFileUploadChooser = this.mIFileUploadChooser;
        this.mIFileUploadChooser = mIFileUploadChooser = new FileUpLoadChooserImpl.Builder()
                .setWebView(webView)
                .setActivity(mActivity)
                .setUriValueCallbacks(filePathCallback)
                .setFileChooserParams(fileChooserParams)
                .setFileUploadMsgConfig(mChromeClientMsgCfg.getFileUploadMsgConfig())
                .setPermissionInterceptor(this.mPermissionInterceptor)
                .build();
        mIFileUploadChooser.openFileChooser();

    }
 
Example #4
Source File: AgentWebX5Config.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
public static void removeSessionCookies(ValueCallback<Boolean> callback) {

        if (callback == null)
            callback = getDefaultIgnoreCallback();
        if (CookieManager.getInstance() == null) {
            callback.onReceiveValue(new Boolean(false));
            return;
        }
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            CookieManager.getInstance().removeSessionCookie();
            toSyncCookies();
            callback.onReceiveValue(new Boolean(true));
            return;
        }
        CookieManager.getInstance().removeSessionCookies(callback);
        toSyncCookies();

    }
 
Example #5
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WebViewSdkCompat.ValueCallback<Uri> getCompatCallback(final ValueCallback<Uri> uploadMsg){
    return new WebViewSdkCompat.ValueCallback<Uri>() {
        @Override
        public void onReceiveValue(Uri uri) {
            uploadMsg.onReceiveValue(uri);
        }
    };
}
 
Example #6
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 打开文件夹
 * @param uploadMsg                         msg
 */
private void openFileChooserImpl(ValueCallback<Uri> uploadMsg) {
    if (context!=null && context instanceof Activity){
        Activity activity = (Activity) context;
        mUploadMessage = uploadMsg;
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.addCategory(Intent.CATEGORY_OPENABLE);
        i.setType("image/*");
        activity.startActivityForResult(
                Intent.createChooser(i, "文件选择"), FILE_CHOOSER_RESULT_CODE);
    }
}
 
Example #7
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 5 votes vote down vote up
/**
 * 打开文件夹,Android5.0以上
 * @param uploadMsg                         msg
 */
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    if (context!=null && context instanceof Activity){
        Activity activity = (Activity) context;
        mUploadMessageForAndroid5 = uploadMsg;
        Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
        contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
        contentSelectionIntent.setType("image/*");
        Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
        chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
        chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");
        activity.startActivityForResult(chooserIntent, FILE_CHOOSER_RESULT_CODE_5);
    }
}
 
Example #8
Source File: FileUpLoadChooserImpl.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public Builder setUriValueCallbacks(ValueCallback<Uri[]> uriValueCallbacks) {
    mUriValueCallbacks = uriValueCallbacks;
    isL = true;
    mUriValueCallback = null;
    mJsChannelCallback = null;
    jsChannel = false;
    return this;
}
 
Example #9
Source File: FileUpLoadChooserImpl.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public Builder setUriValueCallback(ValueCallback<Uri> uriValueCallback) {
    mUriValueCallback = uriValueCallback;
    isL = false;
    jsChannel = false;
    mUriValueCallbacks = null;
    mJsChannelCallback = null;
    return this;
}
 
Example #10
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
    Log.i(TAG, "openFileChooser>3.0");

    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "openFileChooser", ChromePath + ".openFileChooser", ValueCallback.class, String.class)) {
        super.openFileChooser(valueCallback, acceptType);
        return;
    }
    createAndOpenCommonFileLoader(valueCallback);
}
 
Example #11
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> valueCallback) {
    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "openFileChooser", ChromePath + ".openFileChooser", ValueCallback.class)) {
        super.openFileChooser(valueCallback);
        return;
    }
    Log.i(TAG, "openFileChooser<3.0");
    createAndOpenCommonFileLoader(valueCallback);
}
 
Example #12
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) {
    /*believe me , i never want to do this */
    LogUtils.i(TAG, "openFileChooser>=4.1");
    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "openFileChooser", ChromePath + ".openFileChooser", ValueCallback.class, String.class, String.class)) {
        super.openFileChooser(uploadFile, acceptType, capture);
        return;
    }
    createAndOpenCommonFileLoader(uploadFile);
}
 
Example #13
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
    LogUtils.i(TAG, "openFileChooser>=5.0");
    if (AgentWebX5Utils.isOverriedMethod(mWebChromeClient, "onShowFileChooser", ChromePath + ".onShowFileChooser", WebView.class, ValueCallback.class, WebChromeClient.FileChooserParams.class)) {

        return super.onShowFileChooser(webView, filePathCallback, fileChooserParams);
    }
    openFileChooserAboveL(webView, filePathCallback, fileChooserParams);
    return true;
}
 
Example #14
Source File: AgentWebX5Config.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public static void removeAllCookies(@Nullable ValueCallback<Boolean> callback) {

        if (callback == null)
            callback = getDefaultIgnoreCallback();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            CookieManager.getInstance().removeAllCookie();
            toSyncCookies();
            callback.onReceiveValue(!CookieManager.getInstance().hasCookies());
            return;
        }
        CookieManager.getInstance().removeAllCookies(callback);
        toSyncCookies();
    }
 
Example #15
Source File: AgentWebX5Config.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
private static ValueCallback<Boolean> getDefaultIgnoreCallback() {

        return new ValueCallback<Boolean>() {
            @Override
            public void onReceiveValue(Boolean ignore) {
                LogUtils.i("Info", "removeExpiredCookies:" + ignore);
            }
        };
    }
 
Example #16
Source File: MyX5WebChromeClient.java    From ByWebView with Apache License 2.0 5 votes vote down vote up
private void openFileChooserImpl(ValueCallback<Uri> uploadMsg) {
    mUploadMessage = uploadMsg;
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/*");
    mIWebPageView.startFileChooserForResult(Intent.createChooser(intent, "文件选择"), FILECHOOSER_RESULTCODE);
}
 
Example #17
Source File: MyX5WebChromeClient.java    From ByWebView with Apache License 2.0 5 votes vote down vote up
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMessageForAndroid5 = uploadMsg;
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("image/*");

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");

    mIWebPageView.startFileChooserForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5);
}
 
Example #18
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
                                 FileChooserParams fileChooserParams) {
    if (this.mRealWebChromeClient != null)
        return this.mRealWebChromeClient.onShowFileChooser(webView, filePathCallback, fileChooserParams);
    return super.onShowFileChooser(webView,filePathCallback,fileChooserParams);
}
 
Example #19
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public void getVisitedHistory(ValueCallback<String[]> callback) {
    if (this.mRealWebChromeClient != null){
        this.mRealWebChromeClient.getVisitedHistory(callback);
        return ;
    }
    super.getVisitedHistory(callback);
}
 
Example #20
Source File: x5_MainActivity.java    From stynico with MIT License 5 votes vote down vote up
@Override
      public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
{
          uploadMessageAboveL = filePathCallback;
          openImageChooserActivity();
          return true;
      }
 
Example #21
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    ((EBrowserActivity) mContext).setmUploadMessage(getCompatCallback(uploadMsg));
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    ((EBrowserActivity) mContext).startActivityForResult(Intent.createChooser(i, "File Chooser"),
            EBrowserActivity.FILECHOOSER_RESULTCODE);
}
 
Example #22
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
    ((EBrowserActivity) mContext).setmUploadMessage(getCompatCallback(uploadMsg));
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    ((EBrowserActivity) mContext).startActivityForResult(Intent.createChooser(i, "File Chooser"),
            EBrowserActivity.FILECHOOSER_RESULTCODE);
}
 
Example #23
Source File: CBrowserMainFrame.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
    ((EBrowserActivity) mContext).setmUploadMessage(getCompatCallback(uploadMsg));
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    ((EBrowserActivity) mContext).startActivityForResult(Intent.createChooser(i, "File Browser"),
            EBrowserActivity.FILECHOOSER_RESULTCODE);
}
 
Example #24
Source File: X5WebChromeClient.java    From YCWebView with Apache License 2.0 4 votes vote down vote up
/**
 * 获得所有访问历史项目的列表,用于链接着色。
 * @param valueCallback                     callback
 */
@Override
public void getVisitedHistory(ValueCallback<String[]> valueCallback) {
    super.getVisitedHistory(valueCallback);
}
 
Example #25
Source File: X5WebChromeClient.java    From cordova-plugin-x5-tbs with Apache License 2.0 4 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
  this.openFileChooser(uploadMsg, acceptType, null);
}
 
Example #26
Source File: X5WebChromeClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 4 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    this.openFileChooser(uploadMsg, "*/*");
}
 
Example #27
Source File: X5WebChromeClient.java    From cordova-plugin-x5engine-webview with Apache License 2.0 4 votes vote down vote up
public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType ) {
    this.openFileChooser(uploadMsg, acceptType, null);
}
 
Example #28
Source File: WebChromeClientListener.java    From JsBridge with MIT License 4 votes vote down vote up
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
    return false;
}
 
Example #29
Source File: MyX5WebChromeClient.java    From ByWebView with Apache License 2.0 4 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
    openFileChooserImpl(uploadMsg);
}
 
Example #30
Source File: MyX5WebChromeClient.java    From ByWebView with Apache License 2.0 4 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    openFileChooserImpl(uploadMsg);
}