Пример #1
0
        public async Task InitiateConferenceTweet()
        {
            var slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

            if (slComposer == null)
            {
                var alertController = UIAlertController.Create(
                    "Unavailable",
                    "Twitter is not available, please sign in on your device's settings screen.",
                    UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                await UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(alertController, true);
            }
            else
            {
                slComposer.SetInitialText(EventInfo.HashTag + " ");
                if (slComposer.EditButtonItem != null)
                {
                    slComposer.EditButtonItem.TintColor = AppDelegate.PrimaryColor;
                }
                slComposer.CompletionHandler += (result) =>
                {
                    UIApplication.SharedApplication.InvokeOnMainThread(() => UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null));
                };

                await UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(slComposer, true);
            }
        }
        private void ShareOnService(SLServiceKind service, string title, string status, string link)
        {
            SLComposeViewController slComposer;

            if (SLComposeViewController.IsAvailable(service))
            {
                slComposer = SLComposeViewController.FromService(service);
                slComposer.SetInitialText(status);
                if (title != null)
                {
                    slComposer.SetInitialText(String.Format("{0} {1}", title, status));
                }
                else
                {
                    slComposer.SetInitialText(status);
                }
                if (link != null)
                {
                    slComposer.AddUrl(new NSUrl(link));
                }
                slComposer.CompletionHandler += (result) => {
                    UIApplication.SharedApplication.KeyWindow.RootViewController.InvokeOnMainThread(() => {
                        UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);
                    });
                };
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(slComposer, true, null);
            }
        }
Пример #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            SendTweetButton.TouchUpInside += (object sender, EventArgs e) => {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    slComposerViewController = SLComposeViewController.FromService(SLServiceKind.Twitter);

                    slComposerViewController.SetInitialText(TweetTextView.Text);

                    slComposerViewController.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                            DismissViewController(true, null);

                            UIAlertView messageBox = new UIAlertView("Ray's Hot Dogs", "Tweet sent successfully", null, "OK", null);

                            messageBox.Show();
                        });
                    };

                    PresentViewController(slComposerViewController, true, null);
                }
                else
                {
                    UIAlertView messageBox = new UIAlertView("Ray's Hot Dogs", "Twitter not configured on your device", null, "OK", null);
                    messageBox.Show();
                }
            };
        }
        public void OpenTwitter()
        {
            var slComposr = SLComposeViewController.FromService(SLServiceType.Twitter);

            if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
            {
                slComposr.SetInitialText("#AppTwitter");

                slComposr.CompletionHandler += (result) =>
                {
                    UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);
                };

                UIWindow         window         = UIApplication.SharedApplication.KeyWindow;
                UIViewController viewController = window.RootViewController;
                if (viewController == null)
                {
                    while (viewController.PresentedViewController != null)
                    {
                        viewController = viewController.PresentedViewController;
                    }
                }
                viewController.PresentViewController(slComposr, true, null);
            }
        }
Пример #5
0
        public override UIViewController GetShareUI(Item item, Action <ShareResult> completionHandler)
        {
            //
            // Get the native UI
            //
            var vc = SLComposeViewController.FromService(kind);

            vc.CompletionHandler = (result) => {
                var shareResult = result == SLComposeViewControllerResult.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 void postImageOnFacebook(UIImage image)
        {
            if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
            {
                SLComposeViewController composerVC = SLComposeViewController.FromService(SLServiceKind.Facebook);
                composerVC.SetInitialText("Wikitude Snapshot");
                composerVC.AddImage(image);

                _presentingVC.PresentViewController(composerVC, true, null);

                composerVC.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        NSString resultString = new NSString("");
                        switch (result)
                        {
                        case SLComposeViewControllerResult.Cancelled:
                            resultString = new NSString("Failed to post on Facebook");
                            break;

                        case SLComposeViewControllerResult.Done:
                            resultString = new NSString("Successfully posted on Facebook");
                            break;

                        default:
                            break;
                        }

                        UIAlertView alert = new UIAlertView("Screen shot", resultString, null, "OK", null);
                        alert.Show();
                    });
                };
            }
        }
