List of usage examples for android.webkit WebView getSettings
public WebSettings getSettings()
From source file:com.example.prasadnr.traquad.TraQuad.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tra_quad); ConnectivityManager connManager = (ConnectivityManager) getSystemService(TraQuad.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); Builder alert = new AlertDialog.Builder(TraQuad.this); WifiManager managerWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); Method[] wmMethods = managerWifi.getClass().getDeclaredMethods(); for (Method method : wmMethods) { if (method.getName().equals("isWifiApEnabled")) { try { isWifiAPenabled = (boolean) method.invoke(managerWifi); } catch (IllegalArgumentException e) { e.printStackTrace();//www. j ava 2 s. c o m } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } final ProgressDialog pDialog; MediaController mediaController = new MediaController(this); pDialog = new ProgressDialog(TraQuad.this); pDialog.setTitle("TraQuad app (Connecting...)"); pDialog.setMessage("Buffering...Please wait..."); pDialog.setCancelable(true); if (!isWifiAPenabled) { alert.setTitle("WiFi Hotspot Settings"); alert.setMessage("Can you please connect WiFi-hotspot?"); alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { irritation = true; startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); pDialog.show(); } }); alert.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //Dismiss AlertDialog pDialog.show(); Toast.makeText(getApplicationContext(), "Please connect your WiFi!", Toast.LENGTH_LONG).show(); } }); alert.setCancelable(false); AlertDialog alertDialog = alert.create(); alertDialog.show(); } WebView webView = (WebView) findViewById(R.id.webView); if (irritation == true | isWifiAPenabled) { pDialog.show(); } mediaController.setAnchorView(webView); mediaController.setVisibility(View.GONE); extra = getIntent().getStringExtra("VideosId"); webView = (WebView) findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setPluginState(WebSettings.PluginState.ON); final GlobalClass globalVariable = (GlobalClass) getApplicationContext(); final String IPaddressNew = globalVariable.getIP(); final String httpString = "http://"; final String commandPort = String.valueOf(1500); final String streamPort = String.valueOf(8080); final String IPaddressStream = httpString + IPaddressNew + ":" + streamPort; final String IPaddressCommand = httpString + IPaddressNew + ":" + commandPort; TextView sendCharacter = (TextView) findViewById(R.id.sendCharacter); try { webView.loadUrl(IPaddressStream); } catch (Exception e) { Toast.makeText(getApplicationContext(), IPaddressNew + ":Error!", Toast.LENGTH_LONG).show(); } webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { pDialog.dismiss(); } }); final Button switchact = (Button) findViewById(R.id.btn2); switchact.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent act1 = new Intent(view.getContext(), Joypad.class); startActivity(act1); } }); final Button hometraquad = (Button) findViewById(R.id.button5); hometraquad.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent acthometraquad = new Intent(TraQuad.this, MainActivity.class); startActivity(acthometraquad); } }); }
From source file:ca.bitwit.postcard.PostcardAdaptor.java
/** * Cordova Plugin Overrides/*from w w w.j av a2 s .c o m*/ */ public PostcardAdaptor(Activity activity, WebView webView) { Log.d("PostcardApplication", "Initialized"); NetworksManager.INSTANCE.adaptor = this; this.activity = activity; this.webView = webView; Context context = activity.getApplicationContext(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webView.addJavascriptInterface(this, "PostcardApplication"); webView.loadUrl("file:///android_asset/www/index.html"); this.properties = new Properties(); String propFileName = "postcard.properties"; try { InputStream inputStream = context.getAssets().open(propFileName); if (inputStream != null) { this.properties.load(inputStream); } else { throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); } } catch (IOException e) { e.printStackTrace(); } this.networkAccountDataSource = new NetworkAccountDataSource(context); this.networkAccountDataSource.open(); this.personDataSource = new PersonDataSource(context); this.personDataSource.open(); this.tagDataSource = new TagDataSource(context); this.tagDataSource.open(); }
From source file:com.github.akinaru.hcidebugger.activity.DescriptionActivity.java
protected void onCreate(Bundle savedInstanceState) { setLayout(R.layout.description_activity); super.onCreate(savedInstanceState); //setup navigation items setupDrawerContent(nvDrawer);//from ww w . ja v a2 s . c o m //hide max packet count for this activity nvDrawer.getMenu().findItem(R.id.set_max_packet_num).setVisible(false); nvDrawer.getMenu().findItem(R.id.browse_file).setVisible(false); nvDrawer.getMenu().findItem(R.id.change_settings).setVisible(false); //get information sent via intent to be displayed String hciPacket = getIntent().getExtras().getString(Constants.INTENT_HCI_PACKET); String snoopPacket = getIntent().getExtras().getString(Constants.INTENT_SNOOP_PACKET); int packetNumber = getIntent().getExtras().getInt(Constants.INTENT_PACKET_NUMBER); String ts = getIntent().getExtras().getString(Constants.INTENT_PACKET_TS); String packet_type = getIntent().getExtras().getString(Constants.INTENT_PACKET_TYPE); String destination = getIntent().getExtras().getString(Constants.INTENT_PACKET_DEST); //setup description item table tablelayout = (TableLayout) findViewById(R.id.tablelayout); altTableRow(2); //setup json highlishter web page WebView lWebView = (WebView) findViewById(R.id.webView); TextView number_value = (TextView) findViewById(R.id.number_value); TextView ts_value = (TextView) findViewById(R.id.ts_value); TextView packet_type_value = (TextView) findViewById(R.id.packet_type_value); TextView destination_value = (TextView) findViewById(R.id.dest_value); number_value.setText("" + packetNumber); ts_value.setText(ts); packet_type_value.setText(packet_type); destination_value.setText(destination); WebSettings webSettings = lWebView.getSettings(); webSettings.setJavaScriptEnabled(true); int spacesToIndentEachLevel = 2; String beautify = "{}"; try { beautify = new JSONObject(hciPacket).toString(spacesToIndentEachLevel); } catch (JSONException e) { e.printStackTrace(); } String html = "<HTML><HEAD><link rel=\"stylesheet\" href=\"styles.css\">" + "<script src=\"highlight.js\"></script>" + "<script>hljs.initHighlightingOnLoad();</script>" + "</HEAD><body>" + "<pre><code class=\"json\">" + beautify + "</code></pre>" + "</body></HTML>"; lWebView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null); }
From source file:com.bayapps.android.robophish.ui.MediaBrowserFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LogHelper.d(TAG, "fragment.onCreateView"); View rootView;/*w w w. j a va2 s . c o m*/ String mediaId = getMediaId(); ListView listView; if (mediaId != null && MediaIDHelper.isShow(mediaId)) { setHasOptionsMenu(true); //show option to download rootView = inflater.inflate(R.layout.fragment_list_show, container, false); ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.viewpager); viewPager.setAdapter(new ShowPagerAdapter(inflater, rootView)); viewPager.setOffscreenPageLimit(3); TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.sliding_tabs); tabLayout.setupWithViewPager(viewPager); final WebView setlist = (WebView) rootView.findViewById(R.id.setlist_webview); setlist.getSettings().setJavaScriptEnabled(true); AsyncHttpClient setlistClient = new AsyncHttpClient(); RequestParams setlistParams = new RequestParams(); setlistParams.put("api", "2.0"); setlistParams.put("method", "pnet.shows.setlists.get"); setlistParams.put("showdate", getSubTitle()); setlistParams.put("apikey", "C01AEE2002E80723E9E7"); setlistParams.put("format", "json"); setlistClient.get("http://api.phish.net/api.js", setlistParams, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONArray response) { super.onSuccess(statusCode, headers, response); try { JSONObject result = response.getJSONObject(0); String city = result.getString("city"); String state = result.getString("state"); String country = result.getString("country"); String venue = result.getString("venue"); String header = "<h1>" + venue + "</h1>" + "<h2>" + city + ", " + state + "<br/>" + country + "</h2>"; String setlistdata = result.getString("setlistdata"); String setlistnotes = result.getString("setlistnotes"); setlist.loadData(header + setlistdata + setlistnotes, "text/html", null); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); } }); final WebView reviews = (WebView) rootView.findViewById(R.id.reviews_webview); reviews.getSettings().setJavaScriptEnabled(true); AsyncHttpClient reviewsClient = new AsyncHttpClient(); RequestParams reviewsParams = new RequestParams(); reviewsParams.put("api", "2.0"); reviewsParams.put("method", "pnet.reviews.query"); reviewsParams.put("showdate", getSubTitle()); reviewsParams.put("apikey", "C01AEE2002E80723E9E7"); reviewsParams.put("format", "json"); reviewsClient.get("http://api.phish.net/api.js", reviewsParams, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONArray response) { super.onSuccess(statusCode, headers, response); try { String display = ""; int len = response.length(); for (int i = 0; i < len; i++) { JSONObject entry = response.getJSONObject(i); String author = entry.getString("author"); String review = entry.getString("review"); String tstamp = entry.getString("tstamp"); Date reviewTime = new Date(Long.parseLong(tstamp) * 1000); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String reviewDate = dateFormat.format(reviewTime); String reviewSubs = review.replaceAll("\n", "<br/>"); display += "<h2>" + author + "</h2>" + "<h4>" + reviewDate + "</h4>"; display += reviewSubs + "<br/>"; } reviews.loadData(display, "text/html", null); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); } }); final WebView tapernotesWebview = (WebView) rootView.findViewById(R.id.tapernotes_webview); tapernotesWebview.getSettings().setJavaScriptEnabled(true); String showId = extractShowFromMediaID(mediaId); final AsyncHttpClient tapernotesClient = new AsyncHttpClient(); tapernotesClient.get("http://phish.in/api/v1/shows/" + showId + ".json", null, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); try { mShowData = response; JSONObject data = response.getJSONObject("data"); String tapernotes = data.getString("taper_notes"); if (tapernotes.equals("null")) tapernotes = "Not available"; String notesSubs = tapernotes.replaceAll("\n", "<br/>"); tapernotesWebview.loadData(notesSubs, "text/html", null); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); } }); } else { rootView = inflater.inflate(R.layout.fragment_list, container, false); } mErrorView = rootView.findViewById(R.id.playback_error); mErrorMessage = (TextView) mErrorView.findViewById(R.id.error_message); mBrowserAdapter = new BrowseAdapter(getActivity()); listView = (ListView) rootView.findViewById(R.id.list_view); listView.setAdapter(mBrowserAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { checkForUserVisibleErrors(false); MediaBrowserCompat.MediaItem item = mBrowserAdapter.getItem(position); mMediaFragmentListener.onMediaItemSelected(item); } }); return rootView; }
From source file:org.sufficientlysecure.keychain.ui.linked.LinkedIdCreateGithubFragment.java
public void oAuthRequest(String hostAndPath, String clientId, String scope) { Activity activity = getActivity();/*www. java 2s .c o m*/ if (activity == null) { return; } byte[] buf = new byte[16]; new Random().nextBytes(buf); mOAuthState = new String(Hex.encode(buf)); mOAuthCode = null; final Dialog auth_dialog = new Dialog(activity); auth_dialog.setContentView(R.layout.oauth_webview); WebView web = (WebView) auth_dialog.findViewById(R.id.web_view); web.getSettings().setSaveFormData(false); web.getSettings().setUserAgentString("OpenKeychain " + BuildConfig.VERSION_NAME); web.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri = Uri.parse(url); if ("oauth-openkeychain".equals(uri.getScheme())) { if (mOAuthCode != null) { return true; } if (uri.getQueryParameter("error") != null) { Log.i(Constants.TAG, "got oauth error: " + uri.getQueryParameter("error")); auth_dialog.dismiss(); return true; } // check if mOAuthState == queryParam[state] mOAuthCode = uri.getQueryParameter("code"); auth_dialog.dismiss(); return true; } // don't surf away from github! if (!"github.com".equals(uri.getHost())) { auth_dialog.dismiss(); return true; } return false; } }); auth_dialog.setTitle(R.string.linked_webview_title_github); auth_dialog.setCancelable(true); auth_dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { step1GetOAuthToken(); } }); auth_dialog.show(); web.loadUrl("https://" + hostAndPath + "?client_id=" + clientId + "&scope=" + scope + "&redirect_uri=oauth-openkeychain://linked/" + "&state=" + mOAuthState); }
From source file:com.sourcey.materiallogindemo.MainActivity.java
private void DialogMap() { View dialogBoxView = View.inflate(this, R.layout.activity_map, null); final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView); String url = getString(R.string.url_map) + "index.php?poinFrom=" + txtStart.getText().toString().trim() + "&poinTo=" + txtEnd.getText().toString().trim(); map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);/*from w ww. j a va 2 s . c om*/ AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("Map"); builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false) .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }
From source file:com.near.chimerarevo.fragments.PostFragment.java
@SuppressLint("SetJavaScriptEnabled") private void addWebObject(String width, String height, String url) { WebView wv = new WebView(getActivity()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); wv.setLayoutParams(params);//from w ww.j a v a 2 s. co m wv.getSettings().setUseWideViewPort(true); wv.getSettings().setLoadWithOverviewMode(true); wv.getSettings().setSupportZoom(false); wv.setVerticalScrollBarEnabled(true); wv.setHorizontalScrollBarEnabled(true); wv.getSettings().setJavaScriptEnabled(true); wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); wv.setWebViewClient(new WebViewClient()); String frame = "<iframe width=\"" + width + "\" height=\"" + height + "\" frameborder=\"0\" src=\"" + url + "\"/>"; wv.loadDataWithBaseURL(url, frame, "html/plain", "UTF-8", null); lay.addView(wv); }
From source file:com.facebook.react.views.webview.ReactWebViewManager.java
@ReactProp(name = "allowUniversalAccessFromFileURLs") public void setAllowUniversalAccessFromFileURLs(WebView view, boolean allow) { view.getSettings().setAllowUniversalAccessFromFileURLs(allow); }
From source file:com.facebook.react.views.webview.ReactWebViewManager.java
@ReactProp(name = "javaScriptEnabled") public void setJavaScriptEnabled(WebView view, boolean enabled) { view.getSettings().setJavaScriptEnabled(enabled); }
From source file:com.facebook.react.views.webview.ReactWebViewManager.java
@ReactProp(name = "scalesPageToFit") public void setScalesPageToFit(WebView view, boolean enabled) { view.getSettings().setUseWideViewPort(!enabled); }