Exemplo n.º 1
0
        public void Tweet(string tweetText)
        {
            var tweet = new TWTweetComposeViewController();

            tweet.SetInitialText(tweetText);
//			viewController.PresentModalViewController(tweet, true);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            UIButton tweetButton = UIButton.FromType (UIButtonType.RoundedRect);
            tweetButton.Frame = new RectangleF (0, 0, 300f, 40f);

            tweetButton.SetTitle ("Tweet", UIControlState.Normal);
            tweetButton.TouchUpInside += (sender, e) => {
                var tvc = new TWTweetComposeViewController ();
                tvc.SetInitialText ("Learing about Monothouch at the #NDCOslo workshop!");
                tvc.SetCompletionHandler ((result) =>
                {
                    if (result == TWTweetComposeViewControllerResult.Cancelled) {
                        Console.WriteLine ("Cancelled the tweet");
                    } else {
                        Console.WriteLine ("Tweet sent! Hurrah!");
                    }
                    this.DismissModalViewControllerAnimated (true);
                }
                );
                this.PresentModalViewController (tvc, true);
            };
            View.AddSubview (tweetButton);
            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemplo n.º 3
0
        public override UIViewController GetShareUI(Item item, Action <ShareResult> completionHandler)
        {
            //
            // Get the native UI
            //
            var vc = new TWTweetComposeViewController();

            vc.SetCompletionHandler(result => {
                var shareResult = result == TWTweetComposeViewControllerResult.Done ? ShareResult.Done : ShareResult.Cancelled;
                completionHandler(shareResult);
            });

            vc.SetInitialText(item.Text);

            foreach (var image in item.Images)
            {
                vc.AddImage(image.Image);
            }

            foreach (var link in item.Links)
            {
                vc.AddUrl(new NSUrl(link.AbsoluteUri));
            }

            return(vc);
        }
Exemplo n.º 4
0
        public void shareTwitter()
        {
            if (TWTweetComposeViewController.CanSendTweet)
            {
                // Add code below
                var tweet = new TWTweetComposeViewController();

                tweet.Title = "TWiiiit";
                tweet.SetInitialText("Bust your stress with this new iOS Game!");
                //tweet.AddImage ();
                //								tweet.SetCompletionHandler((TWTweetComposeViewControllerResult r) =>{
                //									DismissModalViewControllerAnimated(true); // hides the tweet
                //									if (r == TWTweetComposeViewControllerResult.Cancelled) {
                //										// user cancelled the tweet
                //									} else {
                //										// user sent the tweet (they may have edited it first)
                //									}
                //								});
                //

                View.Window.RootViewController.PresentModalViewController(tweet, true);

                //PresentModalViewController(tweet, true);
                tweet.AddUrl(new NSUrl("http://xamarin.com/xyz"));
            }
            else
            {
                // Show a message: Twitter may not be configured in Settings
            }
        }
Exemplo n.º 5
0
        public void ShareShort(string message)
        {
            if (!TWTweetComposeViewController.CanSendTweet)
                return;

            _tweet = new TWTweetComposeViewController();
            _tweet.SetInitialText(message);
            _tweet.SetCompletionHandler(TWTweetComposeHandler);
            _modalHost.PresentModalViewController(_tweet, true);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            View.Subviews.OfType<UIButton>().Each( (button, n) => {
                button.TitleLabel.Font = UIFont.FromName ("Open Sans", 18f);
            });

            View.Subviews.OfType<UILabel>().Each( (label, n) => {
                label.Font = UIFont.FromName ("Open Sans", 16f);
            });

            CAGradientLayer gradient =  CAGradientLayer.Create() as CAGradientLayer;
            gradient.Frame = View.Bounds;
            gradient.Colors = new MonoTouch.CoreGraphics.CGColor[] { UIColor.FromRGB(0, 0, 0).CGColor, UIColor.FromRGB(0, 71, 93).CGColor };
            View.Layer.InsertSublayer(gradient, 0);

            if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
                twitterLink.Hidden = true;
                socialLink.Hidden = false;
            } else {
                twitterLink.Hidden = false;
                socialLink.Hidden = true;
            }

            twitterLink.TouchUpInside += (sender, e) => {
                var tweet = new TWTweetComposeViewController();
                tweet.SetInitialText (mainViewController.GetSocialCountdownString());
                PresentViewController(tweet, true, null);
            };

            socialLink.TouchUpInside += (sender, e) => {
                var message = mainViewController.GetSocialCountdownString();
                var social = new UIActivityViewController(new NSObject[] { new NSString(message)},
                new UIActivity[] { new UIActivity() });
                PresentViewController(social, true, null);
            };

            websiteLink.TouchUpInside += (sender, e) => {
                var webUrl = NSUrl.FromString("http://daysuntilxmas.com");
                UIApplication.SharedApplication.OpenUrl(webUrl);
            };

            reviewLink.TouchUpInside += (sender, e) => {
                var id = "yourAppId";
                var itunesUrl = NSUrl.FromString(String.Format("itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id={0}", id));
                var webUrl = NSUrl.FromString(String.Format("http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id={0}&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", id));
                if(UIApplication.SharedApplication.CanOpenUrl(itunesUrl))
                    UIApplication.SharedApplication.OpenUrl(itunesUrl);
                else
                    UIApplication.SharedApplication.OpenUrl(webUrl);
            };

            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemplo n.º 7
0
        public void Manual_PresentsDialog()
        {
            var c = new TWTweetComposeViewController();

            c.SetCompletionHandler(result => {
                Console.WriteLine("COMPLETED " + result);
                c.DismissModalViewControllerAnimated(true);
            });

            AppDelegate.Shared.RootViewController.PresentModalViewController(c, true);
        }
Exemplo n.º 8
0
		public void ShareShort(string message, byte[] image)
		{
			if (!TWTweetComposeViewController.CanSendTweet)
				return;
			
			_tweet = new TWTweetComposeViewController();
			_tweet.SetInitialText(message);
			_tweet.AddImage(UIImage.LoadFromData(NSData.FromArray(image)));
			//_tweet.SetCompletionHandler(TWTweetComposeHandler);
			_presenter.PresentModalViewController(_tweet, true);
		}
Exemplo n.º 9
0
        public void ShareLink(string title, string message, string link)
        {
            if (!TWTweetComposeViewController.CanSendTweet)
                return;

            _tweet = new TWTweetComposeViewController();
            _tweet.SetInitialText(title + " " + message);
            _tweet.AddUrl(new NSUrl(link));
            _tweet.SetCompletionHandler(TWTweetComposeHandler);
            _modalHost.PresentModalViewController(_tweet, true);
        }
Exemplo n.º 10
0
		public void Manual_PresentsDialog ()
		{
			var c = new TWTweetComposeViewController ();

			c.SetCompletionHandler (result => {
				Console.WriteLine ("COMPLETED " + result);
				c.DismissModalViewControllerAnimated (true);
			});

			AppDelegate.Shared.RootViewController.PresentModalViewController (c, true);
		}
Exemplo n.º 11
0
        public void ShareShort(string message)
        {
            if (!TWTweetComposeViewController.CanSendTweet)
            {
                return;
            }

            _tweet = new TWTweetComposeViewController();
            _tweet.SetInitialText(message);
            _tweet.SetCompletionHandler(TWTweetComposeHandler);
            _modalHost.PresentModalViewController(_tweet, true);
        }
Exemplo n.º 12
0
        public void ShareShort(string message)
        {
            if (!TWTweetComposeViewController.CanSendTweet)
            {
                return;
            }

            _tweet = new TWTweetComposeViewController();
            _tweet.SetInitialText(message);
            _tweet.CompletionHandler = TWTweetComposeHandler;

            UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_tweet, true, null);
        }
Exemplo n.º 13
0
        public void ShareLink(string title, string message, string link)
        {
            if (!TWTweetComposeViewController.CanSendTweet)
            {
                return;
            }

            _tweet = new TWTweetComposeViewController();
            _tweet.SetInitialText(title + " " + message);
            _tweet.AddUrl(new NSUrl(link));
            _tweet.SetCompletionHandler(TWTweetComposeHandler);
            _modalHost.PresentModalViewController(_tweet, true);
        }
Exemplo n.º 14
0
        public void ShareLink(string title, string message, string link)
        {
            if (!TWTweetComposeViewController.CanSendTweet)
            {
                return;
            }

            _tweet = new TWTweetComposeViewController();
            _tweet.SetInitialText(title + " " + message);
            _tweet.AddUrl(new NSUrl(link));
            _tweet.CompletionHandler = TWTweetComposeHandler;

            UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_tweet, true, null);
        }
Exemplo n.º 15
0
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            var tweetButton = e.NewElement as TweetButton;

            var button = Control as UIButton;

            button.TouchUpInside += (object sender, EventArgs ea) => {
                var tweetController = new TWTweetComposeViewController();
                tweetController.SetInitialText(tweetButton.Tweet);

                var parentview = button.Superview;
                parentview.Window.RootViewController.PresentModalViewController(tweetController, true);
            };
        }
        /// <summary>
        /// Posts the message to the social network
        /// </summary>
        /// <param name='filename'>
        /// Filename of the image we wish to post
        /// </param>
        private void PostMessage(string filename)
        {
            var tweetComposerViewController = new TWTweetComposeViewController();
            tweetComposerViewController.SetInitialText(LanguageStrings.TweetMessage);

            var image = UIImage.FromFile(filename);
            tweetComposerViewController.AddImage(image);

            tweetComposerViewController.SetCompletionHandler((TWTweetComposeViewControllerResult result) => {
                this.parentController.InvokeOnMainThread(() => {
                    this.parentController.DismissViewController(true, null);
                });
            });

            this.parentController.PresentViewController(tweetComposerViewController, true, null);
        }
		protected override void OnElementChanged (ElementChangedEventArgs<Button> e)
		{
			base.OnElementChanged (e);
		
			var tweetButton = e.NewElement as TweetButton;

			var button = Control as UIButton;

			button.TouchUpInside += (object sender, EventArgs ea) => {
				var tweetController = new TWTweetComposeViewController();
				tweetController.SetInitialText (tweetButton.Tweet); 

				var parentview = button.Superview;
				parentview.Window.RootViewController.PresentModalViewController(tweetController, true);
			};
		}
        protected override void OnModelSet(VisualElement view)
        {
            base.OnModelSet(view);

            var tweetButton = view as TweetButton;

            var button = Control as UIButton;

            button.TouchUpInside += (object sender, EventArgs e) => {
                var tweetController = new TWTweetComposeViewController();
                tweetController.SetInitialText(tweetButton.Tweet);

                var parentview = button.Superview;
                parentview.Window.RootViewController.PresentModalViewController(tweetController, true);
            };
        }
