Search in sources :

Example 96 with WebSettings

use of android.webkit.WebSettings in project aware-client by denzilferreira.

the class About method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.aware_about);
    WebView about_us = (WebView) findViewById(R.id.about_us);
    WebSettings settings = about_us.getSettings();
    settings.setJavaScriptEnabled(true);
    about_us.loadUrl("https://awareframework.com/team/");
}
Also used : WebSettings(android.webkit.WebSettings) WebView(android.webkit.WebView)

Example 97 with WebSettings

use of android.webkit.WebSettings in project SmartCampus by Vegen.

the class ArticleDetailActivity method setupUI.

@Override
protected void setupUI() {
    newsTitle = getIntent().getStringExtra("newsTitle");
    newsUrl = getIntent().getStringExtra("newsUrl");
    setTitle(newsTitle);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    // 设置自适应屏幕,两者合用
    // 将图片调整到适合webview的大小
    webSettings.setUseWideViewPort(true);
    // 缩放至屏幕的大小
    webSettings.setLoadWithOverviewMode(true);
    // 支持自动加载图片
    webSettings.setLoadsImagesAutomatically(true);
    // 设置编码格式
    webSettings.setDefaultTextEncodingName("utf-8");
    webSettings.setSupportZoom(true);
    webSettings.setTextSize(WebSettings.TextSize.LARGEST);
    refreshLayout.setEnableLoadmore(false);
    refreshLayout.startRefresh();
}
Also used : WebSettings(android.webkit.WebSettings)

Example 98 with WebSettings

use of android.webkit.WebSettings in project android-mdm-agent by flyve-mdm.

the class FragmentHelp method onCreateView.