Пример #7
0
        public bool HandleShortcutItem(UIApplicationShortcutItem shortcutItem)
        {
            Console.WriteLine("HandleShortcutItem ");
            var handled = false;

            // Anything to process?
            if (shortcutItem == null)
                return false;


            // Take action based on the shortcut type
            switch (shortcutItem.Type)
            {
                case ShortcutIdentifier.Tweet:
                    Console.WriteLine("QUICKACTION: Tweet");
                    var slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                    if (slComposer == null)
                    {
                        new UIAlertView("Unavailable", "Twitter is not available, please sign in on your devices settings screen.", null, "OK").Show();
                    }
                    else
                    {
                        slComposer.SetInitialText("#UtahOpenSource");
                        if (slComposer.EditButtonItem != null)
                        {
                            slComposer.EditButtonItem.TintColor = UIColor.FromRGB(118, 53, 235);
                        }
                        slComposer.CompletionHandler += (result) =>
                        {
                            InvokeOnMainThread(() => UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null));
                        };
                        
                        UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(slComposer, true);
                    }
                    handled = true;
                    break;
                case ShortcutIdentifier.Announcements:
                    Console.WriteLine("QUICKACTION: Accouncements");
                    ContinueNavigation(AppPage.Notification);
                    handled = true;
                    break;
                case ShortcutIdentifier.MiniHacks:
                    Console.WriteLine("QUICKACTION: MiniHacks");
                    ContinueNavigation(AppPage.MiniHacks);
                    handled = true;
                    break;
                case ShortcutIdentifier.Events:
                    Console.WriteLine("QUICKACTION: Events");
                    ContinueNavigation(AppPage.Events);
                    handled = true;
                    break;
            }

            Console.Write(handled);
            // Return results
            return handled;
        }
Пример #8
0
 public static void Tweet(string text)
 {
     Thread.UI.Run(() =>
     {
         if (UIApplication.SharedApplication.CanOpenUrl(NSUrl.FromString("twitter://")))
         {
             var twitter = SLComposeViewController.FromService(SLServiceType.Twitter);
             twitter.SetInitialText(text);
             UIRuntime.Window.RootViewController.PresentViewController(twitter, true, null);
         }
         else
         {
             UIApplication.SharedApplication.OpenUrl(NSUrl.FromString($"https://twitter.com/intent/tweet?text={text}"));
         }
     });
 }
Пример #9
0
 public static void TweetPhoto(string text, byte[] photo)
 {
     Thread.UI.Run(() =>
     {
         if (UIApplication.SharedApplication.CanOpenUrl(NSUrl.FromString("twitter://")))
         {
             var twitter = SLComposeViewController.FromService(SLServiceType.Twitter);
             twitter.SetInitialText(text);
             twitter.AddImage(UIImage.LoadFromData(NSData.FromArray(photo)));
             UIRuntime.Window.RootViewController.PresentViewController(twitter, true, null);
         }
         else
         {
             throw new ArgumentOutOfRangeException("For posting photos you need to install Twitter on your device");
         }
     });
 }
Пример #10
0
        public void shareFaceobook()
        {
            if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
            {
                var slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                slComposer.SetInitialText("Bust your stress with this new iOS Game!");

                slComposer.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        slComposer.DismissViewController(true, null);
                    });
                };


                View.Window.RootViewController.PresentModalViewController(slComposer, true);
            }
        }
Пример #11
0
        public void SendSocial(SLServiceKind framework)
        {
            var slComposer = SLComposeViewController.FromService(framework);

            if (slComposer == null)
            {
                new UIAlertView("Unavailable", "This social network is not available.", null, "OK").Show();
                return;
            }

            slComposer.CompletionHandler += (result) => {
                InvokeOnMainThread(() => DismissViewController(true, null));
            };
            PresentViewControllerAsync(slComposer, true);

            CreateAllNotifcations();
        }
