List of usage examples for android.webkit WebView getSettings
public WebSettings getSettings()
From source file:cn.sharesdk.analysis.MobclickAgentJSInterface.java
public MobclickAgentJSInterface(Context paramContext, WebView paramWebView, WebChromeClient paramWebChromeClient) { this.context = paramContext; paramWebView.getSettings().setJavaScriptEnabled(true); paramWebView.setWebChromeClient(new StatisticsWebClient(paramWebChromeClient)); }
From source file:com.pixate.freestyle.viewdemo.ViewDetailFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from w ww . j av a 2 s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_view_detail, container, false); if (mItem != null) { // set the views ViewSample viewSample = mItem.getViewSample(); final ViewGroup viewsHolder = (ViewGroup) rootView.findViewById(R.id.holder); viewSample.createViews(getActivity(), viewsHolder); // load the CSS styling for the sample String css = ViewsData.getCSS(getActivity(), mItem); // Set up syntax highlighting WebView cssView = (WebView) rootView.findViewById(R.id.css_style); WebSettings s = cssView.getSettings(); s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); s.setUseWideViewPort(false); s.setAllowFileAccess(true); s.setBuiltInZoomControls(true); s.setSupportZoom(true); s.setSupportMultipleWindows(false); s.setJavaScriptEnabled(true); StringBuilder contentString = new StringBuilder(); contentString.append("<html><head>"); contentString.append( "<link href='file:///android_asset/prettify/prettify.css' rel='stylesheet' type='text/css'/> "); contentString.append( "<script src='file:///android_asset/prettify/prettify.js' type='text/javascript'></script> "); contentString.append( "<script src='file:///android_asset/prettify/lang-css.js' type='text/javascript'></script> "); contentString.append("</head><body onload='prettyPrint()'><code class='prettyprint lang-css'>"); contentString.append(TextUtils.htmlEncode(css).replaceAll("\n", "<br>").replaceAll(" ", " ") .replaceAll("\t", " ")); contentString.append("</code> </html> "); cssView.getSettings().setUseWideViewPort(true); cssView.loadDataWithBaseURL("file:///android_asset/prettify/", contentString.toString(), "text/html", StringUtil.EMPTY, StringUtil.EMPTY); // to aid in styling the css text shows in the textview, set its // ID. Eventually will not be needed. if (!"css-style".equals(PixateFreestyle.getStyleId(cssView))) { PixateFreestyle.setStyleId(cssView, "css-style", true); } // Style viewSample.style(css); } return rootView; }
From source file:de.nico.asura.activities.WebView1.java
private void openWebView() { setContentView(R.layout.webview);/* w ww .j a v a 2 s.com*/ final WebView webView = (WebView) findViewById(R.id.webView_main); WebSettings settings = webView.getSettings(); settings.setDomStorageEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(getString(R.string.menu_Web_1_url)); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(getResources().getBoolean(R.bool.menu_Web_1_js)); }
From source file:de.nico.asura.activities.WebView2.java
private void openWebView() { setContentView(R.layout.webview);/* w w w . j ava 2 s .c o m*/ final WebView webView = (WebView) findViewById(R.id.webView_main); WebSettings settings = webView.getSettings(); settings.setDomStorageEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(getString(R.string.menu_Web_2_url)); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(getResources().getBoolean(R.bool.menu_Web_2_js)); }
From source file:de.nico.asura.activities.WebView3.java
private void openWebView() { setContentView(R.layout.webview);/* www. j av a2 s . co m*/ final WebView webView = (WebView) findViewById(R.id.webView_main); WebSettings settings = webView.getSettings(); settings.setDomStorageEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(getString(R.string.menu_Web_3_url)); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(getResources().getBoolean(R.bool.menu_Web_3_js)); }
From source file:com.barcamppenang2014.tabfragment.AgendaFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.agenda, container, false); WebView agenda_wv = (WebView) v.findViewById(R.id.webview); NetworkAvailability network = new NetworkAvailability(); if (network.isNetworkAvalaible(getActivity().getApplicationContext())) { agenda_wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); agenda_wv.loadUrl("http://barcamppenang.org/agenda.html"); } else {/* w w w . j a v a2s. c o m*/ agenda_wv.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); agenda_wv.loadUrl("http://barcamppenang.org/agenda.html"); } return v; }
From source file:com.hhs.hfnavigator.slidingtabs.home.BusFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe); progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress); swipeRefreshLayout.setEnabled(false); final WebView webView = (WebView) root.findViewById(R.id.webView); if (webView != null) { webView.loadUrl("http://vqr.mx/DmkD"); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { progressWheel.stopSpinning(); swipeRefreshLayout.setRefreshing(false); webView.setVisibility(View.VISIBLE); }// w w w.j a va 2s . c o m }); } progressWheel.spin(); webView.setVisibility(View.INVISIBLE); // swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { // @Override // public void onRefresh() { // if (CheckNetwork.isInternetAvailable(getActivity())) { // webView.reload(); // } // } // }); // // swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, // android.R.color.holo_red_light, // android.R.color.holo_green_light, // android.R.color.holo_orange_light); return root; }
From source file:com.hhs.hfnavigator.slidingtabs.harbinger.SportsFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null); WebView webView = (WebView) root.findViewById(R.id.webView); if (webView != null) { webView.setWebViewClient(new WebViewClient()); webView.loadUrl("http://www.harbingernews.net/sports"); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setBuiltInZoomControls(true); }/*from w ww . j a va 2s . c o m*/ return root; }
From source file:com.barryku.android.boxnet.BrowseActivity.java
private void loadFolder(String folderId) { String browseUri = BOX_INTENT_SCHEME + "://" + BOX_INTENT_BROWSE + "/"; String uploadUri = BOX_INTENT_SCHEME + "://" + BOX_INTENT_UPLOAD + "/"; ;//www .jav a 2 s. c om String downloadUri = DOWNLOAD_URI + authToken + "/"; String homeUrl = browseUri + 0; if (folderId == null || folderId.equals("")) folderId = "0"; Log.d(LOG_TAG, "loading folder:" + folderId); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = prefs.edit(); editor.putString(LAST_VIEWED_FOLDER, folderId); editor.commit(); RestTemplate rest = RestUtil.getRestTemplate(); String requestUri = restUri + "get_account_tree¶ms[]=nozip¶ms[]=onelevel&folder_id={folderId}"; AccountTree response = rest.getForObject(requestUri, AccountTree.class, apiKey, authToken, folderId); //authToken expires at certain interval which will require authentication again if (!STATUS_LISTING_OK.equals(response.getStatus())) { Log.d(LOG_TAG, "authToken no longer works"); clearPreferences(prefs); } StringBuilder sb = new StringBuilder(); if (response == null) { sb.append("no data found"); } else { if (!"0".equals(folderId)) { sb.append("<a href=\"").append(homeUrl).append("\">").append("<img src=\"").append(IMG_HOME_URL) .append("\"> ").append("return to home").append("</a><br>"); } if (response.getFolders() != null) { for (FolderItem folder : response.getFolders()) { sb.append("<a href=\"").append(browseUri).append(folder.getId()).append("\">") .append("<img src=\"").append(IMG_FOLDER_URL).append("\"> ").append(folder.getName()) .append("</a><br>"); } } if (response.getFiles() != null) { for (FileItem file : response.getFiles()) { sb.append("<a href=\"").append(downloadUri).append(file.getId()).append("\">") .append(file.getName()).append("</a><br/>"); } } sb.append("<br/><br/><a href=\"").append(uploadUri).append(folderId).append("\">") .append("upload file ").append("<img src=\"").append(IMG_UPLOAD_URL).append("\"></a>"); final WebView detailResult = (WebView) findViewById(R.id.browseView); detailResult.getSettings().setBuiltInZoomControls(true); detailResult.loadDataWithBaseURL("fake://notused", "<html><body>" + sb.toString() + "</body></html>", "text/html", "UTF-8", ""); } }
From source file:com.gh4a.FileViewerActivity.java
private void fillData(boolean highlight) { String data = new String(EncodingUtils.fromBase64(mContent.getContent())); WebView webView = (WebView) findViewById(R.id.web_view); WebSettings s = webView.getSettings(); s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); s.setAllowFileAccess(true);// w w w . j av a 2s . c o m s.setBuiltInZoomControls(true); s.setLightTouchEnabled(true); s.setLoadsImagesAutomatically(true); s.setPluginsEnabled(false); s.setSupportZoom(true); s.setSupportMultipleWindows(true); s.setJavaScriptEnabled(true); s.setUseWideViewPort(true); webView.setWebViewClient(webViewClient); if (FileUtils.isImage(mName)) { String htmlImage = StringUtils.highlightImage( "https://github.com/" + mRepoOwner + "/" + mRepoName + "/raw/" + mRef + "/" + mPath); webView.loadDataWithBaseURL("file:///android_asset/", htmlImage, "text/html", "utf-8", ""); } else { String highlighted = StringUtils.highlightSyntax(data, highlight, mName); webView.loadDataWithBaseURL("file:///android_asset/", highlighted, "text/html", "utf-8", ""); } }