/**
 * Instantiate the user interface View
 * @param inflater inflater the object that can be used to inflate any views in the fragment
 * @param container the parent View the fragment's UI should be attached to
 * @param savedInstanceState this fragment is being re-constructed from a previous saved state
 * @return View the View for the fragment's UI
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_help, container, false);
    WebView wv = v.findViewById(R.id.webview);
    WebSettings settings = wv.getSettings();
    settings.setJavaScriptEnabled(true);
    wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    progressBar = ProgressDialog.show(FragmentHelp.this.getActivity(), getResources().getString(R.string.help), getResources().getString(R.string.loading));
    wv.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Log.i(TAG, "Processing webview url click...");
            view.loadUrl(url);
            return true;
        }

        public void onPageFinished(WebView view, String url) {
            Log.i(TAG, "Finished loading URL: " + url);
            if (progressBar.isShowing()) {
                progressBar.dismiss();
            }
        }

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Log.e(TAG, "Error: " + description);
            Helpers.snack(FragmentHelp.this.getActivity(), description);
        }
    });
    wv.loadUrl(HELP_URL);
    return v;
}
Also used : WebSettings(android.webkit.WebSettings) WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 99 with WebSettings

use of android.webkit.WebSettings in project WeexErosFramework by bmfe.

the class BMWebView method initWebView.

private void initWebView(WebView wv) {
    WebSettings settings = wv.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCacheEnabled(true);
    settings.setUseWideViewPort(true);
    settings.setDomStorageEnabled(true);
    settings.setSupportZoom(false);
    settings.setBuiltInZoomControls(false);
    wv.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            WXLogUtils.v("tag", "onPageOverride " + url);
            return true;
        }

        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            WXLogUtils.v("tag", "onPageStarted " + url);
            if (BMWebView.this.mOnPageListener != null) {
                BMWebView.this.mOnPageListener.onPageStart(url);
            }
        }

        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            WXLogUtils.v("tag", "onPageFinished " + url);
            if (BMWebView.this.mOnPageListener != null) {
                BMWebView.this.mOnPageListener.onPageFinish(url, view.canGoBack(), view.canGoForward());
            }
        }

        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
            super.onReceivedError(view, request, error);
            if (BMWebView.this.mOnErrorListener != null) {
                BMWebView.this.mOnErrorListener.onError("error", "page error");
            }
        }

        public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
            super.onReceivedHttpError(view, request, errorResponse);
            if (BMWebView.this.mOnErrorListener != null) {
                BMWebView.this.mOnErrorListener.onError("error", "http error");
            }
        }

        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            super.onReceivedSslError(view, handler, error);
            if (BMWebView.this.mOnErrorListener != null) {
                BMWebView.this.mOnErrorListener.onError("error", "ssl error");
            }
        }
    });
    wv.setWebChromeClient(new WebChromeClient() {

        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            BMWebView.this.showWebView(newProgress == 100);
            BMWebView.this.showProgressBar(newProgress != 100);
            WXLogUtils.v("tag", "onPageProgressChanged " + newProgress);
        }

        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
            if (BMWebView.this.mOnPageListener != null) {
                BMWebView.this.mOnPageListener.onReceivedTitle(view.getTitle());
            }
        }
    });
}
Also used : SslErrorHandler(android.webkit.SslErrorHandler) Bitmap(android.graphics.Bitmap) WebResourceRequest(android.webkit.WebResourceRequest) WebResourceResponse(android.webkit.WebResourceResponse) WebSettings(android.webkit.WebSettings) SslError(android.net.http.SslError) WebChromeClient(android.webkit.WebChromeClient) WebResourceError(android.webkit.WebResourceError) IWebView(com.taobao.weex.ui.view.IWebView) WebView(android.webkit.WebView) WXWebView(com.taobao.weex.ui.view.WXWebView) WebViewClient(android.webkit.WebViewClient)

Example 100 with WebSettings

use of android.webkit.WebSettings in project WeexErosFramework by bmfe.

the class BMWXWebView method initWebView.

private void initWebView(WebView wv) {
    WebSettings settings = wv.getSettings();
    settings.setAppCacheEnabled(true);
    settings.setUseWideViewPort(true);
    settings.setDomStorageEnabled(true);
    settings.setSupportZoom(false);
    settings.setBuiltInZoomControls(false);
    addWebJavascriptInterface(wv);
    wv.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            WXLogUtils.v("tag", "onPageOverride " + url);
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            WXLogUtils.v("tag", "onPageStarted " + url);
            if (mOnPageListener != null) {
                mOnPageListener.onPageStart(url);
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            WXLogUtils.v("tag", "onPageFinished " + url);
            if (mOnPageListener != null) {
                mOnPageListener.onPageFinish(url, view.canGoBack(), view.canGoForward());
            }
        }

        @Override
        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
            super.onReceivedError(view, request, error);
            if (mOnErrorListener != null) {
                // mOnErrorListener.onError("error", "page error code:" + error.getErrorCode() + ", desc:" + error.getDescription() + ", url:" + request.getUrl());
                mOnErrorListener.onError("error", "page error");
            }
        }

        @Override
        public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
            super.onReceivedHttpError(view, request, errorResponse);
            if (mOnErrorListener != null) {
                mOnErrorListener.onError("error", "http error");
            }
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            super.onReceivedSslError(view, handler, error);
            if (mOnErrorListener != null) {
                mOnErrorListener.onError("error", "ssl error");
            }
        }
    });
    wv.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            showWebView(newProgress == 100);
            showProgressBar(newProgress != 100);
            WXLogUtils.v("tag", "onPageProgressChanged " + newProgress);
        }

        @Override
        public void onReceivedTitle(WebView view, String title) {
            super.onReceivedTitle(view, title);
            if (mOnPageListener != null) {
                mOnPageListener.onReceivedTitle(view.getTitle());
            }
        }

        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            mContentHeight = Integer.parseInt(message);
            mContentHeight = mContentHeight / (WXViewUtils.defaultPixelScaleFactor(getView().getContext()) * 2);
            Map<String, String> params = new HashMap<>();
            params.put("contentHeight", mContentHeight + "");
            if (mWXWeb != null) {
                mWXWeb.fireEvent("bmPageFinish", params);
            }
            result.confirm();
            return true;
        }
    });
}
Also used : SslErrorHandler(android.webkit.SslErrorHandler) WebResourceRequest(android.webkit.WebResourceRequest) SslError(android.net.http.SslError) SuppressLint(android.annotation.SuppressLint) JsResult(android.webkit.JsResult) Bitmap(android.graphics.Bitmap) WebResourceResponse(android.webkit.WebResourceResponse) WebSettings(android.webkit.WebSettings) WebChromeClient(android.webkit.WebChromeClient) WebResourceError(android.webkit.WebResourceError) WebView(android.webkit.WebView) IWebView(com.taobao.weex.ui.view.IWebView) HashMap(java.util.HashMap) Map(java.util.Map) WebViewClient(android.webkit.WebViewClient)

Aggregations

WebSettings (android.webkit.WebSettings)213 WebView (android.webkit.WebView)110 WebViewClient (android.webkit.WebViewClient)77 SuppressLint (android.annotation.SuppressLint)52 WebChromeClient (android.webkit.WebChromeClient)49 View (android.view.View)38 Intent (android.content.Intent)32 Bitmap (android.graphics.Bitmap)23 WebResourceRequest (android.webkit.WebResourceRequest)15 KeyEvent (android.view.KeyEvent)11 JsResult (android.webkit.JsResult)11 LinearLayout (android.widget.LinearLayout)11 WebResourceError (android.webkit.WebResourceError)10 CookieManager (android.webkit.CookieManager)9 TextView (android.widget.TextView)9 SslError (android.net.http.SslError)8 SslErrorHandler (android.webkit.SslErrorHandler)8 WebResourceResponse (android.webkit.WebResourceResponse)8 ProgressDialog (android.app.ProgressDialog)7 Toolbar (android.support.v7.widget.Toolbar)7