Пример #12
0
        private void ShareOnService(SLServiceKind service, string title, string status, string link, Action onShareDone)
        {
            if (SLComposeViewController.IsAvailable(service))
            {
                var slComposer = SLComposeViewController.FromService(service);
                slComposer.Title = title;
                slComposer.SetInitialText(status);
                slComposer.AddUrl(new NSUrl(link));

                slComposer.CompletionHandler += (result) => {
                    if (result == SLComposeViewControllerResult.Done && onShareDone != null)
                    {
                        onShareDone.Invoke();
                    }
                };

                ViewController.PresentViewController(slComposer, true, null);
            }
        }
        public void Facebook()
        {
            var _facebookComposer = SLComposeViewController.FromService(SLServiceType.Facebook);

            if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
            {
                _facebookComposer.SetInitialText(ConstantsClass.sharingText);
                //  FacebookComposer.AddImage(UIImage.FromFile("Icon.png"));
                _facebookComposer.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        DismissViewController(true, null);
                        Console.WriteLine("Results: {0}", result);
                    });
                };

                // Display controller
                PresentViewController(_facebookComposer, true, null);
            }
        }
Пример #14
0
        public void SendTweet(string msg)
        {
            if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
            {
                var window          = UIApplication.SharedApplication.KeyWindow;
                UIViewController vc = window.RootViewController;

                slComposer = SLComposeViewController.FromService(SLServiceKind.Twitter);
                slComposer.SetInitialText(msg);
                slComposer.CompletionHandler += (result) =>
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        vc.DismissModalViewController(true);
                    });
                };
                vc.PresentViewController(slComposer, true, null);
            }
        }
        public void Twitter()
        {
            Console.WriteLine("............. CALLING FROM TABLE SOURCE");

            var slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

            if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
            {
                Console.WriteLine("....................................................");

                // Set initial message
                slComposer.SetInitialText(ConstantsClass.sharingText);
                // slComposer.AddImage(UIImage.FromFile("Icon.png"));
                slComposer.CompletionHandler += (result) => {
                    InvokeOnMainThread(() => {
                        DismissViewController(true, null);
                        Console.WriteLine("Results: {0}", result);
                    });
                };

                // Display controller
                PresentViewController(slComposer, true, null);
            }
        }
Пример #16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TweetButton.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

                if (Screenshot.Image != null)
                {
                    slComposer.AddImage(Screenshot.Image);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            PostButton.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);

                if (Screenshot.Image != null)
                {
                    slComposer.AddImage(Screenshot.Image);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            #region Menu Buttons
            CloseButton.TouchUpInside += delegate {
                UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade);
                DismissViewController(true, null);
            };

            PrevBtn.TouchUpInside += delegate {
                SwipeImage("Right");
            };

            NextBtn.TouchUpInside += delegate {
                SwipeImage("Left");
            };
            #endregion

            #region Gesture Recognizers
            UITapGestureRecognizer tapGesture = new UITapGestureRecognizer();
            tapGesture.NumberOfTapsRequired = 1;
            tapGesture.AddTarget(this, new Selector("MenuDisplay"));
            Screenshot.AddGestureRecognizer(tapGesture);

            UISwipeGestureRecognizer swipeLeftGesture = new UISwipeGestureRecognizer();
            swipeLeftGesture.AddTarget(this, new Selector("SwipeLeftGesture"));
            swipeLeftGesture.Direction = UISwipeGestureRecognizerDirection.Left;
            View.AddGestureRecognizer(swipeLeftGesture);

            UISwipeGestureRecognizer swipeRightGesture = new UISwipeGestureRecognizer();
            swipeRightGesture.AddTarget(this, new Selector("SwipeRightGesture"));
            swipeRightGesture.Direction = UISwipeGestureRecognizerDirection.Right;
            View.AddGestureRecognizer(swipeRightGesture);

            UISwipeGestureRecognizer swipeDownGesture = new UISwipeGestureRecognizer();
            swipeDownGesture.AddTarget(this, new Selector("SwipeDownGesture"));
            swipeDownGesture.Direction = UISwipeGestureRecognizerDirection.Down;
            View.AddGestureRecognizer(swipeDownGesture);
            #endregion
        }
