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/");
}
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();
}
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;
}
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());
}
}
});
}
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;
}
});
}
Aggregations