com.tencent.smtt.sdk.WebChromeClient Java Examples

The following examples show how to use com.tencent.smtt.sdk.WebChromeClient. 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
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    X5WeView webView = new X5WeView(reactContext);

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
            callback.invoke(origin, true, false);
        }
    });
    reactContext.addLifecycleEventListener(webView);
    mWebViewConfig.configWebView(webView);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);

    // Fixes broken full-screen modals/galleries due to body height being 0.
    webView.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT));

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return webView;
}
 
Example #2
Source File: DefaultChromeClient.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
DefaultChromeClient(Activity activity,
                    IndicatorController indicatorController,
                    WebChromeClient chromeClient,
                    ChromeClientCallbackManager chromeClientCallbackManager,
                    @Nullable IVideo iVideo,
                    DefaultMsgConfig.ChromeClientMsgCfg chromeClientMsgCfg, PermissionInterceptor permissionInterceptor, WebView webView) {
    super( chromeClient);
    this.mIndicatorController=indicatorController;
    isWrapper = chromeClient != null ? true : false;
    this.mWebChromeClient = chromeClient;
    mActivityWeakReference = new WeakReference<Activity>(activity);
    this.mChromeClientCallbackManager = chromeClientCallbackManager;
    this.mIVideo = iVideo;
    this.mChromeClientMsgCfg = chromeClientMsgCfg;
    this.mPermissionInterceptor = permissionInterceptor;
    this.mWebView = webView;
}
 
Example #3
Source File: AgentWebX5.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
private WebChromeClient getChromeClient() {
    IndicatorController mIndicatorController = (this.mIndicatorController == null) ? IndicatorHandler.getInstance().inJectProgressView(mWebCreator.offer()) : this.mIndicatorController;

    DefaultChromeClient mDefaultChromeClient =
            new DefaultChromeClient(this.mActivity, this.mIndicatorController = mIndicatorController, this.mWebChromeClient, this.mChromeClientCallbackManager, this.mIVideo = getIVideo(), mDefaultMsgConfig.getChromeClientMsgCfg(), this.mPermissionInterceptor, mWebCreator.get());

    LogUtils.i(TAG, "WebChromeClient:" + this.mWebChromeClient);
    MiddleWareWebChromeBase header = this.mMiddleWareWebChromeBaseHeader;
    if (header != null) {
        MiddleWareWebChromeBase tail = header;
        int count = 1;
        MiddleWareWebChromeBase tmp = header;
        while (tmp.next() != null) {
            tail = tmp = tmp.next();
            count++;
        }
        LogUtils.i(TAG, "MiddleWareWebClientBase middleware count:" + count);
        tail.setWebChromeClient(mDefaultChromeClient);
        return this.mTargetChromeClient = header;
    } else {
        return this.mTargetChromeClient = mDefaultChromeClient;
    }
}
 
Example #4
Source File: DetailActivity.java    From KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo with Apache License 2.0 5 votes vote down vote up
private void webViewSetting() {
    /* 设置支持Js,必须设置的,不然网页基本上不能看 */
    mWebView.getSettings().setJavaScriptEnabled(true);
    /* 设置缓存模式,我这里使用的默认,不做多讲解 */
    mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
    /* 设置为true表示支持使用js打开新的窗口 */
    mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    /* 大部分网页需要自己保存一些数据,这个时候就的设置下面这个属性 */
    mWebView.getSettings().setDomStorageEnabled(true);
    /* 设置为使用webview推荐的窗口 */
    mWebView.getSettings().setUseWideViewPort(true);
    /* 设   置网页自适应屏幕大小 ---这个属性应该是跟上面一个属性一起用 */
    mWebView.getSettings().setLoadWithOverviewMode(true);
    /* HTML5的地理位置服务,设置为true,启用地理定位 */
    mWebView.getSettings().setGeolocationEnabled(true);
    /* 设置是否允许webview使用缩放的功能,我这里设为false,不允许 */
    mWebView.getSettings().setBuiltInZoomControls(false);
    /* 提高网页渲染的优先级 */
    mWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    /* 设置显示水平滚动条,就是网页右边的滚动条.我这里设置的不显示 */
    mWebView.setHorizontalScrollBarEnabled(false);
    /* 指定垂直滚动条是否有叠加样式 */
    mWebView.setVerticalScrollbarOverlay(true);
    /* 设置滚动条的样式 */
    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onReceivedTitle(WebView webView, String s) {
            super.onReceivedTitle(webView, s);
            if (s.length() > 15) {
                s = s.substring(0, 15) + "...";
            }
            collapsingtoolbarlayout.setTitle(s);
        }
    });
}
 
Example #5
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 #6
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
private void commonRefect(WebChromeClient o, String mothed, Object[] os, Class... clazzs) {
        try {
            if (o == null)
                return;
            Class<?> clazz = o.getClass();
            Method mMethod = clazz.getMethod(mothed, clazzs);
            mMethod.invoke(o, os);
        } catch (Exception igore) {
//            igore.printStackTrace();
        }

    }
 
