List of usage examples for android.webkit WebView getSettings
public WebSettings getSettings()
From source file:com.userhook.view.UHMessageView.java
protected void loadWebViewContent(String html) { WebView webView = new WebView(getContext()); webView.setWebViewClient(new MessageWebViewClient()); webView.getSettings().setJavaScriptEnabled(true); // find dialog width in pixels final float scale = getResources().getDisplayMetrics().density; int width = (int) (dialogWidth * scale); LayoutParams layoutParams = new LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.addRule(CENTER_IN_PARENT); addView(webView, layoutParams);/*from w w w . j a v a2s .c om*/ webView.loadData(html, "text/html", "utf-8"); contentView = webView; contentLoaded = true; }
From source file:com.hhs.hfnavigator.slidingtabs.schedules.MidRegFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null); progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe); swipeRefreshLayout.setEnabled(false); progressWheel.spin();//from w ww.j a v a 2 s . co m final WebView webView = (WebView) root.findViewById(R.id.webView); if (webView != null) { webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { progressWheel.stopSpinning(); } }); webView.loadUrl("https://docs.google.com/document/d/1FEFRSCql8AXKBsVoiawX9E087oaPbcQh-f-Ou4yKaIE/pub"); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); } return root; }
From source file:com.hhs.hfnavigator.slidingtabs.home.PollsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null); progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe); swipeRefreshLayout.setEnabled(false); progressWheel.spin();//from ww w . j av a 2 s.c om final WebView webView = (WebView) root.findViewById(R.id.webView); if (webView != null) { webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { progressWheel.stopSpinning(); } }); webView.loadUrl("https://docs.google.com/document/d/1Y8c9GwN0nkRBRHau1SCRrvAmRK1LQiV7Omn13KsMMqc/pub"); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); } return root; }
From source file:com.devspark.sidenavigation.meiriyiwen.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); icon = (ImageView) findViewById(android.R.id.icon); sideNavigationView = (SideNavigationView) findViewById(R.id.side_navigation_view); sideNavigationView.setMenuItems(R.menu.side_navigation_menu); sideNavigationView.setMenuClickCallback(this); if (getIntent().hasExtra(EXTRA_TITLE)) { String title = getIntent().getStringExtra(EXTRA_TITLE); int resId = getIntent().getIntExtra(EXTRA_RESOURCE_ID, 0); setTitle(title);/*ww w. j ava 2 s. co m*/ icon.setImageResource(resId); sideNavigationView.setMode(getIntent().getIntExtra(EXTRA_MODE, 0) == 0 ? Mode.LEFT : Mode.RIGHT); } StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites() .detectNetwork().penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); { String title = "http://meiriyiwen.com/index/mobile"; //setTitle(title); WebView uiwebview = (WebView) findViewById(R.id.meiriyiwenWeb); uiwebview.setBackgroundColor(Color.BLACK); uiwebview.setWebViewClient(new Callback()); uiwebview.getSettings().setBuiltInZoomControls(true); uiwebview.getSettings().setJavaScriptEnabled(true); uiwebview.loadUrl(title); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:com.blogspot.holbohistorier.readonfree.BookView.java
@Override public void onActivityCreated(Bundle saved) { super.onActivityCreated(saved); view = (WebView) getView().findViewById(R.id.Viewport); // enable JavaScript for cool things to happen! view.getSettings().setJavaScriptEnabled(true); // ----- SWIPE PAGE view.setOnTouchListener(new OnTouchListener() { @Override//w w w. ja v a 2s . c om public boolean onTouch(View v, MotionEvent event) { if (state == ViewStateEnum.books) swipePage(v, event, 0); WebView view = (WebView) v; return view.onTouchEvent(event); } }); // ----- NOTE & LINK view.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Message msg = new Message(); msg.setTarget(new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); String url = msg.getData().getString(getString(R.string.url)); if (url != null) navigator.setNote(url, index); } }); view.requestFocusNodeHref(msg); return false; } }); view.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { try { navigator.setBookPage(url, index); } catch (Exception e) { errorMessage(getString(R.string.error_LoadPage)); } return true; } }); loadPage(viewedPage); }
From source file:com.work.nishant.publicchannel.StartHere.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from w w w . j av a 2 s.c o m*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_editProfile) { Intent it = new Intent(StartHere.this, Profile.class); startActivity(it); } else if (id == R.id.nav_fb) { sp = getApplicationContext().getSharedPreferences("shared", 0); ed = sp.edit(); if (sp.getString("facebook", "no").contentEquals("yes")) { Intent it = new Intent(StartHere.this, FbDone.class); startActivity(it); } else { Intent it = new Intent(StartHere.this, FbLogin.class); startActivity(it); } } else if (id == R.id.nav_Skill) { Intent it = new Intent(StartHere.this, SkillPost.class); startActivity(it); } else if (id == R.id.nav_developer) { Intent it = new Intent(StartHere.this, AboutMe.class); startActivity(it); } else if (id == R.id.nav_Attendance) { Intent it = new Intent(StartHere.this, Attendance.class); startActivity(it); } else if (id == R.id.nav_share) { try { Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_SUBJECT, "Public Channel"); String sAux = "\nAn android app for UPES students to check their attendance, timetable and search other students\n\n"; sAux = sAux + "https://play.google.com/store/apps/details?id=com.work.nishant.publicchannel \n\n"; i.putExtra(Intent.EXTRA_TEXT, sAux); startActivity(Intent.createChooser(i, "choose one")); } catch (Exception e) { //e.toString(); } } else if (id == R.id.nav_logout) { ed.clear(); ed.commit(); eco.clear(); eco.commit(); Intent it = new Intent(StartHere.this, MainActivity.class); startActivity(it); finish(); } else if (id == R.id.nav_opensource) { WebView view = (WebView) LayoutInflater.from(this).inflate(R.layout.license, null); view.loadUrl("file:///android_asset/open.html"); view.getSettings().setUseWideViewPort(true); view.getSettings().setBuiltInZoomControls(true); AlertDialog.Builder mAlertDialog = new AlertDialog.Builder(this, R.style.Theme_AppCompat_Light_Dialog_Alert).setTitle("Open Source License").setView(view) .setPositiveButton(android.R.string.ok, null); AlertDialog alert = mAlertDialog.create(); alert.show(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.hhs.hfnavigator.slidingtabs.harbinger.LiveStreamFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview, null); progressWheel = (ProgressWheel) root.findViewById(R.id.webViewProgress); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.swipe); swipeRefreshLayout.setEnabled(false); progressWheel.spin();/* w w w . ja v a2 s.c o m*/ final WebView webView = (WebView) root.findViewById(R.id.webView); if (webView != null) { webView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { progressWheel.stopSpinning(); webView.setVisibility(View.VISIBLE); } }); webView.loadUrl("http://www.harbingernews.net/livestreams"); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); } webView.setVisibility(View.INVISIBLE); return root; }
From source file:com.sourcey.materiallogindemo.PostItemActivity.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=" + strStart + "&poinTo=" + strEnd; map.getSettings().setLoadsImagesAutomatically(true); map.getSettings().setJavaScriptEnabled(true); map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); map.loadUrl(url);/*from w ww. j a v a 2s.c o m*/ AlertDialog.Builder builderInOut = new AlertDialog.Builder(this); builderInOut.setTitle("?"); 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.concentricsky.android.khanacademy.app.ShowProfileActivity.java
@SuppressLint("SetJavaScriptEnabled") private void enableJavascript(WebView webView) { webView.getSettings().setJavaScriptEnabled(true); }
From source file:at.alladin.rmbt.android.help.RMBTHelpFragment.java
/** * *//*from w w w. ja v a 2 s.co m*/ @SuppressLint("SetJavaScriptEnabled") @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); final Bundle args = getArguments(); String url = args.getString(ARG_URL); if (url == null || url.length() == 0) url = this.getString(R.string.url_help); final Activity activity = getActivity(); final WebView webview = new WebView(activity) { @Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && canGoBack()) { goBack(); return true; } return super.onKeyDown(keyCode, event); } }; final WebSettings webSettings = webview.getSettings(); final String userAgent = AppConstants.getUserAgentString(getActivity()); if (userAgent != null) { webSettings.setUserAgentString(userAgent); } webSettings.setJavaScriptEnabled(true); webview.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) { Log.w(getTag(), "error code:" + errorCode); Log.d(getTag(), "error desc:" + description); Log.d(getTag(), "error url:" + failingUrl); webview.loadUrl("file:///android_res/raw/error.html"); super.onReceivedError(view, errorCode, description, failingUrl); } }); if (!url.matches("^https?://.*")) { final String protocol = ConfigHelper.isControlSeverSSL(activity) ? "https" : "http"; url = protocol + "://" + url; } webview.loadUrl(url); return webview; }