List of usage examples for android.webkit WebView getSettings
public WebSettings getSettings()
From source file:org.geometerplus.android.fbreader.network.auth.WebAuthorisationScreen.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_PROGRESS); SQLiteCookieDatabase.init(this); CookieSyncManager.createInstance(getApplicationContext()); CookieManager.getInstance().removeAllCookie(); final Intent intent = getIntent(); final Uri data = intent.getData(); if (data == null || data.getHost() == null) { finish();// w w w . j av a 2 s .c om return; } final String completeUrl = intent.getStringExtra(COMPLETE_URL_KEY); OrientationUtil.setOrientation(this, intent); final WebView view = new WebView(this); view.getSettings().setJavaScriptEnabled(true); view.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { setProgress(progress * 100); } }); view.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { setTitle(url); if (url != null && url.startsWith(completeUrl)) { final HashMap<String, String> cookies = new HashMap<String, String>(); final String cookieString = CookieManager.getInstance().getCookie(url); if (cookieString != null) { // cookieString is a string like NAME=VALUE [; NAME=VALUE] for (String pair : cookieString.split(";")) { final String[] parts = pair.split("=", 2); if (parts.length != 2) { continue; } cookies.put(parts[0].trim(), parts[1].trim()); } } storeCookies(data.getHost(), cookies); WebAuthorisationScreen.this.setResult(RESULT_OK); finish(); } } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.ECLAIR_MR1) { // hack for auth problem in android 2.1 handler.proceed(); } else { super.onReceivedSslError(view, handler, error); } } }); setContentView(view); view.loadUrl(intent.getDataString()); }
From source file:cn.sharesdk.analysis.MobclickAgentJSInterface.java
public MobclickAgentJSInterface(Context paramContext, WebView paramWebView) { this.context = paramContext; paramWebView.getSettings().setJavaScriptEnabled(true); paramWebView.setWebChromeClient(new StatisticsWebClient(null)); }
From source file:com.sim2dial.dialer.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.webaddres, container, false); TextView tv = (TextView) view.findViewById(R.id.textView1); tv.setText("About Us"); WebView web = (WebView) view.findViewById(R.id.webView1); if (getArguments() != null) { String abouturl = getArguments().getString("about"); web.getSettings().setJavaScriptEnabled(true); web.loadUrl(abouturl);/*ww w.j a v a 2 s .c o m*/ } return view; }
From source file:io.github.importre.android.chromeadb.OssLicenseFragment.java
private void setContents(View rootView) { String str;/*ww w. j a v a2s . co m*/ StringBuilder buf = new StringBuilder("<pre>"); try { InputStream is = getActivity().getAssets().open("LICENSE-2.0.txt"); BufferedReader in = new BufferedReader(new InputStreamReader(is)); while ((str = in.readLine()) != null) { buf.append(str + "<br />"); } in.close(); } catch (IOException e) { return; } WebView webView = (WebView) rootView.findViewById(R.id.webview); buf.append("</pre>"); String encoding = "utf-8"; WebSettings settings = webView.getSettings(); settings.setDefaultTextEncodingName(encoding); webView.loadDataWithBaseURL(null, buf.toString(), "text/html", encoding, null); }
From source file:com.hyperkode.friendshare.fragment.TwitterWebViewFragment.java
public void onResume() { super.onResume(); String url = null;//from w w w . j a v a2s .com FragmentManager fragmentManager = TwitterWebViewFragment.this.getActivity().getSupportFragmentManager(); Bundle args = this.getArguments(); if (args != null) { url = args.getString("URL"); loginFragment = (LoginFragment) fragmentManager.getFragment(args, "LoginFragment"); } WebView webView = (WebView) mThisActivity.findViewById(R.id.twitter_webview); WebSettings webSettings = webView.getSettings(); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(false); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains(getString(R.string.TWITTER_CALLBACK_URL))) { Uri uri = Uri.parse(url); String oauthVerifier = uri.getQueryParameter("oauth_verifier"); if (loginFragment != null) { loginFragment.setOAuthVerifierResult(oauthVerifier); } return true; } return false; } }); webView.loadUrl(url); }
From source file:de.uni_weimar.m18.anatomiederstadt.element.LatexFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_latex, container, false); WebView latexView = (WebView) root.findViewById(R.id.latexWebView); latexView.getSettings().setJavaScriptEnabled(true); latexView.getSettings().setBuiltInZoomControls(false); TypedValue typedValue = new TypedValue(); Resources.Theme theme = getActivity().getTheme(); theme.resolveAttribute(R.color.windowBackgroundColor, typedValue, true); latexView.setBackgroundColor(typedValue.data); latexView.loadDataWithBaseURL("http://bar", "<script type='text/x-mathjax-config'>" + "MathJax.Hub.Config({ " + "messageStyle: 'none'," + "showMathMenu: false, " + "jax: ['input/TeX','output/HTML-CSS'], " + "extensions: ['tex2jax.js'], " + "TeX: { extensions: ['AMSmath.js','AMSsymbols.js'," + "'noErrors.js','noUndefined.js'] } " + "});</script>" + "<script type='text/javascript' " + "src='file:///android_asset/MathJax/MathJax.js'" + "></script><span id='math'></span>", "text/html", "utf-8", ""); Log.v(LOG_TAG, "Loading latexCode: " + mLatexCode); latexView.setWebViewClient(new WebViewClient() { private String mLatexCode = null; @Override/*from ww w. j a va 2 s. c o m*/ public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (Build.VERSION.SDK_INT < 19) { view.loadUrl("javascript:document.getElementById('math').innerHTML='\\\\[" + doubleEscapeTeX(getLatexCode()) + "\\\\]'"); view.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);"); } else { view.evaluateJavascript("javascript:document.getElementById('math').innerHTML='\\\\[" + doubleEscapeTeX(getLatexCode()) + "\\\\]'", null); view.evaluateJavascript("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);", null); } } }); return root; }
From source file:net.meiolania.apps.habrahabr.fragments.companies.CompaniesShowFragment.java
@Override public void onLoadFinished(Loader<CompanyFullData> loader, CompanyFullData data) { SherlockFragmentActivity activity = getSherlockActivity(); if (activity != null) { TextView date = (TextView) activity.findViewById(R.id.company_date); date.setText(data.getDate());//w w w . j a v a 2s . c om TextView site = (TextView) activity.findViewById(R.id.company_site); site.setText(data.getCompanyUrl()); TextView industries = (TextView) activity.findViewById(R.id.company_industries); industries.setText(data.getIndustries()); TextView location = (TextView) activity.findViewById(R.id.company_location); location.setText(data.getLocation()); TextView quantity = (TextView) activity.findViewById(R.id.company_quantity); quantity.setText(data.getQuantity()); WebView summary = (WebView) activity.findViewById(R.id.company_summary); summary.getSettings().setSupportZoom(true); summary.loadDataWithBaseURL("", data.getSummary(), "text/html", "UTF-8", null); WebView management = (WebView) activity.findViewById(R.id.company_management); management.getSettings().setSupportZoom(true); management.loadDataWithBaseURL("", data.getManagement(), "text/html", "UTF-8", null); WebView developmentStages = (WebView) activity.findViewById(R.id.company_development_stages); developmentStages.getSettings().setSupportZoom(true); developmentStages.loadDataWithBaseURL("", data.getDevelopmentStages(), "text/html", "UTF-8", null); } hideProgressDialog(); }
From source file:io.vit.vitio.Fragments.CampusMapFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.campusmap_fragment, container, false); setTransitions();// w ww. j a v a2 s .c o m WebView view = (WebView) rootView.findViewById(R.id.img_map); view.setVisibility(View.GONE); view.getSettings().setBuiltInZoomControls(true); view.getSettings().setDisplayZoomControls(false); view.getSettings().setLoadWithOverviewMode(true); view.getSettings().setUseWideViewPort(true); view.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); try { view.setVisibility(View.VISIBLE); } catch (Exception ignore) { } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { try { } catch (Exception ignore) { } } }); view.loadUrl("file:///android_asset/vit_map.jpg"); return rootView; }
From source file:com.todoroo.astrid.taskrabbit.TaskRabbitOAuthLoginActivity.java
@SuppressWarnings("nls") @Override// w ww. ja v a 2 s . c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DependencyInjectionService.getInstance().inject(this); setContentView(R.layout.oauth_login_activity); getSupportActionBar().setTitle(R.string.actfm_OLA_prompt); final String urlParam = getIntent().getStringExtra(URL_TOKEN); final WebView webView = (WebView) findViewById(R.id.browser); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setSavePassword(false); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setSupportZoom(true); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { System.err.println("hey error. " + errorCode + ": " + description); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("?client_id=") && (url.lastIndexOf("?client_id=") != url.indexOf("?client_id="))) { String redirectUrl = url.substring(0, url.lastIndexOf("?client_id=")); webView.loadUrl(redirectUrl); return true; } return super.shouldOverrideUrlLoading(view, url); } @Override public void onLoadResource(WebView view, String url) { super.onLoadResource(view, url); } @Override public void onPageFinished(WebView view, final String url) { super.onPageFinished(view, url); pd.dismiss(); if (url.contains("access_token=")) { String token = url.substring(url.indexOf("access_token="), url.length()); Intent intent = new Intent(); intent.putExtra(DATA_RESPONSE, token); setResult(RESULT_OK, intent); finish(); } } }); pd = DialogUtilities.progressDialog(this, getString(R.string.DLG_wait)); webView.loadUrl(urlParam); }
From source file:net.toload.main.hd.ui.NewsDialog.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) { getDialog().getWindow().setTitle(getResources().getString(R.string.action_news)); mLIMEPref = new LIMEPreferenceManager(getActivity()); view = inflater.inflate(R.layout.fragment_dialog_news, container, false); String html_value = mLIMEPref.getParameterString(Lime.LIME_NEWS_CONTENT, ""); if (!html_value.isEmpty()) { WebView newsContentArea = (WebView) view.findViewById(R.id.newsContentArea); newsContentArea.getSettings().setJavaScriptEnabled(true); newsContentArea.loadData(html_value, "text/html", "UTF-8"); }//from w w w . j a v a 2 s . com btnHelpDialog = (Button) view.findViewById(R.id.btnNewsDialog); btnHelpDialog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); return view; }