Beispiel #1
0
 private void twitterBtn_Click(object sender, RoutedEventArgs e)
 {
     if (App.appSettings.Contains(HikeConstants.TW_LOGGED_IN)) // already logged in
     {
         MessageBoxResult res = MessageBox.Show(AppResources.FreeSMS_UnlinkFbOrTwConfirm_MsgBx, AppResources.FreeSMS_UnlinkTwitter_MsgBxCaptn, MessageBoxButton.OKCancel);
         if (res == MessageBoxResult.Cancel)
         {
             return;
         }
         else
         {
             App.RemoveKeyFromAppSettings(HikeConstants.AppSettings.TWITTER_TOKEN);
             App.RemoveKeyFromAppSettings(HikeConstants.AppSettings.TWITTER_TOKEN_SECRET);
             App.RemoveKeyFromAppSettings(HikeConstants.TW_LOGGED_IN);
             AccountUtils.SocialPost(null, new AccountUtils.postResponseFunction(SocialDeleteTW), HikeConstants.TWITTER, false);
             return;
         }
     }
     PhoneApplicationService.Current.State[HikeConstants.SOCIAL] = HikeConstants.TWITTER;
     NavigationService.Navigate(new Uri("/View/SocialPages.xaml", UriKind.Relative));
 }
Beispiel #2
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (PhoneApplicationService.Current.State.ContainsKey("FromSocialPage")) // shows page is navigated from social page
            {
                PhoneApplicationService.Current.State.Remove("FromSocialPage");
                ChangeElementsState(false);
                object      oo;
                SocialState ss = SocialState.DEFAULT;
                if (PhoneApplicationService.Current.State.TryGetValue("socialState", out oo))
                {
                    ss = (SocialState)oo;
                    PhoneApplicationService.Current.State.Remove("socialState");
                }
                switch (ss)
                {
                case SocialState.FB_LOGIN:
                    ChangeElementsState(false);
                    JObject oj = new JObject();
                    oj["id"]    = (string)App.appSettings[HikeConstants.AppSettings.FB_USER_ID];
                    oj["token"] = (string)App.appSettings[HikeConstants.AppSettings.FB_ACCESS_TOKEN];
                    AccountUtils.SocialPost(oj, new AccountUtils.postResponseFunction(SocialPostFB), HikeConstants.FACEBOOK, true);
                    break;

                case SocialState.FB_LOGOUT:
                    ChangeElementsState(false);
                    AccountUtils.SocialPost(null, new AccountUtils.postResponseFunction(SocialDeleteFB), HikeConstants.FACEBOOK, false);
                    break;

                case SocialState.TW_LOGIN:
                    JObject ojj = new JObject();
                    ojj["id"]    = (string)App.appSettings[HikeConstants.AppSettings.TWITTER_TOKEN];;
                    ojj["token"] = (string)App.appSettings[HikeConstants.AppSettings.TWITTER_TOKEN_SECRET];
                    AccountUtils.SocialPost(ojj, new AccountUtils.postResponseFunction(SocialPostTW), HikeConstants.TWITTER, true);
                    break;

                default:
                    ChangeElementsState(true);
                    break;
                }
            }
            else
            {
                if (App.appSettings.Contains(HikeConstants.FB_LOGGED_IN))
                {
                    IsFacebookConnected = true;
                }
                else
                {
                    IsFacebookConnected = false;
                }
                if (App.appSettings.Contains(HikeConstants.TW_LOGGED_IN))
                {
                    IsTwitterConnected = true;
                }
                else
                {
                    IsTwitterConnected = false;
                }
            }
        }