Esempio n. 1
0
        private void OpenBrowserWithOptionsOnThread(object browserOptionsObject)
        {
            SecondaryBrowserOptions browserOptions = (SecondaryBrowserOptions)browserOptionsObject;

            UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                IPhoneUIViewController contentController = new IPhoneUIViewController(browserOptions.Title, browserOptions.CloseButtonText);
                UIWebView webView = IPhoneNet.generateWebView();

                //IF NO EXTENSIONS ARE USED THEN PARSE THE URL FILE EXTENSION
                if (browserOptions.BrowserFileExtensions != null && browserOptions.BrowserFileExtensions.Length > 0)
                {
                    webView.ShouldStartLoad = delegate(UIWebView view, NSUrlRequest req, UIWebViewNavigationType nav){
                        if (req != null && req.Url != null && req.Url.Path.LastIndexOf(".") != -1)
                        {
                            string sFileExtension = req.Url.Path.Substring(req.Url.Path.LastIndexOf("."));
                            if (browserOptions.BrowserFileExtensions.Contains(sFileExtension))
                            {
                                //HANDLE URL LIKE SYSTEM DOES
                                DownloadFile(req.Url.ToString());
                                //RETURN FALSE TO NOT LOAD THE URL ON OUR WEBVIEW
                                return(false);
                            }
                            else
                            {
                                //LOAD URL
                                return(true);
                            }
                        }
                        return(true);
                    };
                }
                contentController.AddInnerView(webView);
                IPhoneServiceLocator.CurrentDelegate.MainUIViewController().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if (!String.IsNullOrWhiteSpace(browserOptions.Url))
                {
                    NSUrl nsUrl = new NSUrl(browserOptions.Url);
                    NSUrlRequest nsUrlRequest = new NSUrlRequest(nsUrl, NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                }
                else if (!String.IsNullOrWhiteSpace(browserOptions.Html))
                {
                    webView.LoadHtmlString(browserOptions.Html, new NSUrl("/"));
                }
            });
        }
Esempio n. 2
0
        private void OpenBrowserOnThread(object browserCommandObject)
        {
            BrowserCommand browserCommand = (BrowserCommand)browserCommandObject;

            UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                IPhoneUIViewController contentController = new IPhoneUIViewController(browserCommand.Title, browserCommand.ButtonText);
                UIWebView webView = IPhoneNet.generateWebView();
                contentController.AddInnerView(webView);

                IPhoneServiceLocator.CurrentDelegate.MainUIViewController().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if (!String.IsNullOrWhiteSpace(browserCommand.Url))
                {
                    NSUrl nsUrl = new NSUrl(browserCommand.Url);
                    NSUrlRequest nsUrlRequest = new NSUrlRequest(nsUrl, NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                }
                else if (!String.IsNullOrWhiteSpace(browserCommand.Html))
                {
                    webView.LoadHtmlString(browserCommand.Html, new NSUrl("/"));
                }
            });
        }
Esempio n. 3
0
 private void ShowMap()
 {
     UIApplication.SharedApplication.InvokeOnMainThread (delegate {
         StartUpdatingLocation();
         IPhoneUIViewController contentController = new IPhoneUIViewController ("Map", "Back");
         if (unityMapView == null) {
                 unityMapView = new UnityMapView ();
         }
         coord = new CLLocationCoordinate2D (unityLocation.Latitude, unityLocation.Longitude);
         coordSpan = new MKCoordinateSpan (latitudeDeltaSpan, longitudeDeltaSpan);
         //0.5 means 0.5 degrees -> 55 km approximately; so it display an area of (55 Km * 55 Km) arround the current coordinates
         coordRegion = new MKCoordinateRegion (coord, coordSpan);
         setMapView ();
         setAnnotationPoints ();
         contentController.AddInnerView (unityMapView);
         IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController (contentController, true);
         IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
     });
 }
