public AnimazioneView(Context context, Animazione animaz, string path) : base(context) { this.Settings.UserAgentString = "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"; this.Settings.JavaScriptEnabled = true; //this.Settings.PluginsEnabled = true; this.Settings.SetPluginState(WebSettings.PluginState.OnDemand); this.Settings.AllowFileAccess = true; this.Settings.SetAppCacheEnabled(true); //this.Settings.JavaScriptCanOpenWindowsAutomatically = true; this.SetBackgroundColor(Android.Graphics.Color.Transparent); this.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; this.Settings.LoadWithOverviewMode = true; this.Settings.UseWideViewPort = true; this.VerticalScrollBarEnabled = false; this.HorizontalScrollBarEnabled = false; LoadingWebViewClient webClient = new LoadingWebViewClient(); this.SetWebViewClient(webClient); resPath = Path.GetFullPath(Path.Combine(path, System.Web.HttpUtility.UrlDecode(animaz.UrlStream))); /*string pa = Path.GetFullPath(Path.Combine(path, System.Web.HttpUtility.UrlDecode(animaz.UrlStream))); * string url = "file://" + pa; * this.LoadUrl(url);*/ }
public BrowserView(Context context, Browser browser, string path, ViewerScreen docView = null) : base(context) { _browser = browser; _docView = docView; //_Context = context; //this.FocusableInTouchMode = true; //this.Settings.LoadsImagesAutomatically = true; //this.Settings.DomStorageEnabled = true; /*mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"); * mWebView.getSettings().setJavaScriptEnabled(true); * mWebView.getSettings().setPluginsEnabled(true); * mWebView.getSettings().setPluginState(PluginState.ON_DEMAND); * mWebView.getSettings().setAllowFileAccess(true); * mWebView.getSettings().setAppCacheEnabled(true); * mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);*/ //this.Settings.UserAgentString = "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17"; //this.SetInitialScale(1); this.Settings.JavaScriptEnabled = true; this.Settings.DomStorageEnabled = true; this.Settings.SetPluginState(WebSettings.PluginState.OnDemand); this.Settings.AllowFileAccess = true; this.Settings.SetAppCacheEnabled(false); this.Settings.JavaScriptCanOpenWindowsAutomatically = true; this.Settings.DomStorageEnabled = true; this.Settings.SetRenderPriority(WebSettings.RenderPriority.High); this.SetBackgroundColor(Android.Graphics.Color.Transparent); this.ScrollBarStyle = ScrollbarStyles.OutsideOverlay; this.Settings.LoadWithOverviewMode = browser.PageFit; this.Settings.UseWideViewPort = browser.PageFit; this.Settings.BuiltInZoomControls = browser.PageFit; this.Settings.DisplayZoomControls = false; this.VerticalScrollBarEnabled = !_browser.ScrollDisable; this.HorizontalScrollBarEnabled = !_browser.ScrollDisable; this.SetWebChromeClient(new WebChromeClient()); this.Settings.AllowUniversalAccessFromFileURLs = true; LoadingWebViewClient webClient = new LoadingWebViewClient(context); /*webClient.OnStart = () => { * this.ShowLoadingOverlay(); * };*/ webClient.OnComplete = () => { this.HideLoadingOverlay(); }; webClient.OverrideUrlLoading = HandleUIWebLoaderControl; /*webClient.OverrideUrlLoading = (WebView view, string reqUrl) => * { * if (reqUrl.Contains("applink://")) * { * reqUrl = reqUrl.Replace("applink://", ""); * var reqParts = reqUrl.Split('?'); * * var action = reqParts[0]; * * if(context is ViewerScreen) * { * var docView = context as ViewerScreen; * docView.OpenPopUp(new string[] { "crediti" }); * } * * return true; * } * * return false; * };*/ this.SetWebViewClient(webClient); string url; bool overlay = true; if (this._browser.Tipo == "embed") { string html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; html += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; html += "<head>"; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"; //html += "<meta name=\"viewport\" content=\"initial-scale=1\">"; html += "<title>Documento senza titolo</title>"; html += "<style>"; html += "html,body {margin:0; padding: 0; height: 100%;}"; html += "</style>"; html += "</head>"; html += "<body>"; html += this._browser.HTML; html += "</body>"; html += "</html>"; this.LoadData(html, "text/html", "UTF-8"); } else if (_browser.Tipo == "gif") { //this.Settings.LoadWithOverviewMode = true; //this.Settings.UseWideViewPort = true; string pa = Path.GetFullPath(Path.Combine(path, System.Web.HttpUtility.UrlDecode(this._browser.UrlStream))); FileInfo fi = new FileInfo(pa); string html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; html += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; html += "<head>"; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"; //html += "<meta name=\"viewport\" content=\"initial-scale=0.5\" />"; html += "<title>Documento senza titolo</title>"; html += "<style>"; html += "html,body {margin:0; padding: 0; height: 100%;}"; html += "</style>"; html += "</head>"; html += "<body>"; html += "<img width='100%' src='" + fi.Name + "'/>"; html += "</body>"; html += "</html>"; this.LoadDataWithBaseURL("file:///" + fi.Directory.FullName + "/", html, "text/html", "UTF-8", null); overlay = false; } else if (_browser.Tipo == "web" && _browser.UrlStream.EndsWith(".mp4")) { string html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; html += "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; html += "<head>"; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"; //html += "<meta name=\"viewport\" content=\"initial-scale=0.5\" />"; html += "<title>Documento senza titolo</title>"; html += "<style>"; html += "html,body {margin:0; padding: 0; height: 100%;}"; html += "</style>"; html += "</head>"; html += "<body>"; html += "<video controls autoplay width='100%' height='100%' src='" + _browser.UrlStream + "'></video>"; html += "</body>"; html += "</html>"; this.LoadData(html, "text/html", "UTF-8"); } else { if (_browser.Tipo == "htm") { string pa = Path.GetFullPath(Path.Combine(path, System.Web.HttpUtility.UrlDecode(this._browser.UrlStream))); url = "file://" + pa; } else if (this._browser.Tipo == "pdf") { string pa = Path.GetFullPath(Path.Combine(path, System.Web.HttpUtility.UrlDecode(this._browser.UrlStream))); if ((int)Android.OS.Build.VERSION.SdkInt < 19) { url = "javascript:void(0);"; } else { if (_browser.Fullscreen) { url = string.Format("file:///android_asset/pdfjs/web/viewer.html?file={0}#0", pa); } else { this.SetInitialScale(1); url = string.Format("file:///android_asset/pdfjs/web/viewer_nobarre.html?file={0}#0", pa); } } } else { if (this._browser.UrlStream.Contains("http://maps")) { //url = "http://maps.google.com/maps?q="+mostRecentLocation.Latitude+","+mostRecentLocation.Longitude; // url = "http://maps.google.com/maps?q=47.404376,8.601478"; url = this._browser.UrlStream.Replace("&output=embed", "").Replace("&output=svembed", ""); } else { url = this._browser.UrlStream; } overlay = true; } if (this._browser.Autostart) { this.LoadUrl(url); if (overlay) { this.ShowLoadingOverlay(); } } } }