Exemplo n.º 19
0
        partial void btnTweet(MonoTouch.Foundation.NSObject sender)
        {
            bool canTweet = TWTweetComposeViewController.CanSendTweet;

            if (canTweet)
            {
                var tweetSheet = new TWTweetComposeViewController();
                tweetSheet.SetInitialText(txtOutput.Text);

                this.PresentModalViewController(tweetSheet, true);
            }
            else
            {
                UIAlertView _notice = new UIAlertView("Gutted", "You don't have twitter enabled in settings.", null, "Okay", null);
                _notice.Show();
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            webView.ShouldStartLoad = delegate (UIWebView webViewParam, NSUrlRequest request, UIWebViewNavigationType navigationType)
            {	// Catch the link click, and process the add/remove favorites
                if (navigationType == UIWebViewNavigationType.LinkClicked)
                {
                    string path = request.Url.Path.Substring(1);
                    string host = request.Url.Host.ToLower ();
                    if (host == "tweet.mix10.app") {
                        var tweet = new TWTweetComposeViewController();

                        string tweetFormat  = "I'm in '{0}' en {1}";
                        string conferenceHash = "#CodeCampSDQ";

                        tweet.SetInitialText (string.Format(tweetFormat, DisplaySession.Title, conferenceHash));

                        PresentModalViewController(tweet, true);

                    } else if (host == "add.mix10.app") {
                        AppDelegate.UserData.AddFavoriteSession(path);
                        Update(DisplaySession);
                    }
                    else if (host == "remove.mix10.app")
                    {	// "remove.MIX10.app"
                        AppDelegate.UserData.RemoveFavoriteSession(path);
                        if (IsFromFavoritesView)
                        {	// once unfavorited, hide and go back to list view
                            NavigationController.PopViewControllerAnimated(true);
                        }
                        else
                        {
                            Update(DisplaySession);
                        }
                    }
                    else
                    {
                        NavigationController.PushViewController (new WebViewController (request), true);
                        return false;
                    }
                }
                return true;
            };
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            var tweetButton = e.NewElement as TweetButton;

            var button = Control as UIButton;

            button.TouchUpInside += (object sender, EventArgs ea) => {
                var tweetController = new TWTweetComposeViewController();
                // add message, attach URL
                tweetController.SetInitialText(tweetButton.FormattedText);
                tweetController.AddUrl(new Foundation.NSUrl(tweetButton.AttachedUrl));
                tweetController.ModalInPopover = true;

                var parentview = button.Superview;
                parentview.Window.RootViewController.PresentViewController(tweetController, true, null);
            };
        }
Exemplo n.º 22
0
        void ConfigureView()
        {
            // Update the user interface for the detail item
            if (DetailItem != null)
            {
                Title = DetailItem.NameFormatted;

                NameLabel.Text       = DetailItem.NameFormatted;
                DepartmentLabel.Text = DetailItem.Department;

                CallCellButton.TouchUpInside += (sender, e) => {
                    var u = new NSUrl("tel:" + DetailItem.Mobile);
                    UIApplication.SharedApplication.OpenUrl(u);
                };

                CallWorkButton.TouchUpInside += (sender, e) => {
                    var u = new NSUrl("tel:" + DetailItem.Work);
                    UIApplication.SharedApplication.OpenUrl(u);
                };
                EmailButton.TouchUpInside += (sender, e) => {
                    var u = new NSUrl("mailto:" + DetailItem.Email);
                    UIApplication.SharedApplication.OpenUrl(u);
                };
                TweetButton.TouchUpInside += (sender, e) => {
                    if (TWTweetComposeViewController.CanSendTweet)
                    {
                        var tvc = new TWTweetComposeViewController();
                        tvc.SetInitialText("@" + DetailItem.Firstname + " ");
                        this.PresentModalViewController(tvc, true);
                    }
                };


                #region demo of map, optional
                ShowMapButton.Alpha          = 0f;
                ShowMapButton.TouchUpInside += (sender, e) => {
                    // Address has been hardcoded
                    var u = new NSUrl("http://maps.google.com/maps?q=" + "401 Van Ness Ave, San Francisco, USA".Replace(" ", "%20"));
                    UIApplication.SharedApplication.OpenUrl(u);
                };
                #endregion
            }
        }
		protected override void OnElementChanged (ElementChangedEventArgs<Button> e)
		{
			base.OnElementChanged (e);

			var tweetButton = e.NewElement as TweetButton;

			var button = Control as UIButton;

			button.TouchUpInside += (object sender, EventArgs ea) => {
				var tweetController = new TWTweetComposeViewController();
				// add message, attach URL
				tweetController.SetInitialText (tweetButton.FormattedText); 
				tweetController.AddUrl(new MonoTouch.Foundation.NSUrl(tweetButton.AttachedUrl));
				tweetController.ModalInPopover = true;

				var parentview = button.Superview;
				parentview.Window.RootViewController.PresentViewController(tweetController, true, null);
			};
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            webView.ShouldStartLoad = delegate(UIWebView webViewParam, NSUrlRequest request, UIWebViewNavigationType navigationType)
            {                   // Catch the link click, and process the add/remove favorites
                if (navigationType == UIWebViewNavigationType.LinkClicked)
                {
                    string path = request.Url.Path.Substring(1);
                    string host = request.Url.Host.ToLower();
                    if (host == "tweet.mix10.app")
                    {
                        var tweet = new TWTweetComposeViewController();
                        tweet.SetInitialText("I'm in '" + DisplaySession.Title + "' at #monkeyspace");
                        PresentModalViewController(tweet, true);
                    }
                    else if (host == "add.mix10.app")
                    {
                        AppDelegate.UserData.AddFavoriteSession(path);
                        Update(DisplaySession);
                    }
                    else if (host == "remove.mix10.app")
                    {                           // "remove.MIX10.app"
                        AppDelegate.UserData.RemoveFavoriteSession(path);
                        if (IsFromFavoritesView)
                        {                               // once unfavorited, hide and go back to list view
                            NavigationController.PopViewControllerAnimated(true);
                        }
                        else
                        {
                            Update(DisplaySession);
                        }
                    }
                    else
                    {
                        NavigationController.PushViewController(new WebViewController(request), true);
                        return(false);
                    }
                }
                return(true);
            };
        }
		void ConfigureView ()
		{
			// Update the user interface for the detail item
			if (DetailItem != null) {
				Title = DetailItem.NameFormatted;

				NameLabel.Text = DetailItem.NameFormatted;
				DepartmentLabel.Text = DetailItem.Department;

				CallCellButton.TouchUpInside += (sender, e) => {
					var u = new NSUrl ("tel:" + DetailItem.Mobile);
					UIApplication.SharedApplication.OpenUrl (u);
				};

				CallWorkButton.TouchUpInside += (sender, e) => {
					var u = new NSUrl ("tel:" + DetailItem.Work);
					UIApplication.SharedApplication.OpenUrl (u);
				};
				EmailButton.TouchUpInside += (sender, e) => {
					var u = new NSUrl ("mailto:" + DetailItem.Email);
					UIApplication.SharedApplication.OpenUrl (u);
				};
				TweetButton.TouchUpInside += (sender, e) => {
					if (TWTweetComposeViewController.CanSendTweet) {
						var tvc = new TWTweetComposeViewController ();
						tvc.SetInitialText ("@" + DetailItem.Firstname + " ");
						this.PresentModalViewController (tvc, true);
					}
				};
				
				
				#region demo of map, optional
				ShowMapButton.Alpha = 0f;
				ShowMapButton.TouchUpInside += (sender, e) => {
					// Address has been hardcoded 
					var u = new NSUrl ("http://maps.google.com/maps?q=" + "401 Van Ness Ave, San Francisco, USA".Replace (" ", "%20"));
					UIApplication.SharedApplication.OpenUrl (u);
				};
				#endregion
			}
		}
        void HandleShareOptionClicked(object sender, UIButtonEventArgs e)
        {
            UIActionSheet myActionSheet = sender as UIActionSheet;

            Console.WriteLine("Clicked on item {0}", e.ButtonIndex);
            if (e.ButtonIndex != myActionSheet.CancelButtonIndex)
            {
                string paperTitle   = paper.title;
                string urlTitle     = paper.url_title;
                string subject      = "White Paper Bible: " + paperTitle;
                string paperFullURL = "http://whitepaperbible.org/" + urlTitle;

                string messageCombined = subject + Environment.NewLine + paperFullURL;

                if (e.ButtonIndex == 1)
                {
                    //email
                    if (MFMailComposeViewController.CanSendMail)
                    {
                        MFMailComposeViewController _mail = new MFMailComposeViewController();
                        _mail.SetSubject(subject);
                        _mail.SetMessageBody(messageCombined, false);
                        _mail.Finished += HandleMailFinished;
                        this.PresentModalViewController(_mail, true);
                    }
                }
                else if (e.ButtonIndex == 2)
                {
                    TWTweetComposeViewController tweetComposer = new TWTweetComposeViewController();
                    tweetComposer.SetInitialText(paperTitle + " | " + paperFullURL);
                    this.PresentModalViewController(tweetComposer, true);
                }
                else if (e.ButtonIndex == 3)
                {
                    //facebook
                    string encodedURLString = HttpUtility.UrlEncode(paperFullURL);
                    string URLString        = @"http://www.facebook.com/sharer.php?u=" + encodedURLString;
                    UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(URLString));
                }
            }
        }
 public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
 {
     if (navigationType == UIWebViewNavigationType.LinkClicked)
     {
         string path = request.Url.Path.Substring(1);
         string host = request.Url.Host.ToLower();
         if (host == "tweet.mix10.app")
         {
             var tweet = new TWTweetComposeViewController();
             tweet.SetInitialText("@" + path + " #monkeyspace");
             viewController.PresentModalViewController(tweet, true);
         }
         else if (host == "twitter.mix10.app")
         {
             var nsurl = new NSUrl("twitter://user?screen_name=" + viewController.speaker.TwitterHandle);
             UIApplication.SharedApplication.OpenUrl(nsurl);
         }
         else if (host == "session.mix10.app")
         {
             if (sessVC == null)
             {
                 sessVC = new SessionViewController(path);
             }
             else
             {
                 sessVC.Update(path);
             }
             viewController.NavigationController.PushViewController(sessVC, true);
         }
         else
         {
             viewController.NavigationController.PushViewController(new WebViewController(request), true);
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 28
0
		public override UIViewController GetShareUI (Item item, Action<ShareResult> completionHandler)
		{
			//
			// Get the native UI
			//
			var vc = new TWTweetComposeViewController ();

			vc.SetCompletionHandler (result => {
				var shareResult = result == TWTweetComposeViewControllerResult.Done ? ShareResult.Done : ShareResult.Cancelled;
				completionHandler (shareResult);
			});

			vc.SetInitialText (item.Text);

			foreach (var image in item.Images) {
				vc.AddImage (image.Image);
			}

			foreach (var link in item.Links) {
				vc.AddUrl (new NSUrl (link.AbsoluteUri));
			}

			return vc;
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.Subviews.OfType <UIButton>().Each((button, n) => {
                button.TitleLabel.Font = UIFont.FromName("Open Sans", 18f);
            });

            View.Subviews.OfType <UILabel>().Each((label, n) => {
                label.Font = UIFont.FromName("Open Sans", 16f);
            });

            CAGradientLayer gradient = CAGradientLayer.Create() as CAGradientLayer;

            gradient.Frame  = View.Bounds;
            gradient.Colors = new MonoTouch.CoreGraphics.CGColor[] { UIColor.FromRGB(0, 0, 0).CGColor, UIColor.FromRGB(0, 71, 93).CGColor };
            View.Layer.InsertSublayer(gradient, 0);

            if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
            {
                twitterLink.Hidden = true;
                socialLink.Hidden  = false;
            }
            else
            {
                twitterLink.Hidden = false;
                socialLink.Hidden  = true;
            }

            twitterLink.TouchUpInside += (sender, e) => {
                var tweet = new TWTweetComposeViewController();
                tweet.SetInitialText(mainViewController.GetSocialCountdownString());
                PresentViewController(tweet, true, null);
            };

            socialLink.TouchUpInside += (sender, e) => {
                var message = mainViewController.GetSocialCountdownString();
                var social  = new UIActivityViewController(new NSObject[] { new NSString(message) },
                                                           new UIActivity[] { new UIActivity() });
                PresentViewController(social, true, null);
            };

            websiteLink.TouchUpInside += (sender, e) => {
                var webUrl = NSUrl.FromString("http://daysuntilxmas.com");
                UIApplication.SharedApplication.OpenUrl(webUrl);
            };

            reviewLink.TouchUpInside += (sender, e) => {
                var id        = "yourAppId";
                var itunesUrl = NSUrl.FromString(String.Format("itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id={0}", id));
                var webUrl    = NSUrl.FromString(String.Format("http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id={0}&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", id));
                if (UIApplication.SharedApplication.CanOpenUrl(itunesUrl))
                {
                    UIApplication.SharedApplication.OpenUrl(itunesUrl);
                }
                else
                {
                    UIApplication.SharedApplication.OpenUrl(webUrl);
                }
            };

            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemplo n.º 30
0
 private void TWTweetComposeHandler(TWTweetComposeViewControllerResult result)
 {
     _modalHost.NativeModalViewControllerDisappearedOnItsOwn();
     _tweet = null;
 }
Exemplo n.º 31
0
 private void TWTweetComposeHandler(TWTweetComposeViewControllerResult result)
 {
     _tweet.DismissViewController(true, () => { });
     _tweet = null;
 }
 private void ShowTwitterView()
 {
     var tvc = new TWTweetComposeViewController();
     tvc.SetInitialText("@PennyFarApps ");
     this.PresentModalViewController(tvc, true);
 }
Exemplo n.º 33
0
		private void OnShare(object sender, EventArgs e)
		{
			var shareView = new UIAlertView(View.Frame);

			shareView.Title = "Del " + ViewModel.Title;

			shareView.AddButton("Del på Facebook");
			shareView.AddButton("Del på Twitter");
			shareView.AddButton("Avbryt");

			shareView.Clicked += (ss, se) =>
			{
				string launchUri = null;

				var shareMessage = "Se hva jeg fant på Sølvberget: " + ViewModel.Title;

				if(null == ViewModel.RawDto.WebAppUrl) return;

				switch(se.ButtonIndex)
				{
					case 0:

						if(!FBDialogs.CanPresentOSIntegratedShareDialog(FBSession.ActiveSession))
						{
							UIAlertView alert = new UIAlertView(View.Frame);
							alert.Title = "Facebook oppsett mangler";
							alert.Message = "Du må koble din iPhone/iPad til Facebook før du kan dele (selv om du kanskje har installet Facebook appen). Gå til Instillinger - Facebook.";
							alert.AddButton("Ok");
							alert.Show();
							return;
						}

						FBDialogs.PresentOSIntegratedShareDialogModally(this,
							shareMessage, null, new NSUrl(ViewModel.RawDto.WebAppUrl),new FBOSIntegratedShareDialogHandler((res,err) => {

								var ex = err;

							}));


						break;
					case 1:

						var tvc = new TWTweetComposeViewController();
						tvc.SetInitialText(shareMessage);
						tvc.AddUrl(new NSUrl(ViewModel.RawDto.WebAppUrl));
						PresentModalViewController(tvc, true);

						break;
				}

				if(null == launchUri) return;

				bool success = UIApplication.SharedApplication.OpenUrl(new NSUrl(launchUri));
			};

			shareView.CancelButtonIndex = shareView.ButtonCount - 1;

			shareView.Show();
		}
Exemplo n.º 34
0
 private void TWTweetComposeHandler(TWTweetComposeViewControllerResult result)
 {
     _modalHost.NativeModalViewControllerDisappearedOnItsOwn();
     _tweet = null;
 }
Exemplo n.º 35
0
		public void Tweet (string tweetText)
		{
			var tweet = new TWTweetComposeViewController();
			tweet.SetInitialText (tweetText);
//			viewController.PresentModalViewController(tweet, true);
		}
		protected void HandleTweetThisButtonHandleTouchUpInside (object sender, EventArgs e)
		{
			var version = Convert.ToDecimal (UIDevice.CurrentDevice.SystemVersion.Split ('.').First ());
			if (version >= (decimal)5.0) {
				//TODO: Add Reachability
				if (TWTweetComposeViewController.CanSendTweet) {
					var tvc = new TWTweetComposeViewController ();
					tvc.SetInitialText ("I'm attending " + _session.Title + " at #CodeMash");
					tvc.SetCompletionHandler ((MonoTouch.Twitter.TWTweetComposeViewControllerResult r) => {
						this.DismissModalViewControllerAnimated (true);
						if (r == MonoTouch.Twitter.TWTweetComposeViewControllerResult.Cancelled) {
							//display.Text = "Cancelled~";
						} else {
							//display.Text = "Sent!";
						}
					});
					this.PresentModalViewController (tvc, true);
				} else {
					ModalDialog.Alert ("Unable to tweet", "Twitter credentials must be entered in Settings before tweeting.");
				}
			}
		}
Exemplo n.º 37
0
		bool HandleShouldStartLoad (UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) {
			var scheme = "hybrid:";
			// If the URL is not our own custom scheme, just let the webView load the URL as usual
			if (request.Url.Scheme != scheme.Replace(":", ""))
				return true;

			// This handler will treat everything between the protocol and "?"
			// as the method name.  The querystring has all of the parameters.
			var resources = request.Url.ResourceSpecifier.Split('?');
			var method = resources [0];
			var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]); // breaks if ? not present (ie no params)

			if (method == "") {
				var template = new TodoView () { Model = new TodoItem() };
				var page = template.GenerateString ();
				webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
			}
			else if (method == "ViewTask") {
				var id = parameters ["todoid"];
				var model = App.Database.GetItem (Convert.ToInt32 (id));
				var template = new TodoView () { Model = model };
				var page = template.GenerateString ();
				webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
			} else if (method == "TweetAll") {
				var todos = App.Database.GetItemsNotDone ();
				var totweet = "";
				foreach (var t in todos)
					totweet += t.Name + ",";
				if (totweet == "")
					totweet = "there are no tasks to tweet";
				else 
					totweet = "Still do to:" + totweet;
				var tweetController = new TWTweetComposeViewController ();
				tweetController.SetInitialText (totweet); 
				PresentViewController (tweetController, true, null);
			} else if (method == "TextAll") {
				if (MFMessageComposeViewController.CanSendText) {

					var todos = App.Database.GetItemsNotDone ();
					var totext = "";
					foreach (var t in todos)
						totext += t.Name + ",";
					if (totext == "")
						totext = "there are no tasks to text";

					MFMessageComposeViewController message =
						new MFMessageComposeViewController ();
					message.Finished += (sender, e) => {
						e.Controller.DismissViewController (true, null);
					};
					//message.Recipients = new string[] { receiver };
					message.Body = totext;
					PresentViewController (message, true, null);
				} else {
					new UIAlertView ("Sorry", "Cannot text from this device", null, "OK", null).Show ();
				}
			} else if (method == "TodoView") {
				// the editing form
				var button = parameters ["Button"];
				if (button == "Save") {
					var id = parameters ["id"];
					var name = parameters ["name"];
					var notes = parameters ["notes"];
					var done = parameters ["done"];

					var todo = new TodoItem {
						ID = Convert.ToInt32 (id),
						Name = name,
						Notes = notes,
						Done = (done == "on")
					};

					App.Database.SaveItem (todo);
					NavigationController.PopToRootViewController (true);

				} else if (button == "Delete") {
					var id = parameters ["id"];

					App.Database.DeleteItem (Convert.ToInt32 (id));
					NavigationController.PopToRootViewController (true);

				} else if (button == "Cancel") {
					NavigationController.PopToRootViewController (true);

				} else if (button == "Speak") {
					var name = parameters ["name"];
					var notes = parameters ["notes"];
					Speech.Speak (name + " " + notes);
				}
			}
			return false;
		}
 public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
 {
     if (navigationType == UIWebViewNavigationType.LinkClicked) {
         string path = request.Url.Path.Substring(1);
         string host = request.Url.Host.ToLower ();
         if (host == "tweet.monkeyspace.app") {
             var tweet = new TWTweetComposeViewController();
             tweet.SetInitialText ("@" + path + " " + MonkeySpace.Core.Constants.TwitterHashTag);
             viewController.PresentModalViewController(tweet, true);
         } else if (host == "twitter.monkeyspace.app") {
             var nsurl = new NSUrl("twitter://user?screen_name="+viewController.speaker.TwitterHandle);
             UIApplication.SharedApplication.OpenUrl (nsurl);
         } else if (host == "session.monkeyspace.app") {
             if (sessVC == null)
                 sessVC = new SessionViewController (path);
             else
                 sessVC.Update (path);
             viewController.NavigationController.PushViewController (sessVC, true);
         }
         else
         {
             viewController.NavigationController.PushViewController (new WebViewController (request), true);
             return false;
         }
     }
     return true;
 }
Exemplo n.º 39
0
 public void ShowTwitterView()
 {
     NetworkStatus status = Reachability.InternetConnectionStatus();
     if(status == NetworkStatus.NotReachable) {
         // Put alternative content/message here
         ShowMessage ("Network Error", "Sharing requires an Internet connection. Please check your network settings and try again.");
     }
     else
     {
         var tvc = new TWTweetComposeViewController();
         tvc.SetInitialText("I just got a new one rep max " + this.SocialMessage + " #onermlog");
         this._vc.PresentModalViewController(tvc, true);
     }
 }
Exemplo n.º 40
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            webView.ShouldStartLoad = delegate (UIWebView webViewParam, NSUrlRequest request, UIWebViewNavigationType navigationType)
            {	// Catch the link click, and process the add/remove favorites
                if (navigationType == UIWebViewNavigationType.LinkClicked)
                {
                    string path = request.Url.Path.Substring(1);
                    string host = request.Url.Host.ToLower ();
                    if (host == "tweet.mix10.app") {
                        var tweet = new TWTweetComposeViewController();
                        tweet.SetInitialText ("I'm in '" + DisplaySession.Title + "' at #monkeyspace" );
                        PresentModalViewController(tweet, true);
                    } else if (host == "social.mix10.app") {
                        var message = "I'm in '" + DisplaySession.Title + "' at #monkeyspace";
                        var social = new UIActivityViewController(new NSObject[] { new NSString(message) },
                                                                  new UIActivity[] { new UIActivity() });
                        PresentViewController(social, true, null);
                    } else if (host == "add.mix10.app") {
                        AppDelegate.UserData.AddFavoriteSession(path);
                        App.Current.EventStore.RequestAccess (EKEntityType.Reminder, (bool granted, NSError e) => {
                            if (granted) {

                                EKReminder reminder = EKReminder.Create (App.Current.EventStore);
                                reminder.Title = DisplaySession.Title;
                                reminder.Calendar = App.Current.EventStore.DefaultCalendarForNewReminders;
                                reminder.Notes = DisplaySession.Abstract;

                                var date = new NSDateComponents();
                                date.Day = DisplaySession.Start.Day;
                                date.Month = DisplaySession.Start.Month;
                                date.Year = DisplaySession.Start.Year;
                                date.Hour = DisplaySession.Start.Hour;
                                date.Minute = DisplaySession.Start.Minute;
                                date.Second = DisplaySession.Start.Second;

                                reminder.StartDateComponents = date;
                                reminder.DueDateComponents = date;

                                App.Current.EventStore.SaveReminder (reminder, true, out e);
                            } else
                                new UIAlertView ( "Access Denied", "User Denied Access to Calendar Data", null, "OK", null).Show ();
                        });
                        Update(DisplaySession);
                    }
                    else if (host == "remove.mix10.app")
                    {	// "remove.MIX10.app"
                        AppDelegate.UserData.RemoveFavoriteSession(path);
                        if (IsFromFavoritesView)
                        {	// once unfavorited, hide and go back to list view
                            NavigationController.PopViewControllerAnimated(true);
                        }
                        else
                        {
                            Update(DisplaySession);
                        }
                    }
                    else
                    {
                        NavigationController.PushViewController (new WebViewController (request), true);
                        return false;
                    }
                }
                return true;
            };
        }
Exemplo n.º 41
0
        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            var scheme = "hybrid:";

            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            if (request.Url.Scheme != scheme.Replace(":", ""))
            {
                return(true);
            }

            // This handler will treat everything between the protocol and "?"
            // as the method name.  The querystring has all of the parameters.
            var resources  = request.Url.ResourceSpecifier.Split('?');
            var method     = resources [0];
            var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]);             // breaks if ? not present (ie no params)

            if (method == "ListAll")
            {
                var model    = new Lip3Data().MyRecs;
                var template = new TodoList()
                {
                    Model = model
                };
                var page = template.GenerateString();
                webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
            }
            else if (method == "AddTask")
            {
                var template = new TodoView()
                {
                    Model = new TodoItem()
                };
                var page = template.GenerateString();
                webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
            }
            else if (method == "ViewTask")
            {
                var id       = parameters ["todoid"];
                var model    = App.Database.GetItem(Convert.ToInt32(id));
                var template = new TodoView()
                {
                    Model = model
                };
                var page = template.GenerateString();
                webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
            }
            else if (method == "SpeakAll")
            {
                var todos   = App.Database.GetItemsNotDone();
                var tospeak = "";
                foreach (var t in todos)
                {
                    tospeak += t.Name + " ";
                }
                if (tospeak == "")
                {
                    tospeak = "there are no tasks to do";
                }
                Speech.Speak(tospeak);
            }
            else if (method == "TweetAll")
            {
                var todos   = App.Database.GetItemsNotDone();
                var totweet = "";
                foreach (var t in todos)
                {
                    totweet += t.Name + ",";
                }
                if (totweet == "")
                {
                    totweet = "there are no tasks to tweet";
                }
                else
                {
                    totweet = "Still do to:" + totweet;
                }
                var tweetController = new TWTweetComposeViewController();
                tweetController.SetInitialText(totweet);
                PresentModalViewController(tweetController, true);
            }
            else if (method == "TextAll")
            {
                if (MFMessageComposeViewController.CanSendText)
                {
                    var todos  = App.Database.GetItemsNotDone();
                    var totext = "";
                    foreach (var t in todos)
                    {
                        totext += t.Name + ",";
                    }
                    if (totext == "")
                    {
                        totext = "there are no tasks to text";
                    }

                    MFMessageComposeViewController message =
                        new MFMessageComposeViewController();
                    message.Finished += (sender, e) => {
                        e.Controller.DismissViewController(true, null);
                    };
                    //message.Recipients = new string[] { receiver };
                    message.Body = totext;
                    PresentModalViewController(message, true);
                }
                else
                {
                    new UIAlertView("Sorry", "Cannot text from this device", null, "OK", null).Show();
                }
            }
            else if (method == "TodoView")
            {
                // the editing form
                var button = parameters ["Button"];
                if (button == "Save")
                {
                    var id    = parameters ["id"];
                    var name  = parameters ["name"];
                    var notes = parameters ["notes"];
                    var done  = parameters ["done"];

                    var todo = new TodoItem {
                        ID    = Convert.ToInt32(id),
                        Name  = name,
                        Notes = notes,
                        Done  = (done == "on")
                    };

                    App.Database.SaveItem(todo);

                    var model    = new Lip3Data().MyRecs;
                    var template = new TodoList()
                    {
                        Model = model
                    };
                    var page = template.GenerateString();
                    webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
                }
                else if (button == "Delete")
                {
                    var id = parameters ["id"];

                    App.Database.DeleteItem(Convert.ToInt32(id));

                    var model    = new Lip3Data().MyRecs;
                    var template = new TodoList()
                    {
                        Model = model
                    };
                    var page = template.GenerateString();
                    webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
                }
                else if (button == "Cancel")
                {
                    var model    = new Lip3Data().MyRecs;
                    var template = new TodoList()
                    {
                        Model = model
                    };
                    var page = template.GenerateString();
                    webView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);
                }
                else if (button == "Speak")
                {
                    var name  = parameters ["name"];
                    var notes = parameters ["notes"];
                    Speech.Speak(name + " " + notes);
                }
            }
            return(false);
        }
        void HandleShareOptionClicked(object sender, UIButtonEventArgs e)
        {
            UIActionSheet myActionSheet = sender as UIActionSheet;
            Console.WriteLine ("Clicked on item {0}", e.ButtonIndex);
            if (e.ButtonIndex != myActionSheet.CancelButtonIndex) {

                string paperTitle = paper.title;
                string urlTitle = paper.url_title;
                string subject = "White Paper Bible: " + paperTitle;
                string paperFullURL = "http://whitepaperbible.org/" + urlTitle;

                string messageCombined = subject + Environment.NewLine + paperFullURL;

                if (e.ButtonIndex == 1) {
                    //email
                    if (MFMailComposeViewController.CanSendMail) {
                        MFMailComposeViewController _mail = new MFMailComposeViewController ();
                        _mail.SetSubject (subject);
                        _mail.SetMessageBody (messageCombined, false);
                        _mail.Finished += HandleMailFinished;
                        this.PresentModalViewController (_mail, true);
                    }
                } else if (e.ButtonIndex == 2) {
                    TWTweetComposeViewController tweetComposer = new TWTweetComposeViewController ();
                    tweetComposer.SetInitialText (paperTitle + " | " + paperFullURL);
                    this.PresentModalViewController (tweetComposer, true);
                } else if (e.ButtonIndex == 3) {
                    //facebook
                    string encodedURLString = HttpUtility.UrlEncode (paperFullURL);
                    string URLString = @"http://www.facebook.com/sharer.php?u=" + encodedURLString;
                    UIApplication.SharedApplication.OpenUrl (NSUrl.FromString (URLString));

                }
            }
        }