Ejemplo n.º 1
0
        protected override bool OnOutputLayer(iLayer layer)
        {
            if (layer is LoginLayer)
            {
                ((LoginLayer)layer).Display();
                return(true);
            }

            if (layer is CameraScanLayer)
            {
                CameraScannerView.Scan(layer as CameraScanLayer);
                return(true);
            }

            if (layer is ScanLayer)
            {
                ScannerView.Scan((ScanLayer)layer);
                return(true);
            }

            return(HandleIntegration(layer as Browser) || base.OnOutputLayer(layer));
        }
Ejemplo n.º 2
0
        private bool HandleIntegration(Browser layer)
        {
            if (layer == null || layer.Url == null)
            {
                return(false);
            }

            // mailto won't be encoded correctly
            if (layer.Url.StartsWith("mailto"))
            {
                MailComposer.Compose(layer.Url);
                return(true);
            }

            NSUrl url = NSUrl.FromString(System.Web.HttpUtility.UrlPathEncode(layer.Url));

            if (url == null)
            {
                return(false);
            }

            switch (url.Scheme)
            {
            case "image":
            case "videorecording":
            {
                ImagePicker.GetMedia(url.AbsoluteString);
                return(true);
            }

            case "audiorecording":
            case "voicerecording":
            {
                AudioPlayer.Record(url.AbsoluteString);
                return(true);
            }

            case "audio":
            {
                AudioPlayer.Play(url.AbsoluteString);
                return(true);
            }

            case "video":
            {
                VideoPlayer.Play(url.AbsoluteString);
                return(true);
            }

            case "scan":
            {
                ScannerView.Scan(url.AbsoluteString);
                return(true);
            }

            case "print":
            {
                Printer.Print(url.AbsoluteString);
                return(true);
            }

            default:
            {
                if (url.IsExternal())
                {
                    if (!UIApplication.SharedApplication.OpenUrl(url))
                    {
                        var av = new UIAlertView(GetResourceString("Error"),
                                                 string.Format(GetResourceString("SchemeNotSupported"), url.Scheme),
                                                 null, GetResourceString("OK"), null);

                        av.Show();
                    }
                    return(true);
                }
                return(false);
            }
            }
        }