Java Code Examples for android.webkit.WebSettings#setSupportZoom()
The following examples show how to use
android.webkit.WebSettings#setSupportZoom() .
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: LoginActivity.java From Loop with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); ButterKnife.bind(this); vimeoService = ServiceGenerator.createService( VimeoService.class, VimeoService.BASE_URL, new UnauthorizedNetworkInterceptor(this)); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setLoadWithOverviewMode(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setUseWideViewPort(true); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setWebViewClient(webViewClient); webView.loadUrl(setUpUrl()); }
Example 2
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 3
Source File: PrettifyWebView.java From mvvm-template with GNU General Public License v3.0 | 6 votes |
public void loadImage(@NonNull String url, boolean isSvg) { WebSettings settings = getSettings(); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); String html; if (isSvg) { html = url; } else { html = "<html><head><style>img{display: inline; height: auto; max-width: 100%;}</style></head><body>" + "<img src=\"" + url + "\"/></body></html>"; } Logger.e(html); loadData(html, "text/html", null); }
Example 4
Source File: GankWebActivity.java From Gank-Veaer with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mUrl = getIntent().getStringExtra("feed_url"); mTitle = getIntent().getStringExtra("feed_title"); mToolbar.setTitle(mTitle); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setLoadWithOverviewMode(true); settings.setAppCacheEnabled(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setSupportZoom(true); settings.setDomStorageEnabled(true); mWebView.setWebChromeClient(new ChromeClient()); mWebView.setWebViewClient(new LoveClient()); mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mWebView.loadUrl(mUrl); }
Example 5
Source File: ArticleInfoDetailFragment.java From travelguide with Apache License 2.0 | 6 votes |
@Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); // Fix java.lang.NullPointerException at: // android.view.animation.AnimationUtils.loadAnimation(AnimationUtils.java:71) final Context context = getActivity(); if (shouldAnimate(url, context)) { Utils.fadeOut(context, mProgressContainer); Utils.fadeIn(context, mWebView); } // If picture enable zoom, else disable final WebSettings ws = mWebView.getSettings(); final boolean isPicture = Utils.isPictUrl(url); ws.setBuiltInZoomControls(isPicture); ws.setSupportZoom(isPicture); ws.setLoadWithOverviewMode(isPicture); ws.setLayoutAlgorithm(isPicture ? LayoutAlgorithm.SINGLE_COLUMN : LayoutAlgorithm.NARROW_COLUMNS); ws.setUseWideViewPort(isPicture); }
Example 6
Source File: WebViewActivity.java From V2EX with GNU General Public License v3.0 | 6 votes |
@SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.act_web_view); mWebView = find(R.id.webView); mWebView.setNetworkAvailable(true); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(true); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); mWebView.loadUrl(getIntent().getStringExtra("url")); }
Example 7
Source File: GraphView.java From commcare-android with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) public WebView getView(String html) { if (BuildConfig.DEBUG) { WebView.setWebContentsDebuggingEnabled(true); } WebView webView = new GraphWebView(mContext); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); webView.setClickable(true); webView.setFocusable(false); webView.setFocusableInTouchMode(false); settings.setBuiltInZoomControls(mIsFullScreen); settings.setSupportZoom(mIsFullScreen); settings.setDisplayZoomControls(mIsFullScreen); // Improve performance settings.setCacheMode(WebSettings.LOAD_NO_CACHE); this.myHTML = html; webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null); return webView; }
Example 8
Source File: WebViewActivity.java From Aria2App with GNU General Public License v3.0 | 5 votes |
private void toggleDesktopMode(boolean enabled) { WebSettings settings = web.getSettings(); settings.setLoadWithOverviewMode(enabled); settings.setUseWideViewPort(enabled); settings.setSupportZoom(enabled); settings.setBuiltInZoomControls(enabled); settings.setDisplayZoomControls(!enabled); String userAgent = enabled ? "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0" : WebSettings.getDefaultUserAgent(this); userAgent += " Aria2App/" + BuildConfig.VERSION_NAME + "-" + BuildConfig.FLAVOR; settings.setUserAgentString(userAgent); }
Example 9
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); setContentEmpty(false); setContentShown(true); View view = getContentView(); webView = (WebView) view.findViewById(R.id.webview); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setLoadsImagesAutomatically(true); webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); webSettings.setDisplayZoomControls(false); SharedPreferences preferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE); String OAuth = preferences.getString(getString(R.string.login_sp_oauth), null); client = new GitHubClient(); client.setOAuth2Token(OAuth); Intent intent = getActivity().getIntent(); owner = intent.getStringExtra(getString(R.string.webview_intent_owner)); name = intent.getStringExtra(getString(R.string.webview_intent_name)); sha = intent.getStringExtra(getString(R.string.webview_intent_sha)); filename = intent.getStringExtra(getString(R.string.webview_intent_title)); task = new WebViewTask(WebViewFragment.this); task.execute(); }
Example 10
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 11
Source File: FirstActivity.java From YCShopDetailLayout with Apache License 2.0 | 5 votes |
@SuppressLint({"ObsoleteSdkInt", "SetJavaScriptEnabled"}) private void initWebView() { final WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setUseWideViewPort(true); settings.setDomStorageEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) { new Object() { void setLoadWithOverviewMode(boolean overview) { settings.setLoadWithOverviewMode(overview); } }.setLoadWithOverviewMode(true); } settings.setCacheMode(WebSettings.LOAD_DEFAULT); getWindow().getDecorView().post(new Runnable() { @Override public void run() { webView.loadUrl("https://www.jianshu.com/p/d745ea0cb5bd"); } }); }
Example 12
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 13
Source File: HTMLViewerActivity.java From BonjourBrowser with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_html_viewer); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } mWebView = findViewById(R.id.webview); mLoading = findViewById(R.id.loading); mWebView.setWebChromeClient(new ChromeClient()); mWebView.setWebViewClient(new ViewClient()); WebSettings s = mWebView.getSettings(); s.setUseWideViewPort(true); s.setSupportZoom(true); s.setBuiltInZoomControls(true); s.setDisplayZoomControls(false); s.setSavePassword(false); s.setSaveFormData(false); s.setBlockNetworkLoads(true); // Javascript is purposely disabled, so that nothing can be // automatically run. s.setJavaScriptEnabled(false); s.setDefaultTextEncodingName("utf-8"); final Intent intent = getIntent(); if (intent.hasExtra(Intent.EXTRA_TITLE)) { setTitle(intent.getStringExtra(Intent.EXTRA_TITLE)); } mWebView.loadUrl(String.valueOf(intent.getData())); }
Example 14
Source File: WebActivity.java From TouchNews with Apache License 2.0 | 5 votes |
private void setWebView() { WebSettings settings = mWebView.getSettings(); settings.setSupportZoom(true); //支持缩放 settings.setBlockNetworkImage(true); //设置图片最后加载 // settings.setBlockNetworkLoads ( true ); // settings.setDomStorageEnabled ( true ); settings.setDatabaseEnabled(true); // String cacheDirPath = mContext.getFilesDir ( ).getAbsolutePath()+ CacheUtil.WEB_CACAH_DIRNAME; //缓存 // settings.setAppCachePath ( ); settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); settings.setAppCacheEnabled(true); // settings.setAppCachePath ( cacheDirPath ); // settings.setBuiltInZoomControls ( true ); //启用内置缩放装置 settings.setJavaScriptEnabled(true); //启用JS脚本 /* mWebView.setOnKeyListener ( new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) { mWebView.goBack(); //后退 return true; } } return false; } });*/ }
Example 15
Source File: PKDialog.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void d() { n.setVerticalScrollBarEnabled(false); n.setHorizontalScrollBarEnabled(false); n.setWebViewClient(new e(this, null)); n.setWebChromeClient(mChromeClient); n.clearFormData(); WebSettings websettings = n.getSettings(); websettings.setSavePassword(false); websettings.setSaveFormData(false); websettings.setCacheMode(-1); websettings.setNeedInitialFocus(false); websettings.setBuiltInZoomControls(true); websettings.setSupportZoom(true); websettings.setRenderPriority(android.webkit.WebSettings.RenderPriority.HIGH); websettings.setJavaScriptEnabled(true); if (o != null && o.get() != null) { websettings.setDatabaseEnabled(true); websettings.setDatabasePath(((Context)o.get()).getApplicationContext().getDir("databases", 0).getPath()); } websettings.setDomStorageEnabled(true); jsBridge.a(new f(this, null), "sdk_js_if"); n.clearView(); n.loadUrl(i); n.getSettings().setSavePassword(false); }
Example 16
Source File: PrettifyWebView.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
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); } }
Example 17
Source File: MainActivity.java From SlimSocial-for-Facebook with GNU General Public License v2.0 | 4 votes |
private void SetupWebView() { webViewFacebook = findViewById(webView); webViewFacebook.setListener(this, this); webViewFacebook.clearPermittedHostnames(); webViewFacebook.addPermittedHostname("facebook.com"); webViewFacebook.addPermittedHostname("fbcdn.net"); webViewFacebook.addPermittedHostname("fb.com"); webViewFacebook.addPermittedHostname("fb.me"); /* webViewFacebook.addPermittedHostname("m.facebook.com"); webViewFacebook.addPermittedHostname("h.facebook.com"); webViewFacebook.addPermittedHostname("touch.facebook.com"); webViewFacebook.addPermittedHostname("mbasic.facebook.com"); webViewFacebook.addPermittedHostname("touch.facebook.com"); webViewFacebook.addPermittedHostname("messenger.com"); */ webViewFacebook.requestFocus(View.FOCUS_DOWN); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);//remove the keyboard issue WebSettings settings = webViewFacebook.getSettings(); webViewFacebook.setDesktopMode(true); settings.setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); settings.setJavaScriptEnabled(true); //set text zoom int zoom = Integer.parseInt(savedPreferences.getString("pref_textSize", "100")); settings.setTextZoom(zoom); //set Geolocation settings.setGeolocationEnabled(savedPreferences.getBoolean("pref_allowGeolocation", true)); // Use WideViewport and Zoom out if there is no viewport defined settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); // better image sizing support settings.setSupportZoom(true); settings.setDisplayZoomControls(false); settings.setBuiltInZoomControls(true); // set caching settings.setAppCachePath(getCacheDir().getAbsolutePath()); settings.setAppCacheEnabled(true); settings.setLoadsImagesAutomatically(!savedPreferences.getBoolean("pref_doNotDownloadImages", false));//to save data settings.setDisplayZoomControls(false); }
Example 18
Source File: AppUtils.java From materialistic with Apache License 2.0 | 4 votes |
public static void toggleWebViewZoom(WebSettings webSettings, boolean enabled) { webSettings.setSupportZoom(enabled); webSettings.setBuiltInZoomControls(enabled); webSettings.setDisplayZoomControls(false); }
Example 19
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 20
Source File: KCWebView.java From kerkee_android with GNU General Public License v3.0 | 4 votes |
/** * @param aWebView * **/ public static void setupWebViewAttributes(KCWebView aWebView) { try { WebSettings webSettings = aWebView.getSettings(); setCustomizedUA(webSettings); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } webSettings.setJavaScriptEnabled(true); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); webSettings.setBuiltInZoomControls(false); webSettings.setSupportZoom(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setAppCachePath(aWebView.getWebPath().getRootPath() + "/webcache"); webSettings.setAppCacheEnabled(true); // webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setLoadsImagesAutomatically(true); webSettings.setLightTouchEnabled(false); webSettings.setDomStorageEnabled(true); // supports local storage webSettings.setDatabaseEnabled(true); // supports local storage webSettings.setDatabasePath(aWebView.getWebPath().getRootPath() + "/localstorage"); // we are using ApplicationContext when creaing KCWebView, without disabling the "Save Password" dialog // there will be an exception that would cause crash: "Unable to add window -- token null is not for an application" webSettings.setSavePassword(false); aWebView.setHorizontalScrollBarEnabled(false); // mWebView.setVerticalScrollBarEnabled(false); aWebView.setScrollbarFadingEnabled(true); aWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); } catch (Exception e) { KCLog.e(e); } }