Example #7
Source File: VideoPlayActivity.java    From TBSVideoPlay with Apache License 2.0 5 votes vote down vote up
/**
 * 使用自定义webview播放视频
 * @param vedioUrl 视频地址
 */
private void startPlay(String vedioUrl) {
    x5webView.loadUrl(vedioUrl);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    x5webView.getView().setOverScrollMode(View.OVER_SCROLL_ALWAYS);
    x5webView.setWebChromeClient(new WebChromeClient());
}
 
Example #8
Source File: X5WebChromeClient.java    From cordova-plugin-x5-webview with Apache License 2.0 5 votes vote down vote up
public void onShowCustomView(View view,final IX5WebChromeClient.CustomViewCallback callback) {
    // IX5WebChromeClient.CustomViewCallback casts to webkit.WebChromeClient.CustomViewCallback
    // By Jeremy on 2017/5/18.
    parentEngine.getCordovaWebView().showCustomView(view, new android.webkit.WebChromeClient.CustomViewCallback() {
        @Override
        public void onCustomViewHidden() {
            callback.onCustomViewHidden();
        }
    });
}
 
Example #9
Source File: X5WebViewDemo.java    From ans-android-sdk with GNU General Public License v3.0 5 votes vote down vote up
private void webView() {
        x5WebView = (WebView) findViewById(R.id.forum_context);
        x5WebView.loadUrl("http://uc.analysys.cn/huaxiang/hybrid-4.3.0.10/");
        x5WebView.getSettings().setJavaScriptEnabled(true);
        x5WebView.setWebChromeClient(new WebChromeClient());
        x5WebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
//        x5WebView.setWebViewClient(new OldWebviewClient());
        // 设置UserAgent
        AnalysysAgent.setHybridModel(mContext, x5WebView);
        // 设置WebViewClient
        x5WebView.setWebViewClient(new MyWebviewClient());
    }
 
Example #10
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 #11
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 #12
Source File: X5WebView.java    From cordova-plugin-x5engine-webview with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebChromeClient(WebChromeClient client) {
    chromeClient = (X5WebChromeClient)client;
    super.setWebChromeClient(client);
}
 
Example #13
Source File: X5WebView.java    From cordova-plugin-x5-tbs with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebChromeClient(WebChromeClient client) {
  chromeClient = (X5WebChromeClient) client;
  super.setWebChromeClient(client);
}
 
Example #14
Source File: X5WebView.java    From cordova-plugin-x5-webview with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebChromeClient(WebChromeClient client) {
    chromeClient = (X5WebChromeClient)client;
    super.setWebChromeClient(client);
}
 
Example #15
Source File: X5WebView.java    From x5webview-cordova-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void setWebChromeClient(WebChromeClient client) {
    chromeClient = (X5WebChromeClient)client;
    super.setWebChromeClient(client);
}
 
Example #16
Source File: FileUpLoadChooserImpl.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public Builder setFileChooserParams(WebChromeClient.FileChooserParams fileChooserParams) {
    mFileChooserParams = fileChooserParams;
    return this;
}
 
Example #17
Source File: MiddleWareWebChromeBase.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
@Override
final void setWebChromeClient(WebChromeClient webChromeClient) {
    super.setWebChromeClient(webChromeClient);
}
 
Example #18
Source File: WebDefaultSettingsManager.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
@Override
public WebListenerManager setWebChromeClient(WebView webview, WebChromeClient webChromeClient) {
    webview.setWebChromeClient(webChromeClient);

    return this;
}
 
Example #19
Source File: MiddleWareWebChromeBase.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public MiddleWareWebChromeBase(WebChromeClient webChromeClient) {
    super(webChromeClient);
}
 
Example #20
Source File: AgentWebX5.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public CommonBuilderForFragment setWebChromeClient(@Nullable WebChromeClient webChromeClient) {
    this.mAgentBuilderFragment.mWebChromeClient = webChromeClient;
    return this;

}
 
Example #21
Source File: AgentWebX5.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public CommonAgentBuilder setWebChromeClient(@Nullable WebChromeClient webChromeClient) {
    this.mAgentBuilder.mWebChromeClient = webChromeClient;
    return this;
}
 
Example #22
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
void setWebChromeClient(WebChromeClient webChromeClient){
    this.mRealWebChromeClient=webChromeClient;
}
 
Example #23
Source File: WebChromeClientWrapper.java    From AgentWebX5 with Apache License 2.0 4 votes vote down vote up
public WebChromeClientWrapper(WebChromeClient realWebChromeClient) {
    this.mRealWebChromeClient = realWebChromeClient;
}
 
Example #24
Source File: x5_MainActivity.java    From styT with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {

    return true;
}
 
Example #25
Source File: WebListenerManager.java    From AgentWebX5 with Apache License 2.0 votes vote down vote up
WebListenerManager setWebChromeClient(WebView webview, WebChromeClient webChromeClient); 
Example #26
Source File: OnWebChromeClientListener.java    From JsBridge with MIT License votes vote down vote up
boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams);