Search in sources :

Example 6 with WebSettings

use of android.webkit.WebSettings in project ETSMobile-Android2 by ApplETS.

the class MonETSFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup v = (ViewGroup) inflater.inflate(R.layout.fragment_web_view, container, false);
    super.onCreateView(inflater, v, savedInstanceState);
    webView = (WebView) v.findViewById(R.id.webView);
    final WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    loadingView.showLoadingView();
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            view.loadUrl(url);
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // super.onPageFinished(view, url);
            LoadingView.hideLoadingView(loadingView);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
        }
    });
    webView.loadUrl("https://portail.etsmtl.ca/");
    AnalyticsHelper.getInstance(getActivity()).sendScreenEvent(getClass().getSimpleName());
    return v;
}
Also used : ViewGroup(android.view.ViewGroup) WebSettings(android.webkit.WebSettings) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 7 with WebSettings

use of android.webkit.WebSettings in project ETSMobile-Android2 by ApplETS.

the class BiblioFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup v = (ViewGroup) inflater.inflate(R.layout.fragment_web_view, container, false);
    super.onCreateView(inflater, v, savedInstanceState);
    webView = (WebView) v.findViewById(R.id.webView);
    final WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    loadingView.showLoadingView();
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            view.loadUrl(url);
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // super.onPageFinished(view, url);
            LoadingView.hideLoadingView(loadingView);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            view.loadUrl("file:///android_asset/webview_error_page.html");
        }
    });
    webView.loadUrl(getActivity().getString(R.string.url_biblio));
    AnalyticsHelper.getInstance(getActivity()).sendScreenEvent(getClass().getSimpleName());
    return v;
}
Also used : ViewGroup(android.view.ViewGroup) WebSettings(android.webkit.WebSettings) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 8 with WebSettings

use of android.webkit.WebSettings in project bilibili-android-client by HotBitmapGG.

the class BrowserActivity method setupWebView.

@SuppressLint("SetJavaScriptEnabled")
private void setupWebView() {
    progressBar.spin();
    final WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setDomStorageEnabled(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    mWebView.getSettings().setBlockNetworkImage(true);
    mWebView.setWebViewClient(webViewClient);
    mWebView.requestFocus(View.FOCUS_DOWN);
    mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
            AlertDialog.Builder b2 = new AlertDialog.Builder(BrowserActivity.this).setTitle(R.string.app_name).setMessage(message).setPositiveButton("确定", (dialog, which) -> result.confirm());
            b2.setCancelable(false);
            b2.create();
            b2.show();
            return true;
        }
    });
    mWebView.loadUrl(url);
}
Also used : JsResult(android.webkit.JsResult) ConstantUtil(com.hotbitmapgg.bilibili.utils.ConstantUtil) Bundle(android.os.Bundle) JsResult(android.webkit.JsResult) Uri(android.net.Uri) Intent(android.content.Intent) RxBaseActivity(com.hotbitmapgg.bilibili.base.RxBaseActivity) MenuItem(android.view.MenuItem) BindView(butterknife.BindView) SuppressLint(android.annotation.SuppressLint) R(com.hotbitmapgg.ohmybilibili.R) WebSettings(android.webkit.WebSettings) WebResourceRequest(android.webkit.WebResourceRequest) Handler(android.os.Handler) Menu(android.view.Menu) WebViewClient(android.webkit.WebViewClient) View(android.view.View) WebView(android.webkit.WebView) ActionBar(android.support.v7.app.ActionBar) WebChromeClient(android.webkit.WebChromeClient) TextUtils(android.text.TextUtils) AlertDialog(android.app.AlertDialog) WebResourceError(android.webkit.WebResourceError) CircleProgressView(com.hotbitmapgg.bilibili.widget.CircleProgressView) Toolbar(android.support.v7.widget.Toolbar) Bitmap(android.graphics.Bitmap) ToastUtil(com.hotbitmapgg.bilibili.utils.ToastUtil) ClipboardUtil(com.hotbitmapgg.bilibili.utils.ClipboardUtil) Activity(android.app.Activity) WebSettings(android.webkit.WebSettings) WebChromeClient(android.webkit.WebChromeClient) WebView(android.webkit.WebView) SuppressLint(android.annotation.SuppressLint)

Example 9 with WebSettings

use of android.webkit.WebSettings in project UltimateAndroid by cymcsg.

the class WebViewActivity method initWebView.

private void initWebView() {
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient());
    WebSettings settings = mWebView.getSettings();
    settings.setSavePassword(true);
    settings.setSaveFormData(true);
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDomStorageEnabled(true);
    settings.setSupportMultipleWindows(false);
    mWebView.loadUrl("http://developer.android.com");
}
Also used : WebSettings(android.webkit.WebSettings) WebChromeClient(android.webkit.WebChromeClient) WebViewClient(android.webkit.WebViewClient)

Example 10 with WebSettings

use of android.webkit.WebSettings in project UltimateAndroid by cymcsg.

the class Html5Webview method init.

private void init(Context context) {
    mContext = context;
    Activity mActivity = (Activity) mContext;
    mLayout = new FrameLayout(context);
    mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity).inflate(R.layout.custom_screen, null);
    mContentView = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.main_content);
    mCustomViewContainer = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.fullscreen_custom_content);
    mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
    // Configure the webview
    WebSettings s = getSettings();
    s.setBuiltInZoomControls(true);
    s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    s.setUseWideViewPort(true);
    s.setLoadWithOverviewMode(true);
    //  s.setSavePassword(true);
    s.setSaveFormData(true);
    s.setJavaScriptEnabled(true);
    mWebChromeClient = new MyWebChromeClient();
    setWebChromeClient(mWebChromeClient);
    setWebViewClient(new WebViewClient());
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    // enable navigator.geolocation
    // s.setGeolocationEnabled(true);
    // s.setGeolocationDatabasePath("/data/data/org.itri.html5webview/databases/");
    // enable Web Storage: localStorage, sessionStorage
    s.setDomStorageEnabled(true);
    mContentView.addView(this);
}
Also used : WebSettings(android.webkit.WebSettings) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) WebViewClient(android.webkit.WebViewClient)

Aggregations

WebSettings (android.webkit.WebSettings)211 WebView (android.webkit.WebView)108 WebViewClient (android.webkit.WebViewClient)75 SuppressLint (android.annotation.SuppressLint)50 WebChromeClient (android.webkit.WebChromeClient)47 View (android.view.View)38 Intent (android.content.Intent)30 Bitmap (android.graphics.Bitmap)21 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