Java Code Examples for android.webkit.WebSettings#setSupportMultipleWindows()
The following examples show how to use
android.webkit.WebSettings#setSupportMultipleWindows() .
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: WebViewFragment.java From NestedTouchScrollingLayout with MIT License | 6 votes |
private void initWebSettings() { WebSettings settings = this.mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(false); settings.setDisplayZoomControls(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); settings.supportMultipleWindows(); settings.setSupportMultipleWindows(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setAppCachePath(this.mWebView.getContext().getCacheDir().getAbsolutePath()); settings.setAllowFileAccess(true); settings.setLoadsImagesAutomatically(true); settings.setDefaultTextEncodingName("UTF-8"); }
Example 2
Source File: JockeyJsWebView.java From TLint with Apache License 2.0 | 6 votes |
private void initWebView() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setWebContentsDebuggingEnabled(BuildConfig.DEBUG); } WebSettings settings = getSettings(); settings.setJavaScriptEnabled(true); settings.setAllowFileAccess(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); settings.setUseWideViewPort(true); settings.setSupportZoom(false); settings.setBuiltInZoomControls(false); settings.setSupportMultipleWindows(true); settings.setDefaultTextEncodingName("UTF-8"); if (Build.VERSION.SDK_INT > 12) { settings.setJavaScriptCanOpenWindowsAutomatically(true); } settings.setAppCacheEnabled(true); settings.setLoadWithOverviewMode(true); settings.setDomStorageEnabled(true); settings.setCacheMode(NetWorkUtil.isNetworkConnected(getContext()) ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ELSE_NETWORK); settings.setCacheMode(2); if (Build.VERSION.SDK_INT > 11) { setLayerType(0, null); } }
Example 3
Source File: BaseWebView.java From RichWebList with Apache License 2.0 | 6 votes |
private void initWebViewSettings() { WebSettings webSetting = this.getSettings(); webSetting.setJavaScriptEnabled(true); webSetting.setJavaScriptCanOpenWindowsAutomatically(true); webSetting.setAllowFileAccess(true); webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); webSetting.setSupportZoom(true); webSetting.setBuiltInZoomControls(true); webSetting.setUseWideViewPort(true); webSetting.setSupportMultipleWindows(true); // webSetting.setLoadWithOverviewMode(true); webSetting.setAppCacheEnabled(true); // webSetting.setDatabaseEnabled(true); webSetting.setDomStorageEnabled(true); webSetting.setGeolocationEnabled(true); webSetting.setAppCacheMaxSize(Long.MAX_VALUE); // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY); webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND); // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH); webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE); // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension // settings 的设计 }
Example 4
Source File: WebViewAndRecyclerViewActivity.java From NestedTouchScrollingLayout with MIT License | 6 votes |
@SuppressLint("SetJavaScriptEnabled") private void initWebSettings() { WebSettings settings = this.mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(false); settings.setDisplayZoomControls(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); settings.supportMultipleWindows(); settings.setSupportMultipleWindows(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setAppCachePath(this.mWebView.getContext().getCacheDir().getAbsolutePath()); settings.setAllowFileAccess(true); settings.setLoadsImagesAutomatically(true); settings.setDefaultTextEncodingName("UTF-8"); }
Example 5
Source File: WebViewActivity.java From NestedTouchScrollingLayout with MIT License | 6 votes |
@SuppressLint("SetJavaScriptEnabled") private void initWebSettings() { WebSettings settings = this.mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(false); settings.setDisplayZoomControls(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); settings.supportMultipleWindows(); settings.setSupportMultipleWindows(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setAppCachePath(this.mWebView.getContext().getCacheDir().getAbsolutePath()); settings.setAllowFileAccess(true); settings.setLoadsImagesAutomatically(true); settings.setDefaultTextEncodingName("UTF-8"); }
Example 6
Source File: HuPuWebView.java From TLint with Apache License 2.0 | 5 votes |
private void init() { ((MyApplication) getContext().getApplicationContext()).getApplicationComponent().inject(this); WebSettings settings = getSettings(); settings.setBuiltInZoomControls(false); settings.setSupportZoom(false); settings.setJavaScriptEnabled(true); settings.setAllowFileAccess(true); settings.setSupportMultipleWindows(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setDomStorageEnabled(true); settings.setCacheMode(1); settings.setUseWideViewPort(true); if (Build.VERSION.SDK_INT > 6) { settings.setAppCacheEnabled(true); settings.setLoadWithOverviewMode(true); } settings.setCacheMode(WebSettings.LOAD_DEFAULT); String path = getContext().getFilesDir().getPath(); settings.setGeolocationEnabled(true); settings.setGeolocationDatabasePath(path); settings.setDomStorageEnabled(true); this.basicUA = settings.getUserAgentString() + " kanqiu/7.05.6303/7059"; setBackgroundColor(0); initWebViewClient(); try { if (mUserStorage.isLogin()) { String token = mUserStorage.getToken(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "u=" + URLEncoder.encode(mUserStorage.getCookie(), "utf-8")); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_gamesu=" + URLEncoder.encode(token, "utf-8")); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_inKanqiuApp=1"); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_kanqiu=1"); CookieSyncManager.getInstance().sync(); } } catch (Exception e) { e.printStackTrace(); } }
Example 7
Source File: WebViewActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
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"); }
Example 8
Source File: LoginActivity.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
@SuppressLint("SetJavaScriptEnabled") private static void prepareWebViewSettings(WebSettings settings) { settings.setUserAgentString(settings.getUserAgentString() + MAGIC_USER_AGENT); settings.setJavaScriptEnabled(true); settings.setSupportMultipleWindows(false); settings.setSaveFormData(false); settings.setAllowFileAccess(false); settings.setDatabaseEnabled(false); settings.setNeedInitialFocus(false); settings.setUseWideViewPort(false); settings.setSupportZoom(false); settings.setJavaScriptCanOpenWindowsAutomatically(false); }
Example 9
Source File: Html5Activity.java From ClassSchedule with Apache License 2.0 | 5 votes |
/** * 多窗口的问题 */ private void newWin(WebSettings mWebSettings) { //html中的_bank标签就是新建窗口打开,有时会打不开,需要加以下 //然后 复写 WebChromeClient的onCreateWindow方法 mWebSettings.setSupportMultipleWindows(false); mWebSettings.setJavaScriptCanOpenWindowsAutomatically(true); }
Example 10
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 11
Source File: WebViewFragment.java From Bitocle with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setContentView(R.layout.webview_fragment); setContentShown(true); View view = getContentView(); webView = (WebView) view.findViewById(R.id.webview_fragment); /* Do something */ WebSettings webSettings = webView.getSettings(); webSettings.setBuiltInZoomControls(true); webSettings.setJavaScriptEnabled(true); webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL); webSettings.setLoadWithOverviewMode(true); webSettings.setLoadsImagesAutomatically(true); webSettings.setSupportMultipleWindows(true); webSettings.setSupportZoom(true); webSettings.setUseWideViewPort(true); SharedPreferences sharedPreferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE); String oAuth = sharedPreferences.getString(getString(R.string.login_sp_oauth), null); gitHubClient = new GitHubClient(); gitHubClient.setOAuth2Token(oAuth); Intent intent = getActivity().getIntent(); repoOwner = intent.getStringExtra(getString(R.string.content_intent_repoowner)); repoName = intent.getStringExtra(getString(R.string.content_intent_reponame)); fileName = intent.getStringExtra(getString(R.string.content_intent_filename)); sha = intent.getStringExtra(getString(R.string.content_intent_sha)); webViewTask = new WebViewTask(WebViewFragment.this); webViewTask.execute(); }
Example 12
Source File: HuPuWebView.java From SprintNBA with Apache License 2.0 | 5 votes |
private void init() { WebSettings settings = getSettings(); settings.setBuiltInZoomControls(false); settings.setSupportZoom(false); settings.setJavaScriptEnabled(true); settings.setAllowFileAccess(true); settings.setSupportMultipleWindows(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setDomStorageEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setUseWideViewPort(true); if (Build.VERSION.SDK_INT > 6) { settings.setAppCacheEnabled(true); settings.setLoadWithOverviewMode(true); } String path = getContext().getFilesDir().getPath(); settings.setGeolocationEnabled(true); settings.setGeolocationDatabasePath(path); settings.setDomStorageEnabled(true); this.basicUA = settings.getUserAgentString() + " kanqiu/7.05.6303/7059"; setBackgroundColor(0); initWebViewClient(); setWebChromeClient(new HuPuChromeClient()); try { if (SettingPrefUtils.isLogin()) { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "u=" + SettingPrefUtils.getCookies()); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_gamesu=" + URLEncoder.encode(SettingPrefUtils.getToken(), "utf-8")); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_inKanqiuApp=1"); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_kanqiu=1"); CookieSyncManager.getInstance().sync(); } } catch (Exception e) { e.printStackTrace(); } }
Example 13
Source File: WebViewActivity.java From YCAudioPlayer with Apache License 2.0 | 4 votes |
@SuppressLint("JavascriptInterface") private void initWebView() { WebSettings ws = mWebView.getSettings(); // 网页内容的宽度是否可大于WebView控件的宽度 ws.setLoadWithOverviewMode(false); // 保存表单数据 ws.setSaveFormData(true); // 是否应该支持使用其屏幕缩放控件和手势缩放 ws.setSupportZoom(true); ws.setBuiltInZoomControls(true); ws.setDisplayZoomControls(false); // 启动应用缓存 ws.setAppCacheEnabled(true); // 设置缓存模式 ws.setCacheMode(WebSettings.LOAD_DEFAULT); // setDefaultZoom api19被弃用 // 设置此属性,可任意比例缩放。 ws.setUseWideViewPort(true); // 缩放比例 1 mWebView.setInitialScale(1); // 告诉WebView启用JavaScript执行。默认的是false。 ws.setJavaScriptEnabled(true); //如果启用了JavaScript,要做好安全措施,防止远程执行漏洞 removeJavascriptInterfaces(mWebView); // 页面加载好以后,再放开图片 ws.setBlockNetworkImage(false); // 使用localStorage则必须打开 ws.setDomStorageEnabled(true); //自动加载图片 ws.setLoadsImagesAutomatically(true); // 排版适应屏幕 ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); // WebView是否支持多个窗口。 ws.setSupportMultipleWindows(true); // webView从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } /*设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/ ws.setTextZoom(100); //在js中调用本地java方法 jsAppInterface = new JsAppInterface(this, mWebView); jsAppInterface.register(); mWebView.addJavascriptInterface(jsAppInterface, "WebViewJsMethodName"); mWebView.addJavascriptInterface(new JavascriptInterface(this), "injectedObject"); mWebView.setWebViewClient(new MyWebViewClient()); mWebView.setWebChromeClient(webChromeClient = new MyWebChromeClient()); mWebView.setScrollWebListener(new ScrollWebView.OnScrollWebListener() { @Override public void onScroll(int dx, int dy) { //WebView的总高度 float webViewContentHeight = mWebView.getContentHeight() * mWebView.getScale(); //WebView的现高度 float webViewCurrentHeight = (mWebView.getHeight() + mWebView.getScrollY()); LogUtils.e("webViewContentHeight=" + webViewContentHeight); LogUtils.e("webViewCurrentHeight=" + webViewCurrentHeight); if ((webViewContentHeight - webViewCurrentHeight) == 0) { LogUtils.e("WebView滑动到了底端"); } } }); }
Example 14
Source File: WebViewActivity.java From NetEasyNews with GNU General Public License v3.0 | 4 votes |
private void initWebView() { mProgressBar.setVisibility(View.VISIBLE); WebSettings ws = webView.getSettings(); // 网页内容的宽度是否可大于WebView控件的宽度 ws.setLoadWithOverviewMode(false); // 保存表单数据 ws.setSaveFormData(true); // 是否应该支持使用其屏幕缩放控件和手势缩放 ws.setSupportZoom(true); ws.setBuiltInZoomControls(true); ws.setDisplayZoomControls(false); // 启动应用缓存 ws.setAppCacheEnabled(true); // 设置缓存模式 ws.setCacheMode(WebSettings.LOAD_DEFAULT); // setDefaultZoom api19被弃用 // 设置此属性,可任意比例缩放。 ws.setUseWideViewPort(true); // 缩放比例 1 webView.setInitialScale(1); // 告诉WebView启用JavaScript执行。默认的是false。 ws.setJavaScriptEnabled(true); // 页面加载好以后,再放开图片 ws.setBlockNetworkImage(false); // 使用localStorage则必须打开 ws.setDomStorageEnabled(true); // 排版适应屏幕 ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); // WebView是否支持多个窗口。 ws.setSupportMultipleWindows(true); // webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } /** 设置字体默认缩放大小(改变网页字体大小,setTextSize api14被弃用)*/ ws.setTextZoom(100); mWebChromeClient = new MyWebChromeClient(this); webView.setWebChromeClient(mWebChromeClient); // 与js交互 webView.addJavascriptInterface(new ImageClickInterface(this), "injectedObject"); webView.setWebViewClient(new MyWebViewClient(this)); }
Example 15
Source File: ChatWindowView.java From chat-window-android with MIT License | 4 votes |
private void initView(Context context) { setFitsSystemWindows(true); setVisibility(GONE); LayoutInflater.from(context).inflate(R.layout.view_chat_window_internal, this, true); webView = (WebView) findViewById(R.id.chat_window_web_view); statusText = (TextView) findViewById(R.id.chat_window_status_text); progressBar = (ProgressBar) findViewById(R.id.chat_window_progress); reloadButton = (Button) findViewById(R.id.chat_window_button); reloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { reload(); } }); if (Build.VERSION.RELEASE.matches("4\\.4(\\.[12])?")) { String userAgentString = webView.getSettings().getUserAgentString(); webView.getSettings().setUserAgentString(userAgentString + " AndroidNoFilesharing"); } CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); webView.setFocusable(true); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setSupportMultipleWindows(true); webSettings.setDomStorageEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cookieManager.getInstance().setAcceptThirdPartyCookies(webView, true); } webView.setWebViewClient(new LCWebViewClient()); webView.setWebChromeClient(new LCWebChromeClient()); webView.requestFocus(View.FOCUS_DOWN); webView.setVisibility(GONE); webView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); webView.addJavascriptInterface(new ChatWindowJsInterface(this), ChatWindowJsInterface.BRIDGE_OBJECT_NAME); }
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: WebSettingsCompat.java From Android_Skin_2.0 with Apache License 2.0 | 4 votes |
@Override public void setSupportMultipleWindows(WebSettings settings, boolean support) { settings.setSupportMultipleWindows(support); }
Example 18
Source File: H5PayActivity.java From letv with Apache License 2.0 | 4 votes |
protected void onCreate(Bundle bundle) { super.onCreate(bundle); try { Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } try { String string = extras.getString("url"); if (k.a(string)) { Method method; super.requestWindowFeature(1); this.c = new Handler(getMainLooper()); Object string2 = extras.getString("cookie"); if (!TextUtils.isEmpty(string2)) { CookieSyncManager.createInstance(getApplicationContext()).sync(); CookieManager.getInstance().setCookie(string, string2); CookieSyncManager.getInstance().sync(); } View linearLayout = new LinearLayout(getApplicationContext()); LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1); linearLayout.setOrientation(1); setContentView(linearLayout, layoutParams); this.a = new WebView(getApplicationContext()); layoutParams.weight = 1.0f; this.a.setVisibility(0); linearLayout.addView(this.a, layoutParams); WebSettings settings = this.a.getSettings(); settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext())); settings.setRenderPriority(RenderPriority.HIGH); settings.setSupportMultipleWindows(true); settings.setJavaScriptEnabled(true); settings.setSavePassword(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setMinimumFontSize(settings.getMinimumFontSize() + 8); settings.setAllowFileAccess(false); settings.setTextSize(TextSize.NORMAL); this.a.setVerticalScrollbarOverlay(true); this.a.setWebViewClient(new a()); this.a.loadUrl(string); if (VERSION.SDK_INT >= 7) { try { method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)}); } } catch (Exception e) { } } try { method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]); if (method != null) { method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"}); return; } return; } catch (Exception e2) { return; } } finish(); } catch (Exception e3) { finish(); } } catch (Exception e4) { finish(); } }
Example 19
Source File: NinjaWebView.java From Ninja with Apache License 2.0 | 4 votes |
public synchronized void initPreferences() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); WebSettings webSettings = getSettings(); webSettings.setLoadWithOverviewMode(true); webSettings.setTextZoom(100); webSettings.setUseWideViewPort(true); webSettings.setBlockNetworkImage(!sp.getBoolean(context.getString(R.string.sp_images), true)); webSettings.setJavaScriptEnabled(sp.getBoolean(context.getString(R.string.sp_javascript), true)); webSettings.setJavaScriptCanOpenWindowsAutomatically(sp.getBoolean(context.getString(R.string.sp_javascript), true)); webSettings.setGeolocationEnabled(sp.getBoolean(context.getString(R.string.sp_location), true)); webSettings.setSupportMultipleWindows(sp.getBoolean(context.getString(R.string.sp_multiple_windows), false)); webSettings.setSaveFormData(sp.getBoolean(context.getString(R.string.sp_passwords), true)); boolean textReflow = sp.getBoolean(context.getString(R.string.sp_text_reflow), true); if (textReflow) { webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { try { webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); } catch (Exception e) {} } } else { webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); } int userAgent = Integer.valueOf(sp.getString(context.getString(R.string.sp_user_agent), "0")); if (userAgent == 1) { webSettings.setUserAgentString(BrowserUnit.UA_DESKTOP); } else if (userAgent == 2) { webSettings.setUserAgentString(sp.getString(context.getString(R.string.sp_user_agent_custom), userAgentOriginal)); } else { webSettings.setUserAgentString(userAgentOriginal); } int mode = Integer.valueOf(sp.getString(context.getString(R.string.sp_rendering), "0")); initRendering(mode); webViewClient.enableAdBlock(sp.getBoolean(context.getString(R.string.sp_ad_block), true)); }
Example 20
Source File: MainActivity.java From styT with Apache License 2.0 | 4 votes |
@SuppressLint("SetJavaScriptEnabled") private void initWebSettings() { WebSettings settings = sMm.getSettings(); settings.setUserAgentString("" + SPUtils.get(MainActivity.this, "if_7", ""));//UA //支持获取手势焦点 sMm.requestFocusFromTouch(); //支持JS settings.setJavaScriptEnabled((Boolean) SPUtils.get(MainActivity.this, "if_1", true)); //支持插件 // settings.setPluginState(WebSettings.PluginState.ON); //设置适应屏幕 settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); //支持缩放 settings.setSupportZoom((Boolean) SPUtils.get(MainActivity.this, "if_3", false)); // 支持缩放 //隐藏原生的缩放控件 settings.setDisplayZoomControls(false); //支持内容重新布局 settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.supportMultipleWindows(); settings.setSupportMultipleWindows(false); //设置缓存模式 settings.setGeolocationEnabled((Boolean) SPUtils.get(MainActivity.this, "if_2", true));//允许地理位置可用 settings.setDomStorageEnabled(true); settings.setDatabaseEnabled((Boolean) SPUtils.get(MainActivity.this, "if_4", true)); settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setAppCacheEnabled(true); settings.setAppCachePath(sMm.getContext().getCacheDir().getAbsolutePath()); //settings.setRenderPriority(WebSettings.RenderPriority.HIGH); //提高渲染的优先级 //设置可访问文件 settings.setAllowFileAccess(true); //当webview调用requestFocus时为webview设置节点 settings.setNeedInitialFocus(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } settings.setLoadsImagesAutomatically(false); // settings.setNeedInitialFocus(true); //设置编码格式 //settings.setDefaultTextEncodingName("UTF-8"); }