Пример #17
0
        void ComposeSocialMessage()
        {
            string socialMessage     = string.Empty;
            string currentBestTime   = userDefaults.StringForKey(PREVIOUS_BEST_TIME_KEY);
            string connectedServices = (String.IsNullOrWhiteSpace(userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED)) == true ?
                                        string.Empty : userDefaults.StringForKey(SOCIAL_NETWORKS_CONNECTED));

            if (String.IsNullOrWhiteSpace(currentBestTime) == true)
            {
                socialMessage = "Got #" + APP_NAME + "?";
            }
            else
            {
                socialMessage = "I survived for " + (currentBestTime.Split(':')[0] == "00" ? string.Empty : int.Parse(currentBestTime.Split(':')[0]) + " hrs ")
                                + (currentBestTime.Split(':')[0] == "00" && currentBestTime.Split(':')[1] == "00" ? string.Empty : int.Parse(currentBestTime.Split(':')[1]) + " mins and ")
                                + int.Parse(currentBestTime.Split(':')[2]) + " secs. Enough said. Booyah. Mic drop. All that. #" + APP_NAME;
            }

            if ((connectedServices.Contains("Twitter") == true) &&
                (SLComposeViewController.IsAvailable(SLServiceKind.Twitter) == true))
            {
                SLComposeViewController twitterViewController = SLComposeViewController.FromService(SLServiceKind.Twitter);

                twitterViewController.SetInitialText(socialMessage);
                twitterViewController.AddUrl(new NSUrl(APP_LINK));

                twitterViewController.CompletionHandler += (twitterobj) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        DismissViewController(true, null);

                        if ((connectedServices.Contains("Facebook") == true) &&
                            (SLComposeViewController.IsAvailable(SLServiceKind.Facebook) == true))
                        {
                            SLComposeViewController facebookViewController = SLComposeViewController.FromService(SLServiceKind.Facebook);

                            facebookViewController.SetInitialText(socialMessage);
                            facebookViewController.AddUrl(new NSUrl(APP_LINK));

                            facebookViewController.CompletionHandler += (facebookobj) =>
                            {
                                InvokeOnMainThread(() =>
                                {
                                    DismissViewController(true, null);
                                    ControlMenu("Show");
                                });
                            };

                            PresentViewController(facebookViewController, true, null);
                        }
                        else
                        {
                            ControlMenu("Show");
                        }
                    });
                };

                PresentViewController(twitterViewController, true, null);
            }
            else if ((connectedServices.Contains("Facebook") == true) &&
                     (SLComposeViewController.IsAvailable(SLServiceKind.Facebook) == true))
            {
                SLComposeViewController facebookViewController = SLComposeViewController.FromService(SLServiceKind.Facebook);

                facebookViewController.SetInitialText(socialMessage);
                facebookViewController.AddUrl(new NSUrl(APP_LINK));

                facebookViewController.CompletionHandler += (facebookobj) =>
                {
                    InvokeOnMainThread(() =>
                    {
                        DismissViewController(true, null);
                        ControlMenu("Show");
                    });
                };

                PresentViewController(facebookViewController, true, null);
            }
            else
            {
                ControlMenu("Show");
            }
        }
