use of android.webkit.WebSettings in project FastHub by k0shk0sh.
the class PrettifyWebView method setSource.
public void setSource(@NonNull String source, boolean wrap) {
if (!InputHelper.isEmpty(source)) {
WebSettings settings = getSettings();
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
settings.setSupportZoom(!wrap);
settings.setBuiltInZoomControls(!wrap);
if (!wrap)
settings.setDisplayZoomControls(false);
String page = PrettifyHelper.generateContent(source, AppHelper.isNightMode(getResources()), wrap);
loadCode(page);
}
}
use of android.webkit.WebSettings in project LearnApp by YouCii.
the class WebFragment method webSettings.
@Override
@SuppressLint("SetJavaScriptEnabled")
public void webSettings(WebView webView) {
WebSettings settings = webView.getSettings();
// 支持javascript
settings.setJavaScriptEnabled(true);
// 设置是否支持缩放
settings.setSupportZoom(false);
// 设置是否支持缩放
settings.setBuiltInZoomControls(false);
// 设置出现缩放工具
settings.setDisplayZoomControls(false);
/* 自动自适应屏幕 */
// 自适应屏幕
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setLoadWithOverviewMode(true);
// 扩大比例的缩放
settings.setUseWideViewPort(true);
}
use of android.webkit.WebSettings in project incubator-weex by apache.
the class WXWebView 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() {
@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());
}
if (mOnMessageListener != null) {
evaluateJS("javascript:(window.postMessage = function(message, targetOrigin) {" + "if (message == null || !targetOrigin) return;" + (DOWNGRADE_JS_INTERFACE ? "prompt('" + BRIDGE_NAME + "://postMessage?message=' + JSON.stringify(message) + '&targetOrigin=' + targetOrigin)" : BRIDGE_NAME + ".postMessage(JSON.stringify(message), targetOrigin);") + "})");
}
}
@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 onJsPrompt(WebView view, String url, String text, String defaultValue, JsPromptResult result) {
Uri uri = Uri.parse(text);
String scheme = uri.getScheme();
if (TextUtils.equals(scheme, BRIDGE_NAME)) {
if (TextUtils.equals(uri.getAuthority(), "postMessage")) {
String message = uri.getQueryParameter("message");
String targetOrigin = uri.getQueryParameter("targetOrigin");
onMessage(message, targetOrigin);
result.confirm("success");
} else {
result.confirm("fail");
}
return true;
}
return super.onJsPrompt(view, url, text, defaultValue, result);
}
});
if (!DOWNGRADE_JS_INTERFACE) {
wv.addJavascriptInterface(new Object() {
@JavascriptInterface
public void postMessage(String message, String targetOrigin) {
onMessage(message, targetOrigin);
}
}, BRIDGE_NAME);
}
}
use of android.webkit.WebSettings in project androidquery by androidquery.
the class WebImage method load.
public void load() {
if (url.equals(wv.getTag(AQuery.TAG_URL))) {
return;
}
wv.setTag(AQuery.TAG_URL, url);
if (android.os.Build.VERSION.SDK_INT <= 10) {
wv.setDrawingCacheEnabled(true);
}
fixWebviewTip(wv.getContext());
WebSettings ws = wv.getSettings();
ws.setSupportZoom(zoom);
ws.setBuiltInZoomControls(zoom);
if (!control) {
disableZoomControl(wv);
}
ws.setJavaScriptEnabled(true);
wv.setBackgroundColor(color);
if (progress != null) {
// progress.setVisibility(View.VISIBLE);
Common.showProgress(progress, url, true);
}
if (wv.getWidth() > 0) {
setup();
} else {
delaySetup();
}
}
use of android.webkit.WebSettings in project wigle-wifi-wardriving by wiglenet.
the class RegistrationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
WebView regWebView = (WebView) findViewById(R.id.wigle_registration_container);
WebSettings webSettings = regWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
regWebView.clearCache(true);
clearCookies(MainActivity.getMainActivity().getApplicationContext());
regWebView.setWebChromeClient(new WebChromeClient());
regWebView.getSettings().setUserAgentString(AGENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
regWebView.addJavascriptInterface(new WiGLERegistrationInterface(this), "WiGLEWiFi");
regWebView.loadUrl(MainActivity.REG_URL);
}
Aggregations