Java Code Examples for android.webkit.WebSettings#setDatabaseEnabled()
The following examples show how to use
android.webkit.WebSettings#setDatabaseEnabled() .
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: MainFragment.java From traccar-manager-android with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if ((getActivity().getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE) != 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } } getWebView().setWebViewClient(webViewClient); getWebView().setWebChromeClient(webChromeClient); getWebView().addJavascriptInterface(new AppInterface(), "appInterface"); WebSettings webSettings = getWebView().getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setMediaPlaybackRequiresUserGesture(false); String url = PreferenceManager.getDefaultSharedPreferences( getActivity()).getString(MainActivity.PREFERENCE_URL, null); getWebView().loadUrl(url); }
Example 2
Source File: CommonWebView.java From ZhuanLan with Apache License 2.0 | 6 votes |
private void init() { if (isInEditMode()) { return; } WebSettings settings = getSettings(); settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(false); //设置缓存模式 settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //开启DOM storage API功能 settings.setDomStorageEnabled(true); //开启database storage 功能 settings.setDatabaseEnabled(true); String cacheDir = getContext().getFilesDir().getAbsolutePath() + "web_cache"; settings.setAppCachePath(cacheDir); settings.setAppCacheEnabled(true); settings.setLoadsImagesAutomatically(true); settings.setDefaultTextEncodingName(ENCODING_UTF_8); settings.setBlockNetworkImage(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); setHorizontalScrollBarEnabled(false); }
Example 3
Source File: PKDialog.java From letv with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled"}) private void initViews() { this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.setWebViewClient(new FbWebViewClient()); this.mWebView.setWebChromeClient(this.mChromeClient); this.mWebView.clearFormData(); WebSettings settings = this.mWebView.getSettings(); settings.setSavePassword(false); settings.setSaveFormData(false); settings.setCacheMode(-1); settings.setNeedInitialFocus(false); settings.setBuiltInZoomControls(true); settings.setSupportZoom(true); settings.setRenderPriority(RenderPriority.HIGH); settings.setJavaScriptEnabled(true); if (!(this.mWeakContext == null || this.mWeakContext.get() == null)) { settings.setDatabaseEnabled(true); settings.setDatabasePath(((Context) this.mWeakContext.get()).getApplicationContext().getDir("databases", 0).getPath()); } settings.setDomStorageEnabled(true); this.jsBridge.a(new JsListener(), "sdk_js_if"); this.mWebView.clearView(); this.mWebView.loadUrl(this.mUrl); this.mWebView.getSettings().setSavePassword(false); }
Example 4
Source File: SocialApiIml.java From letv with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled"}) public void writeEncryToken(Context context) { String str = "tencent&sdk&qazxc***14969%%"; String accessToken = this.mToken.getAccessToken(); String appId = this.mToken.getAppId(); String openId = this.mToken.getOpenId(); String str2 = "qzone3.4"; if (accessToken == null || accessToken.length() <= 0 || appId == null || appId.length() <= 0 || openId == null || openId.length() <= 0) { str = null; } else { str = Util.encrypt(str + accessToken + appId + openId + str2); } com.tencent.open.c.b bVar = new com.tencent.open.c.b(context); WebSettings settings = bVar.getSettings(); settings.setDomStorageEnabled(true); settings.setJavaScriptEnabled(true); settings.setDatabaseEnabled(true); accessToken = "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\"><title>localStorage Test</title><script type=\"text/javascript\">document.domain = 'qq.com';localStorage[\"" + this.mToken.getOpenId() + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + this.mToken.getAppId() + "\"]=\"" + str + "\";</script></head><body></body></html>"; str = ServerSetting.getInstance().getEnvUrl(context, ServerSetting.DEFAULT_LOCAL_STORAGE_URI); bVar.loadDataWithBaseURL(str, accessToken, "text/html", "utf-8", str); }
Example 5
Source File: WebViewActivity.java From Tok-Android with GNU General Public License v3.0 | 6 votes |
private void initSetting() { WebSettings settings = mWebView.getSettings(); settings.setAppCacheEnabled(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } String userAgent = settings.getUserAgentString(); settings.setUserAgentString( userAgent + " TokAndroid/" + String.valueOf(BuildConfig.VERSION_NAME)); settings.setJavaScriptEnabled(true); settings.setAllowFileAccessFromFileURLs(false); settings.setAllowUniversalAccessFromFileURLs(false); settings.setDomStorageEnabled(true); settings.setAllowFileAccess(true); settings.setAppCacheEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setDatabaseEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); }
Example 6
Source File: LoveVideoView.java From gank.io-unofficial-android-client with Apache License 2.0 | 5 votes |
void init() { setWebViewClient(new LoveClient()); setWebChromeClient(new Chrome()); WebSettings webSettings = getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setSaveFormData(false); webSettings.setAppCacheEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); webSettings.setLoadWithOverviewMode(false); webSettings.setUseWideViewPort(true); }
Example 7
Source File: CustomWebView.java From letv with Apache License 2.0 | 5 votes |
@SuppressLint({"SetJavaScriptEnabled", "NewApi"}) public void initializeOptions() { WebSettings settings = getSettings(); if (VERSION.SDK_INT >= 21) { CookieManager.getInstance().setAcceptThirdPartyCookies(this, true); } settings.setUserAgentString(OtherUtil.getUserAgent(this.mContext)); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setCacheMode(2); settings.setAllowFileAccess(true); settings.setDefaultTextEncodingName("utf-8"); settings.setAppCacheEnabled(true); settings.setGeolocationEnabled(true); settings.setDatabaseEnabled(true); settings.setDomStorageEnabled(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setLoadsImagesAutomatically(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setSaveFormData(true); CookieManager.getInstance().setAcceptCookie(true); setLongClickable(false); setScrollbarFadingEnabled(true); setScrollBarStyle(0); setDrawingCacheEnabled(true); setClickable(true); setVerticalScrollBarEnabled(false); setHorizontalScrollBarEnabled(false); requestFocus(); }
Example 8
Source File: WebPlayerView.java From mv-android-client with Apache License 2.0 | 5 votes |
private void init(Context context) { mPlayer = new WebPlayer(this); setBackgroundColor(Color.BLACK); enableJavascript(); WebSettings webSettings = getSettings(); webSettings.setAllowContentAccess(true); webSettings.setAllowFileAccess(true); webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDatabasePath(context.getDir("database", Context.MODE_PRIVATE).getPath()); webSettings.setDomStorageEnabled(true); webSettings.setLoadsImagesAutomatically(true); webSettings.setSupportMultipleWindows(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { webSettings.setMediaPlaybackRequiresUserGesture(false); } } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); } setWebChromeClient(new ChromeClient()); setWebViewClient(new ViewClient()); }
Example 9
Source File: SnsPreviewActivity.java From samples with Apache License 2.0 | 5 votes |
@SuppressLint("SetJavaScriptEnabled") private void settingWebView() { WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setMinimumFontSize(16); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(false); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); //设置 缓存模式 // 开启 DOM storage API 功能 settings.setDomStorageEnabled(true); }
Example 10
Source File: ArticleActivity.java From WanAndroid with Apache License 2.0 | 5 votes |
/** * 配置WebView */ @SuppressLint("SetJavaScriptEnabled") private void setSettings(WebSettings settings) { if (mPresenter.getNoImageState()) settings.setBlockNetworkImage(true); else settings.setBlockNetworkImage(false); if(mPresenter.getAutoCacheState()){ settings.setAppCacheEnabled(true); settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true); if(NetWorkUtil.isNetworkConnected(this)) settings.setCacheMode(WebSettings.LOAD_DEFAULT);//(默认)根据cache-control决定是否从网络上取数据 else settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);//只要本地有,无论是否过期,或者no-cache,都使用缓存中的数据。 }else { settings.setAppCacheEnabled(false); settings.setDatabaseEnabled(false); settings.setDatabaseEnabled(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE);//不使用缓存,只从网络获取数据 } //支持缩放 settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); //不显示缩放按钮 settings.setDisplayZoomControls(false); //设置自适应屏幕,两者合用 //将图片调整到适合WebView的大小 settings.setUseWideViewPort(true); //缩放至屏幕的大小 settings.setLoadWithOverviewMode(true); //自适应屏幕 settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); }
Example 11
Source File: NinjaWebView.java From Ninja with Apache License 2.0 | 5 votes |
private synchronized void initWebSettings() { WebSettings webSettings = getSettings(); userAgentOriginal = webSettings.getUserAgentString(); webSettings.setAllowContentAccess(true); webSettings.setAllowFileAccess(true); webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setAppCacheEnabled(true); webSettings.setAppCachePath(context.getCacheDir().toString()); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setGeolocationDatabasePath(context.getFilesDir().toString()); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setDefaultTextEncodingName(BrowserUnit.URL_ENCODING); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { webSettings.setLoadsImagesAutomatically(true); } else { webSettings.setLoadsImagesAutomatically(false); } }
Example 12
Source File: Tab2Fragment.java From HelloActivityAndFragment with Apache License 2.0 | 5 votes |
@SuppressLint("JavascriptInterface") private void initWebView() { // Settings WebSettings settings = webView.getSettings(); settings.setDefaultTextEncodingName("GBK"); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setGeolocationEnabled(true); // settings.setDisplayZoomControls(false); settings.setBuiltInZoomControls(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setAppCachePath(this.getContext().getCacheDir().getAbsolutePath()); settings.setDisplayZoomControls(false); webView.requestFocus(); webView.setWebViewClient(new WebViewClient() { }); webView.setWebChromeClient(new WebChromeClient() { }); }
Example 13
Source File: Bridge.java From OsmGo with MIT License | 5 votes |
/** * Initialize the WebView, setting required flags */ private void initWebView() { WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setGeolocationEnabled(true); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setMediaPlaybackRequiresUserGesture(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); if (Config.getBoolean("android.allowMixedContent", false)) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } String backgroundColor = Config.getString("android.backgroundColor" , Config.getString("backgroundColor", null)); try { if (backgroundColor != null) { webView.setBackgroundColor(Color.parseColor(backgroundColor)); } } catch (IllegalArgumentException ex) { Log.d(LogUtils.getCoreTag(), "WebView background color not applied"); } boolean defaultDebuggable = false; if (isDevMode()) { defaultDebuggable = true; } WebView.setWebContentsDebuggingEnabled(Config.getBoolean("android.webContentsDebuggingEnabled", defaultDebuggable)); }
Example 14
Source File: BitWebViewFragment.java From tysq-android with GNU General Public License v3.0 | 4 votes |
private void initWebViewSetting(WebSettings settings) { //支持js脚本 settings.setJavaScriptEnabled(true); //支持缩放 settings.setSupportZoom(true); //支持缩放 settings.setBuiltInZoomControls(true); //去除缩放按钮 settings.setDisplayZoomControls(false); //扩大比例的缩放 settings.setUseWideViewPort(true); //自适应屏幕 settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setLoadWithOverviewMode(true); //多窗口 settings.supportMultipleWindows(); //关闭webview中缓存 settings.setCacheMode(WebSettings.LOAD_NO_CACHE); //设置可以访问文件 settings.setAllowFileAccess(true); //当webview调用requestFocus时为webview设置节点 settings.setNeedInitialFocus(true); //支持通过JS打开新窗口 settings.setJavaScriptCanOpenWindowsAutomatically(true); //支持自动加载图片 settings.setLoadsImagesAutomatically(true); //启用地理定位 // settings.setGeolocationEnabled(true); //设置渲染优先级 settings.setRenderPriority(WebSettings.RenderPriority.HIGH); // 设置支持本地存储 settings.setDatabaseEnabled(true); //设置支持DomStorage settings.setDomStorageEnabled(true); addJavascriptInterface(); }
Example 15
Source File: ClassicWebViewProvider.java From focus-android with Mozilla Public License 2.0 | 4 votes |
@SuppressLint("SetJavaScriptEnabled") // We explicitly want to enable JavaScript private void configureDefaultSettings(Context context, WebSettings settings) { settings.setJavaScriptEnabled(true); // Needs to be enabled to display some HTML5 sites that use local storage settings.setDomStorageEnabled(true); // Enabling built in zooming shows the controls by default settings.setBuiltInZoomControls(true); // So we hide the controls after enabling zooming settings.setDisplayZoomControls(false); // To respect the html viewport: settings.setLoadWithOverviewMode(true); // Also increase text size to fill the viewport (this mirrors the behaviour of Firefox, // Chrome does this in the current Chrome Dev, but not Chrome release). settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); // Disable access to arbitrary local files by webpages - assets can still be loaded // via file:///android_asset/res, so at least error page images won't be blocked. settings.setAllowFileAccess(false); settings.setAllowFileAccessFromFileURLs(false); settings.setAllowUniversalAccessFromFileURLs(false); final String appName = context.getResources().getString(R.string.useragent_appname); settings.setUserAgentString(buildUserAgentString(context, settings, appName)); // Right now I do not know why we should allow loading content from a content provider settings.setAllowContentAccess(false); // The default for those settings should be "false" - But we want to be explicit. settings.setAppCacheEnabled(false); settings.setDatabaseEnabled(false); settings.setJavaScriptCanOpenWindowsAutomatically(false); // We do not implement the callbacks - So let's disable it. settings.setGeolocationEnabled(false); // We do not want to save any data... settings.setSaveFormData(false); //noinspection deprecation - This method is deprecated but let's call it in case WebView implementations still obey it. settings.setSavePassword(false); }
Example 16
Source File: WebView.java From unity-ads-android with Apache License 2.0 | 4 votes |
public WebView(Context context) { super(context); WebSettings settings = getSettings(); if(Build.VERSION.SDK_INT >= 16) { settings.setAllowFileAccessFromFileURLs(true); settings.setAllowUniversalAccessFromFileURLs(true); } if (Build.VERSION.SDK_INT >= 19) { try { _evaluateJavascript = android.webkit.WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class); } catch(NoSuchMethodException e) { DeviceLog.exception("Method evaluateJavascript not found", e); _evaluateJavascript = null; } } settings.setAppCacheEnabled(false); settings.setBlockNetworkImage(false); settings.setBlockNetworkLoads(false); settings.setBuiltInZoomControls(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setDatabaseEnabled(false); if(Build.VERSION.SDK_INT >= 11) { settings.setDisplayZoomControls(false); } settings.setDomStorageEnabled(false); if(Build.VERSION.SDK_INT >= 11) { settings.setEnableSmoothTransition(false); } settings.setGeolocationEnabled(false); settings.setJavaScriptCanOpenWindowsAutomatically(false); settings.setJavaScriptEnabled(true); settings.setLightTouchEnabled(false); settings.setLoadWithOverviewMode(false); settings.setLoadsImagesAutomatically(true); if(Build.VERSION.SDK_INT >= 17) { settings.setMediaPlaybackRequiresUserGesture(false); } if(Build.VERSION.SDK_INT >= 21) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW); } settings.setNeedInitialFocus(true); settings.setPluginState(WebSettings.PluginState.OFF); settings.setRenderPriority(WebSettings.RenderPriority.NORMAL); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setSupportMultipleWindows(false); settings.setSupportZoom(false); settings.setUseWideViewPort(true); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); setInitialScale(0); setBackgroundColor(Color.TRANSPARENT); ViewUtilities.setBackground(this, new ColorDrawable(Color.TRANSPARENT)); setBackgroundResource(0); addJavascriptInterface(new WebViewBridgeInterface(), "webviewbridge"); }
Example 17
Source File: ArticleDetailActivity.java From Awesome-WanAndroid with Apache License 2.0 | 4 votes |
@SuppressLint("SetJavaScriptEnabled") @Override protected void initEventAndData() { mAgentWeb = AgentWeb.with(this) .setAgentWebParent(mWebContent, new LinearLayout.LayoutParams(-1, -1)) .useDefaultIndicator() .setMainFrameErrorView(R.layout.webview_error_view, -1) .createAgentWeb() .ready() .go(articleLink); WebView mWebView = mAgentWeb.getWebCreator().getWebView(); WebSettings mSettings = mWebView.getSettings(); if (mPresenter.getNoImageState()) { mSettings.setBlockNetworkImage(true); } else { mSettings.setBlockNetworkImage(false); } if (mPresenter.getAutoCacheState()) { mSettings.setAppCacheEnabled(true); mSettings.setDomStorageEnabled(true); mSettings.setDatabaseEnabled(true); if (CommonUtils.isNetworkConnected()) { mSettings.setCacheMode(WebSettings.LOAD_DEFAULT); } else { mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); } } else { mSettings.setAppCacheEnabled(false); mSettings.setDomStorageEnabled(false); mSettings.setDatabaseEnabled(false); mSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); } mSettings.setJavaScriptEnabled(true); mSettings.setSupportZoom(true); mSettings.setBuiltInZoomControls(true); //不显示缩放按钮 mSettings.setDisplayZoomControls(false); //设置自适应屏幕,两者合用 //将图片调整到适合WebView的大小 mSettings.setUseWideViewPort(true); //缩放至屏幕的大小 mSettings.setLoadWithOverviewMode(true); //自适应屏幕 mSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); }
Example 18
Source File: AppbarActivity.java From letv with Apache License 2.0 | 4 votes |
private void initViews() { Method method; WebSettings settings = this.mWebView.getSettings(); settings.setBuiltInZoomControls(true); settings.setUserAgentString(settings.getUserAgentString() + "/" + UA_PREFIX + this.jsBridge.getVersion() + "/sdk"); settings.setJavaScriptEnabled(true); Class cls = settings.getClass(); try { method = cls.getMethod("setPluginsEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(settings, new Object[]{Boolean.valueOf(true)}); } } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (Throwable th) { th.printStackTrace(); } try { method = cls.getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(settings, new Object[]{Boolean.valueOf(true)}); } } catch (SecurityException e2) { e2.printStackTrace(); } catch (NoSuchMethodException e3) { } catch (IllegalArgumentException e4) { } catch (IllegalAccessException e5) { } catch (InvocationTargetException e6) { } settings.setAppCachePath(getWebViewCacheDir()); settings.setDatabasePath(getWebViewCacheDir()); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); if (supportWebViewFullScreen()) { settings.setUseWideViewPort(true); if (VERSION.SDK_INT >= 7) { try { cls.getMethod("setLoadWithOverviewMode", new Class[]{Boolean.TYPE}).invoke(settings, new Object[]{Boolean.valueOf(true)}); } catch (Exception e7) { } } if (SystemUtils.isSupportMultiTouch()) { if (SystemUtils.getAndroidSDKVersion() < 11) { try { Field declaredField = WebView.class.getDeclaredField("mZoomButtonsController"); declaredField.setAccessible(true); ZoomButtonsController zoomButtonsController = new ZoomButtonsController(this.mWebView); zoomButtonsController.getZoomControls().setVisibility(8); declaredField.set(this.mWebView, zoomButtonsController); } catch (Exception e8) { } } else { try { this.mWebView.getSettings().getClass().getMethod("setDisplayZoomControls", new Class[]{Boolean.TYPE}).invoke(this.mWebView.getSettings(), new Object[]{Boolean.valueOf(false)}); } catch (Exception e9) { } } } } this.mWebView.setWebViewClient(new d()); this.mWebView.setWebChromeClient(new c()); this.mWebView.setDownloadListener(this.mDownloadListener); this.mWebView.loadUrl(this.url); }
Example 19
Source File: SystemWebViewEngine.java From pychat with MIT License | 4 votes |
@SuppressLint({"NewApi", "SetJavaScriptEnabled"}) @SuppressWarnings("deprecation") private void initWebViewSettings() { webView.setInitialScale(0); webView.setVerticalScrollBarEnabled(false); // Enable JavaScript final WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); String manufacturer = android.os.Build.MANUFACTURER; LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer); //We don't save any form data in the application settings.setSaveFormData(false); settings.setSavePassword(false); // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist // while we do this settings.setAllowUniversalAccessFromFileURLs(true); settings.setMediaPlaybackRequiresUserGesture(false); // Enable database // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16 String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabaseEnabled(true); settings.setDatabasePath(databasePath); //Determine whether we're in debug or release mode, and turn on Debugging! ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo(); if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { enableRemoteDebugging(); } settings.setGeolocationDatabasePath(databasePath); // Enable DOM storage settings.setDomStorageEnabled(true); // Enable built-in geolocation settings.setGeolocationEnabled(true); // Enable AppCache // Fix for CB-2282 settings.setAppCacheMaxSize(5 * 1048576); settings.setAppCachePath(databasePath); settings.setAppCacheEnabled(true); // Fix for CB-1405 // Google issue 4641 String defaultUserAgent = settings.getUserAgentString(); // Fix for CB-3360 String overrideUserAgent = preferences.getString("OverrideUserAgent", null); if (overrideUserAgent != null) { settings.setUserAgentString(overrideUserAgent); } else { String appendUserAgent = preferences.getString("AppendUserAgent", null); if (appendUserAgent != null) { settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent); } } // End CB-3360 IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { settings.getUserAgentString(); } }; webView.getContext().registerReceiver(this.receiver, intentFilter); } // end CB-1405 }
Example 20
Source File: SystemWebViewEngine.java From keemob with MIT License | 4 votes |
@SuppressLint({"NewApi", "SetJavaScriptEnabled"}) @SuppressWarnings("deprecation") private void initWebViewSettings() { webView.setInitialScale(0); webView.setVerticalScrollBarEnabled(false); // Enable JavaScript final WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); String manufacturer = android.os.Build.MANUFACTURER; LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer); //We don't save any form data in the application settings.setSaveFormData(false); settings.setSavePassword(false); // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist // while we do this settings.setAllowUniversalAccessFromFileURLs(true); settings.setMediaPlaybackRequiresUserGesture(false); // Enable database // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16 String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); settings.setDatabaseEnabled(true); settings.setDatabasePath(databasePath); //Determine whether we're in debug or release mode, and turn on Debugging! ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo(); if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { enableRemoteDebugging(); } settings.setGeolocationDatabasePath(databasePath); // Enable DOM storage settings.setDomStorageEnabled(true); // Enable built-in geolocation settings.setGeolocationEnabled(true); // Enable AppCache // Fix for CB-2282 settings.setAppCacheMaxSize(5 * 1048576); settings.setAppCachePath(databasePath); settings.setAppCacheEnabled(true); // Fix for CB-1405 // Google issue 4641 String defaultUserAgent = settings.getUserAgentString(); // Fix for CB-3360 String overrideUserAgent = preferences.getString("OverrideUserAgent", null); if (overrideUserAgent != null) { settings.setUserAgentString(overrideUserAgent); } else { String appendUserAgent = preferences.getString("AppendUserAgent", null); if (appendUserAgent != null) { settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent); } } // End CB-3360 IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { settings.getUserAgentString(); } }; webView.getContext().registerReceiver(this.receiver, intentFilter); } // end CB-1405 }