Пример #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavBackBtn.TouchUpInside += delegate {
                this.NavigationController.PopViewControllerAnimated(true);
            };

            WebShowSocialNetworksBtn.TouchUpInside += delegate {
                WebNavCloseBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                WebTweetBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                WebPostBtn.Transform     = CGAffineTransform.MakeScale(0f, 0f);
                WebNavCloseBtn.Hidden    = false;
                WebTweetBtn.Hidden       = false;
                WebPostBtn.Hidden        = false;
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    WebTitle.Transform = CGAffineTransform.MakeScale(0f, 0f);
                    WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                    NavBackBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);

                    WebNavCloseBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    WebTweetBtn.Transform    = CGAffineTransform.MakeScale(1f, 1f);
                    WebPostBtn.Transform     = CGAffineTransform.MakeScale(1f, 1f);
                }, null);
            };

            WebNavCloseBtn.TouchUpInside += delegate {
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    WebNavCloseBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                    WebTweetBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                    WebPostBtn.Transform     = CGAffineTransform.MakeScale(0f, 0f);

                    WebTitle.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    NavBackBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                }, null);
            };

            WebTweetBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                slComposer.AddUrl(new NSUrl(_url));

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            WebPostBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                slComposer.AddUrl(new NSUrl(_url));

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            WebBackBtn.TouchUpInside += delegate {
                WebView.GoBack();
            };

            WebForwardBtn.TouchUpInside += delegate {
                WebView.GoForward();
            };

            WebToolBarRefreshBtn.TouchUpInside += delegate {
                if (WebTweetBtn.Hidden == false)
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebNavCloseBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                        WebTweetBtn.Transform       = CGAffineTransform.MakeScale(0f, 0f);
                        WebPostBtn.Transform        = CGAffineTransform.MakeScale(0f, 0f);
                        WebTitle.Transform          = CGAffineTransform.MakeScale(1f, 1f);
                        NavBackBtn.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.Transform = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }
                else
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                        WebLoadingSpinner.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }

                WebView.Reload();
                if (!isLoaded)
                {
                    LoadWebUrl(_url);
                }
            };

            WebView.LoadStarted += delegate {
                if (WebTweetBtn.Hidden == false)
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebNavCloseBtn.Transform    = CGAffineTransform.MakeScale(0f, 0f);
                        WebTweetBtn.Transform       = CGAffineTransform.MakeScale(0f, 0f);
                        WebPostBtn.Transform        = CGAffineTransform.MakeScale(0f, 0f);
                        WebTitle.Transform          = CGAffineTransform.MakeScale(1f, 1f);
                        NavBackBtn.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.Transform = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }
                else
                {
                    UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                        WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                        WebLoadingSpinner.Transform        = CGAffineTransform.MakeScale(1f, 1f);
                        WebLoadingSpinner.StartAnimating();
                    }, null);
                }
            };

            WebView.LoadFinished += delegate {
                WebShowSocialNetworksBtn.Hidden    = false;
                WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(0f, 0f);
                UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    WebShowSocialNetworksBtn.Transform = CGAffineTransform.MakeScale(1f, 1f);
                    WebLoadingSpinner.Transform        = CGAffineTransform.MakeScale(0f, 0f);
                }, delegate {
                    WebLoadingSpinner.StopAnimating();
                    isLoaded = true;
                });
            };

            WebView.LoadError += delegate(object sender, UIWebErrorArgs e) {
                if (!e.Error.ToString().Contains("NSURLErrorDomain"))
                {
                    WebLoadingSpinner.StopAnimating();
                    WebShowSocialNetworksBtn.Alpha = 1;
                    UIAlertView alert = new UIAlertView("Error", "Problem connecting.\n" +
                                                        "Please check your connection and try again.", null, "OK", null);
                    alert.Show();
                }
            };
        }
Пример #19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            BackButton.TouchUpInside += delegate {
                this.NavigationController.PopViewControllerAnimated(true);
            };

            DetailsShowSocialNetworkViewBtn.TouchUpInside += delegate {
                DetailsNavReminderBtn.Transform        = Utilities.Hide;
                DetailsSocialNetworkCloseBtn.Transform = Utilities.Hide;
                TweetBtn.Transform = Utilities.Hide;
                PostBtn.Transform  = Utilities.Hide;
                DetailsNavReminderBtn.Transform = Utilities.Hide;
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Hide;
                    DetailsNavTitleLbl.Transform = Utilities.Hide;
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Hide;
                    BackButton.Transform = Utilities.Hide;

                    DetailsSocialNetworkCloseBtn.Hidden = false;
                    TweetBtn.Hidden = false;
                    PostBtn.Hidden  = false;
                    if (Convert.ToDateTime(_item.release_date) > DateTime.Now)
                    {
                        DetailsNavReminderBtn.Hidden    = false;
                        DetailsNavReminderBtn.Transform = Utilities.Show;
                    }
                    DetailsSocialNetworkCloseBtn.Transform = Utilities.Show;
                    TweetBtn.Transform = Utilities.Show;
                    PostBtn.Transform  = Utilities.Show;
                }, null);
            };

            DetailsSocialNetworkCloseBtn.TouchUpInside += delegate {
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Show;
                    DetailsNavTitleLbl.Transform = Utilities.Show;
                    DetailsShowSocialNetworkViewBtn.Transform = Utilities.Show;
                    BackButton.Transform = Utilities.Show;
                    if (Convert.ToDateTime(_item.release_date) > DateTime.Now)
                    {
                        DetailsNavReminderBtn.Transform = Utilities.Hide;
                    }
                    DetailsSocialNetworkCloseBtn.Transform = Utilities.Hide;
                    TweetBtn.Transform = Utilities.Hide;
                    PostBtn.Transform  = Utilities.Hide;
                }, delegate { DetailsNavReminderBtn.Hidden = true; });
            };

            TweetBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

                if (!String.IsNullOrEmpty(game.hashtag))
                {
                    slComposer.SetInitialText("#" + game.hashtag);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };

            PostBtn.TouchUpInside += delegate {
                slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                if (!String.IsNullOrEmpty(game.title))
                {
                    slComposer.SetInitialText(game.title);
                }

                slComposer.CompletionHandler += (result) => {
                    slComposer.DismissViewController(true, null);
                };
                PresentViewController(slComposer, true, null);
            };
        }