Esempio n. 4
0
        private void OpenBrowserOnThread(object browserCommandObject)
        {
            BrowserCommand browserCommand = (BrowserCommand)browserCommandObject;

            UIApplication.SharedApplication.InvokeOnMainThread (delegate {

                IPhoneUIViewController contentController = new IPhoneUIViewController(browserCommand.Title, browserCommand.ButtonText);

                UIWebView webView = new UIWebView();
                webView.ScalesPageToFit = true;
                webView.LoadStarted+= delegate (object sender, EventArgs e) {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                };
                webView.LoadFinished+=delegate (object sender, EventArgs e) {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

                    // stop notify loading masks if any
                    INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
                    notificationService.StopNotifyLoading();
                };
                contentController.AddInnerView(webView);

                IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if(browserCommand.Url!=null && browserCommand.Url.Length>0) {
                    NSUrl nsUrl = new NSUrl (browserCommand.Url);
                    NSUrlRequest  nsUrlRequest = new NSUrlRequest(nsUrl,NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                } else if(browserCommand.Html!=null && browserCommand.Html.Length>0) {
                    webView.LoadHtmlString(browserCommand.Html, new NSUrl("/"));
                }

            });
        }
Esempio n. 5
0
        private void OpenBrowserWithOptionsOnThread(object browserOptionsObject)
        {
            SecondaryBrowserOptions browserOptions = (SecondaryBrowserOptions)browserOptionsObject;
            UIApplication.SharedApplication.InvokeOnMainThread (delegate {

                IPhoneUIViewController contentController = new IPhoneUIViewController(browserOptions.Title, browserOptions.CloseButtonText);
                UIWebView webView = IPhoneNet.generateWebView();

                //IF NO EXTENSIONS ARE USED THEN PARSE THE URL FILE EXTENSION
                if(browserOptions.BrowserFileExtensions!=null && browserOptions.BrowserFileExtensions.Length>0){
                    webView.ShouldStartLoad = delegate (UIWebView view, NSUrlRequest req, UIWebViewNavigationType nav){

                        SystemLogger.Log(SystemLogger.Module.PLATFORM,"OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: " + req);

                        if(req!=null && req.Url!=null && req.Url.Path!=null && req.Url.Path.LastIndexOf(".") != -1){
                            SystemLogger.Log(SystemLogger.Module.PLATFORM,"OpenBrowserWithOptionsOnThread - request path: " + req.Url.Path);
                            string sFileExtensionPath = req.Url.Path.Substring(req.Url.Path.LastIndexOf("."));
                            if(browserOptions.BrowserFileExtensions.Contains(sFileExtensionPath)){
                                SystemLogger.Log(SystemLogger.Module.PLATFORM,"OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: Handled by system (file extension matching by Path)");
                                //HANDLE URL LIKE SYSTEM DOES
                                DownloadFile(Uri.UnescapeDataString(req.Url.ToString()));
                                //RETURN FALSE TO NOT LOAD THE URL ON OUR WEBVIEW
                                return false;
                            }
                        }
                        // extensions could also be received as Query parameters
                        if(req!=null && req.Url!=null && req.Url.Query!=null && req.Url.Query.LastIndexOf(".") != -1){
                            SystemLogger.Log(SystemLogger.Module.PLATFORM,"OpenBrowserWithOptionsOnThread - request query: " + req.Url.Query);
                            string sFileExtensionQuery = req.Url.Query.Substring(req.Url.Query.LastIndexOf("."));
                            if(browserOptions.BrowserFileExtensions.Contains(sFileExtensionQuery)){
                                //HANDLE URL LIKE SYSTEM DOES
                                SystemLogger.Log(SystemLogger.Module.PLATFORM,"OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: Handled by system (file extension matching by Query)");
                                DownloadFile(Uri.UnescapeDataString(req.Url.ToString()));
                                //RETURN FALSE TO NOT LOAD THE URL ON OUR WEBVIEW
                                return false;
                            }
                        }

                        SystemLogger.Log(SystemLogger.Module.PLATFORM,"OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: Loaded into WebView (not Path or Query match provided extensions)");

                        return true;
                    };
                }
                contentController.AddInnerView(webView);
                IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if(!String.IsNullOrWhiteSpace(browserOptions.Url)) {
                    NSUrl nsUrl = new NSUrl (browserOptions.Url);
                    NSUrlRequest  nsUrlRequest = new NSUrlRequest(nsUrl,NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                } else if(!String.IsNullOrWhiteSpace(browserOptions.Html)) {
                    webView.LoadHtmlString(browserOptions.Html, new NSUrl("/"));
                }
            });
        }
Esempio n. 6
0
        private void OpenBrowserOnThread(object browserCommandObject)
        {
            BrowserCommand browserCommand = (BrowserCommand)browserCommandObject;

            UIApplication.SharedApplication.InvokeOnMainThread (delegate {

                IPhoneUIViewController contentController = new IPhoneUIViewController(browserCommand.Title, browserCommand.ButtonText);
                UIWebView webView = IPhoneNet.generateWebView();
                contentController.AddInnerView(webView);

                IPhoneServiceLocator.CurrentDelegate.MainUIViewController ().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if(!String.IsNullOrWhiteSpace(browserCommand.Url)) {
                    NSUrl nsUrl = new NSUrl (browserCommand.Url);
                    NSUrlRequest  nsUrlRequest = new NSUrlRequest(nsUrl,NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                } else if(!String.IsNullOrWhiteSpace(browserCommand.Html)) {
                    webView.LoadHtmlString(browserCommand.Html, new NSUrl("/"));
                }

            });
        }
Esempio n. 7
0
        private void OpenBrowserWithOptionsOnThread(object browserOptionsObject)
        {
            SecondaryBrowserOptions browserOptions = (SecondaryBrowserOptions)browserOptionsObject;

            UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                IPhoneUIViewController contentController = new IPhoneUIViewController(browserOptions.Title, browserOptions.CloseButtonText);
                UIWebView webView = IPhoneNet.generateWebView();

                //IF NO EXTENSIONS ARE USED THEN PARSE THE URL FILE EXTENSION
                if (browserOptions.BrowserFileExtensions != null && browserOptions.BrowserFileExtensions.Length > 0)
                {
                    webView.ShouldStartLoad = delegate(UIWebView view, NSUrlRequest req, UIWebViewNavigationType nav){
                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: " + req);

                        if (req != null && req.Url != null && req.Url.Path != null && req.Url.Path.LastIndexOf(".") != -1)
                        {
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "OpenBrowserWithOptionsOnThread - request path: " + req.Url.Path);
                            string sFileExtensionPath = req.Url.Path.Substring(req.Url.Path.LastIndexOf("."));
                            if (browserOptions.BrowserFileExtensions.Contains(sFileExtensionPath))
                            {
                                SystemLogger.Log(SystemLogger.Module.PLATFORM, "OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: Handled by system (file extension matching by Path)");
                                //HANDLE URL LIKE SYSTEM DOES
                                DownloadFile(Uri.UnescapeDataString(req.Url.ToString()));
                                //RETURN FALSE TO NOT LOAD THE URL ON OUR WEBVIEW
                                return(false);
                            }
                        }
                        // extensions could also be received as Query parameters
                        if (req != null && req.Url != null && req.Url.Query != null && req.Url.Query.LastIndexOf(".") != -1)
                        {
                            SystemLogger.Log(SystemLogger.Module.PLATFORM, "OpenBrowserWithOptionsOnThread - request query: " + req.Url.Query);
                            string sFileExtensionQuery = req.Url.Query.Substring(req.Url.Query.LastIndexOf("."));
                            if (browserOptions.BrowserFileExtensions.Contains(sFileExtensionQuery))
                            {
                                //HANDLE URL LIKE SYSTEM DOES
                                SystemLogger.Log(SystemLogger.Module.PLATFORM, "OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: Handled by system (file extension matching by Query)");
                                DownloadFile(Uri.UnescapeDataString(req.Url.ToString()));
                                //RETURN FALSE TO NOT LOAD THE URL ON OUR WEBVIEW
                                return(false);
                            }
                        }

                        SystemLogger.Log(SystemLogger.Module.PLATFORM, "OpenBrowserWithOptionsOnThread - WebView ShouldStartLoad: Loaded into WebView (not Path or Query match provided extensions)");

                        return(true);
                    };
                }
                contentController.AddInnerView(webView);
                IPhoneServiceLocator.CurrentDelegate.MainUIViewController().PresentModalViewController(contentController, true);
                IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false);
                if (!String.IsNullOrWhiteSpace(browserOptions.Url))
                {
                    NSUrl nsUrl = new NSUrl(browserOptions.Url);
                    NSUrlRequest nsUrlRequest = new NSUrlRequest(nsUrl, NSUrlRequestCachePolicy.ReloadRevalidatingCacheData, 120.0);
                    webView.LoadRequest(nsUrlRequest);
                }
                else if (!String.IsNullOrWhiteSpace(browserOptions.Html))
                {
                    webView.LoadHtmlString(browserOptions.Html, new NSUrl("/"));
                }
            });
        }