Пример #20
0
        public bool HandleShortcutItem(UIApplicationShortcutItem shortcutItem)
        {
            Console.WriteLine("HandleShortcutItem ");
            var handled = false;

            // Anything to process?
            if (shortcutItem == null)
            {
                return(false);
            }

            // Take action based on the shortcut type
            switch (shortcutItem.Type)
            {
            case ShortcutIdentifier.Tweet:
                Console.WriteLine("QUICKACTION: Tweet");
                var slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                if (slComposer == null)
                {
                    new UIAlertView(
                        title: "Unavailable",
                        message: "Twitter is not available, please sign in on your devices settings screen.",
                        del: null,
                        cancelButtonTitle: "OK").Show();
                }
                else
                {
                    slComposer.SetInitialText(EventInfo.HashTag);
                    if (slComposer.EditButtonItem != null)
                    {
                        slComposer.EditButtonItem.TintColor = primaryColor;
                    }

                    slComposer.CompletionHandler += result =>
                    {
                        this.InvokeOnMainThread(
                            () => UIApplication.SharedApplication.KeyWindow.RootViewController
                            .DismissViewController(true, null));
                    };

                    UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewControllerAsync(
                        slComposer,
                        true);
                }

                handled = true;
                break;

            case ShortcutIdentifier.Announcements:
                Console.WriteLine("QUICKACTION: Accouncements");
                this.ContinueNavigation(AppPage.Notification);
                handled = true;
                break;

            case ShortcutIdentifier.Events:
                Console.WriteLine("QUICKACTION: Meetups");
                this.ContinueNavigation(AppPage.Meetups);
                handled = true;
                break;
            }

            Console.Write(handled);

            // Return results
            return(handled);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            twitterButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);

                    slComposer.SetInitialText("test");
                    slComposer.AddImage(UIImage.FromFile("monkey.png"));

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                            DismissViewController(true, null);
                            resultsTextView.Text = result.ToString();
                        });
                    };

                    PresentViewController(slComposer, true, null);
                }
                else
                {
                    resultsTextView.Text = "Twitter Account not added";
                }
            };

            facebookButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);

                    slComposer.SetInitialText("test2");
                    slComposer.AddImage(UIImage.FromFile("monkey.png"));
                    slComposer.AddUrl(new NSUrl("http://xamarin.com"));

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                            DismissViewController(true, null);
                            resultsTextView.Text = result.ToString();
                        });
                    };

                    PresentViewController(slComposer, true, null);
                }
                else
                {
                    resultsTextView.Text = "Facebook Account not added";
                }
            };

            twitterRequestButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    var parameters = new NSDictionary();
                    var request    = SLRequest.Create(SLServiceKind.Twitter,
                                                      SLRequestMethod.Get,
                                                      new NSUrl("http://api.twitter.com/1/statuses/public_timeline.json"),
                                                      parameters);

                    request.PerformRequest((data, response, error) => {
                        if (response.StatusCode == 200)
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = data.ToString();
                            });
                        }
                        else
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = "Error: " + response.StatusCode.ToString();
                            });
                        }
                    });
                }
                else
                {
                    resultsTextView.Text = "Twitter Account not added";
                }
            };

            facebookRequestButton.TouchUpInside += delegate {
                if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
                {
                    var parameters = new NSDictionary();
                    var request    = SLRequest.Create(SLServiceKind.Facebook,
                                                      SLRequestMethod.Get,
                                                      new NSUrl("https://graph.facebook.com/283148898401104"),
                                                      parameters);

                    request.PerformRequest((data, response, error) => {
                        if (response.StatusCode == 200)
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = data.ToString();
                            });
                        }
                        else
                        {
                            InvokeOnMainThread(() => {
                                resultsTextView.Text = "Error: " + response.StatusCode.ToString();
                            });
                        }
                    });
                }
                else
                {
                    resultsTextView.Text = "Facebook Account not added";
                }
            };
        }
Пример #22
0
        public void donecomboShare()
        {
            hidecomboShare();
            string key = shareList [UpdatecurrenShareOpt];

            Console.WriteLine(key + " Llave: " + UpdatecurrenShareOpt);

            switch (key)
            {
            case "facebook":
            {
                SLComposeViewController slComposer;

                if (SLComposeViewController.IsAvailable(SLServiceKind.Facebook))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Facebook);
                    slComposer.SetInitialText("Condiviso tramite iPortogruaro. Scaricala da iTunes! " + System.Web.HttpUtility.HtmlDecode(dataPos.title));


                    foreach (UIView v in sramdom)
                    {
                        if (v.Tag == positionImg)
                        {
                            if (v is UIImageView)
                            {
                                UIImageView imgs = v as UIImageView;
                                slComposer.AddImage(imgs.Image);
                            }
                            break;
                        }
                    }

                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                                DismissViewController(true, null);
                                if (result == SLComposeViewControllerResult.Done)
                                {
                                    var alert = new UIAlertView("Esito", "messaggio mandato", null, "Ok");

                                    alert.Show();
                                }
                            });
                    };
                    PresentViewController(slComposer, true, null);
                }

                else
                {
                    InvokeOnMainThread(() => {
                            var alert = new UIAlertView("Facebook", "Entrare nei settaggi per configurare l'account facebook", null, "Ok");

                            alert.Show();
                        });
                }
            }
            break;

            case "twitter":
            {
                SLComposeViewController slComposer;

                if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter))
                {
                    slComposer = SLComposeViewController.FromService(SLServiceType.Twitter);
                    slComposer.SetInitialText("Condiviso tramite iPortogruaro. Scaricala da iTunes! " + System.Web.HttpUtility.HtmlDecode(dataPos.title));
                    foreach (UIView v in sramdom)
                    {
                        if (v.Tag == positionImg)
                        {
                            if (v is UIImageView)
                            {
                                UIImageView imgs = v as UIImageView;
                                slComposer.AddImage(imgs.Image);
                            }
                            break;
                        }
                    }
                    slComposer.CompletionHandler += (result) => {
                        InvokeOnMainThread(() => {
                                DismissViewController(true, null);
                                if (result == SLComposeViewControllerResult.Done)
                                {
                                    var alert = new UIAlertView("Esito", "messaggio mandato", null, "Ok");

                                    alert.Show();
                                }
                            });
                    };
                    PresentViewController(slComposer, true, null);
                }
                else
                {
                    InvokeOnMainThread(() => {
                            var alert = new UIAlertView("Twitter", "Entrare nei settaggi per configurare l'account Twitter", null, "Ok");

                            alert.Show();
                        });
                }
                break;
            }

            case "mail":
            {
                MFMailComposeViewController _mail;

                if (MFMailComposeViewController.CanSendMail)
                {
                    _mail = new MFMailComposeViewController();
                    _mail.SetMessageBody("Condiviso tramite iPortogruaro. Scaricala da iTunes! " + System.Web.HttpUtility.HtmlDecode(dataPos.title),
                                         false);
                    _mail.SetSubject(System.Web.HttpUtility.HtmlDecode(dataPos.title));
                    _mail.Finished += HandleMailFinished;

                    foreach (UIView v in sramdom)
                    {
                        if (v.Tag == positionImg)
                        {
                            if (v is UIImageView)
                            {
                                UIImageView imgs = v as UIImageView;
                                NSData      dat  = imgs.Image.AsJPEG(0);
                                _mail.AddAttachmentData(dat, "image/png", System.Web.HttpUtility.HtmlDecode(dataPos.title));
                            }
                            break;
                        }
                    }

                    this.PresentModalViewController(_mail, true);
                }
                else
                {
                    // handle not being able to send mail
                }
                break;
            }
            }
        }