private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as AppBarButton;
            var name   = PlaylistNameText.Text;

            button.IsEnabled           = false;
            PlaylistNameText.IsEnabled = false;

            if (string.IsNullOrEmpty(name))
            {
                CurtainPrompt.ShowError("PlaylistCreateNameForgot".FromLanguageResource());
            }
            else
            {
                if (App.Locator.CollectionService.
                    Playlists.FirstOrDefault(p =>
                                             String.Equals(p.Name, name, StringComparison.CurrentCultureIgnoreCase)) != null)
                {
                    CurtainPrompt.ShowError("PlaylistCreateNameTaken".FromLanguageResource());
                }
                else
                {
                    var playlist = await App.Locator.CollectionService.CreatePlaylistAsync(name);

                    CurtainPrompt.Show("PlaylistCreateSuccess".FromLanguageResource(), playlist.Name);
                    App.Navigator.GoBack();
                }
            }

            button.IsEnabled           = true;
            PlaylistNameText.IsEnabled = true;
        }
Beispiel #2
0
        private async void PublishExecute()
        {
            if (string.IsNullOrWhiteSpace(Text))
            {
                CurtainPrompt.ShowError("Looks like you forgot to include some text.");
                return;
            }

            var newCommentRequest = new CreateCommentRequest(_postId, Text);

            IsLoading = true;
            var restResponse = await _findierService.SendAsync <CreateCommentRequest, string>(newCommentRequest);

            IsLoading = false;

            if (restResponse.IsSuccessStatusCode)
            {
                CurtainPrompt.Show("Comment published!");
                NavigationService.GoBack();
            }
            else
            {
                CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error ?? "Problem publishing comment.");
            }
        }
        private async void LoginExecute()
        {
            IsLoading = true;
            var restResponse = await _findierService.LoginAsync(new OAuthRequest(Username, Password));

            IsLoading = false;

            if (restResponse.IsSuccessStatusCode)
            {
                CurtainPrompt.Show("Welcome!");

                if (_requireAuthentication)
                {
                    // return to original page that requested authentication
                    NavigationService.Frame.BackStack.RemoveAt(NavigationService.Frame.BackStack.Count - 1);
                    NavigationService.GoBack();
                }
                else
                {
                    NavigationService.Navigate(typeof(MainPage), clearBackStack: true);
                }
            }
            else
            {
                CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error
                                        ?? "Problem with login. Try again later.");
            }
        }
Beispiel #4
0
 private void OnUpdate()
 {
     CurtainPrompt.Show(() =>
     {
         MessageBox.Show(
             "-Tapping on a toast will now react according to context (Pulling will dismiss them). Try clicking on a \"saved\" toast!\n\n-Faster animations when opening now playing and toasts.\n\n-Fix bug with similar and bio pivots not loading.\n\n-Fix square live tile not updating.",
             "Changelog");
     }, TimeSpan.FromSeconds(5), "Tap here for details on new update!");
 }
Beispiel #5
0
        private async void KeyDownExecute(KeyRoutedEventArgs e)
        {
            if (e.Key != VirtualKey.Enter)
            {
                return;
            }

            _tracksResponse = null;

            // Close the keyboard
            ((Page)((Grid)((TextBox)e.OriginalSource).Parent).Parent).Focus(FocusState.Keyboard);

            var term = ((TextBox)e.OriginalSource).Text;

            term = term.Trim();
            if (term.StartsWith("http://www.last.fm/music/") && term.Contains("/_/"))
            {
                CurtainPrompt.Show("Last.fm link detected.");
                term = term.Replace("http://www.last.fm/music/", string.Empty);
                var artist = term.Substring(0, term.IndexOf("/_/"));
                var title  = WebUtility.UrlDecode(term.Replace(artist + "/_/", string.Empty));
                artist = WebUtility.UrlDecode(artist);
                try
                {
                    var track = await _service.GetDetailTrack(title, artist);

                    if (track == null)
                    {
                        CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
                    }
                    else
                    {
                        await CollectionHelper.SaveTrackAsync(track);
                    }
                }
                catch
                {
                    CurtainPrompt.ShowError("AppNetworkIssue".FromLanguageResource());
                }
            }
            else
            {
                ((TextBox)e.OriginalSource).IsEnabled = false;
                IsLoading = true;
                await SearchAsync(term);

                ((TextBox)e.OriginalSource).IsEnabled = true;
                IsLoading = false;
            }
        }
Beispiel #6
0
        private async void SignUpExecute()
        {
            var signInSheet = new EmailSignUpSheet();
            var success     = await ModalSheetUtility.ShowAsync(signInSheet);

            if (!success)
            {
                return;
            }

            CurtainPrompt.Show("Welcome!");
            CollectionHelper.IdentifyXamarin();

            SubscribeExecute();
        }
Beispiel #7
0
        private async void AddUpNext_Click(object sender, RoutedEventArgs e)
        {
            using (var scope = App.Current.Kernel.BeginScope())
            {
                var backgroundAudioService = scope.Resolve <IPlayerService>();
                try
                {
                    await backgroundAudioService.AddUpNextAsync(Track);

                    CurtainPrompt.Show("Added up next");
                }
                catch (AppException ex)
                {
                    CurtainPrompt.ShowError(ex.Message ?? "Something happened.");
                }
            }
        }
Beispiel #8
0
        private async void SignInExecute()
        {
            var signInSheet = new EmailSignInSheet();
            var success     = await ModalSheetUtility.ShowAsync(signInSheet);

            if (success)
            {
                CurtainPrompt.Show("Welcome!");
                CollectionHelper.IdentifyXamarin();

                // Sync collection
                await CollectionHelper.CloudSync(false);

                await CollectionHelper.DownloadAlbumsArtworkAsync();

                await CollectionHelper.DownloadArtistsArtworkAsync();
            }
        }
Beispiel #9
0
        private async void LoginButtonClicked()
        {
            if (IsLoggedIn)
            {
                _service.Logout();
                CurtainPrompt.Show("AuthLogoutSuccess".FromLanguageResource());
                LastFmUsername = null;
                LastFmPassword = null;
                IsLoggedIn     = false;
                Scrobble       = false;
                Insights.Track("Logged out from Last.FM");
            }
            else
            {
                if (string.IsNullOrEmpty(LastFmUsername) ||
                    string.IsNullOrEmpty(LastFmPassword))
                {
                    CurtainPrompt.ShowError("AuthLoginErrorForgot".FromLanguageResource());
                }

                else
                {
                    UiBlockerUtility.Block("GenericWait".FromLanguageResource());
                    if (await _service.AuthenticaAsync(LastFmUsername, LastFmPassword))
                    {
                        CurtainPrompt.Show("AuthLoginSuccess".FromLanguageResource());
                        IsLoggedIn = true;
                        Scrobble   = true;
                        Insights.Track("Logged in Last.FM");
                    }
                    else
                    {
                        CurtainPrompt.ShowError("AuthLoginError".FromLanguageResource());
                    }
                    UiBlockerUtility.Unblock();
                }

                // update the player also
                var msg = new ValueSet {
                    { PlayerConstants.LastFmLoginChanged, string.Empty }
                };
                BackgroundMediaPlayer.SendMessageToBackground(msg);
            }
        }
Beispiel #10
0
        private void DeveloperModeExecute()
        {
            if (DevMode)
            {
                return;
            }

            _devCount++;

            if (_devCount >= DevModeCount)
            {
                CurtainPrompt.Show("Challenge Completed: Dev Mode Unlock ");
                DevMode = true;
            }

            else if (_devCount > 3)
            {
                CurtainPrompt.Show("{0} click(s) more to...???", DevModeCount - _devCount);
            }
        }
        private async void AddUpNext_Click(object sender, RoutedEventArgs e)
        {
            using (var scope = App.Current.Kernel.BeginScope())
            {
                var backgroundAudioService = scope.Resolve <IPlayerService>();
                try
                {
                    var tracks = GetTracks()
                                 .Where(p => p.Status == TrackStatus.None || p.Status == TrackStatus.Downloading)
                                 .ToList();
                    await backgroundAudioService.AddUpNextAsync(tracks);

                    CurtainPrompt.Show("Added up next");
                }
                catch (AppException ex)
                {
                    CurtainPrompt.ShowError(ex.Message ?? "Something happened.");
                }
            }
        }
Beispiel #12
0
        public async void ContinueFileSavePicker(FileSavePickerContinuationEventArgs args)
        {
            var file = args.File;

            if (file == null)
            {
                CurtainPrompt.ShowError("Backup cancelled.");
                return;
            }

            using (Insights.TrackTime("Create Backup"))
            {
                UiBlockerUtility.Block("Backing up (this may take a bit)...");

                App.Locator.SqlService.Dispose();
                App.Locator.BgSqlService.Dispose();

                try
                {
                    var data = await AutcpFormatHelper.CreateBackup(ApplicationData.Current.LocalFolder);

                    using (var stream = await file.OpenStreamForWriteAsync())
                    {
                        await stream.WriteAsync(data, 0, data.Length);
                    }
                }
                catch (Exception e)
                {
                    Insights.Report(e, "Where", "Creating Backup");
                    CurtainPrompt.ShowError("Problem creating backup.");
                }

                App.Locator.SqlService.Initialize();
                App.Locator.BgSqlService.Initialize();
                UiBlockerUtility.Unblock();
            }

            CurtainPrompt.Show("Backup completed.");
        }
        private async void EditExecute()
        {
            if (!_findierService.IsAuthenticated)
            {
                NavigationService.Navigate(typeof(AuthenticationPage), true);
                return;
            }

            var     type  = PostType.Freebie;
            decimal price = 0;

            if (IsFixed)
            {
                type = PostType.Fixed;
                // convert the price into a decimal
                if (!decimal.TryParse(Price, out price) || price < 1)
                {
                    CurtainPrompt.ShowError("Please enter a valid price.");
                    return;
                }
            }
            else if (IsMoney)
            {
                type = PostType.Money;
            }

            if (!string.IsNullOrWhiteSpace(Email) && !Email.IsEmail())
            {
                CurtainPrompt.ShowError("Please enter a valid email.");
                return;
            }

            if (!string.IsNullOrWhiteSpace(PhoneNumber) && !PhoneNumber.IsPhoneNumber())
            {
                CurtainPrompt.ShowError("Please enter a valid phone number.");
                return;
            }

            if (string.IsNullOrWhiteSpace(Email) &&
                string.IsNullOrWhiteSpace(PhoneNumber))
            {
                CurtainPrompt.ShowError("Please enter at least one contact method.");
                return;
            }

            var editPostRequest = new EditPostRequest(_post.Id,
                                                      _post.Text == Text ? null : Text,
                                                      _post.Type == type ? null : (PostType?)type,
                                                      _post.Price == price ? null : (decimal?)price,
                                                      _post.IsNsfw == IsNsfw || !CanEditNsfw ? null : (bool?)IsNsfw,
                                                      _post.Email == Email ? null : Email,
                                                      _post.PhoneNumber == PhoneNumber ? null : PhoneNumber);

            IsLoading = true;
            var restResponse = await _findierService.SendAsync(editPostRequest);

            IsLoading = false;

            if (restResponse.IsSuccessStatusCode)
            {
                CurtainPrompt.Show("Edit was saved.");
                NavigationService.GoBack();
            }
            else
            {
                CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error
                                        ?? "Problem editing post. Try again later.");
            }

            var props = new Dictionary <string, string>();

            if (restResponse.IsSuccessStatusCode)
            {
                props.Add("Error", restResponse.DeserializedResponse?.Error ?? "Unknown");
                props.Add("StatusCode", restResponse.StatusCode.ToString());
            }
            _insightsService.TrackEvent("EditPost", props);
        }
Beispiel #14
0
 private void LogoutExecute()
 {
     FindierService.Logout();
     NavigationService.Navigate(typeof(AuthenticationPage), clearBackStack: true);
     CurtainPrompt.Show("Goodbye!");
 }
Beispiel #15
0
        private async void ButtonClick(object sender, RoutedEventArgs e)
        {
            var card = new AudioticaStripeCard
            {
                Name   = this.CardNameBox.Text,
                Number = this.CardNumBox.Text,
                Cvc    = this.CardSecurityCode.Text
            };

            var nameEmpty   = string.IsNullOrEmpty(card.Name);
            var numberEmpty = string.IsNullOrEmpty(card.Number);
            var cvcEmpty    = string.IsNullOrEmpty(card.Cvc);
            var expEmpty    = this.ExpMonthBox.SelectedIndex == -1 || this.ExpYearBox.SelectedIndex == -1;

            if (nameEmpty && numberEmpty && cvcEmpty && expEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter all your card information.");
            }
            else if (nameEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the name on the card.");
            }
            else if (numberEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's number.");
            }
            else if (cvcEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's security code.");
            }
            else if (expEmpty)
            {
                CurtainPrompt.ShowError("You forgot to enter the card's expiration date.");
            }
            else
            {
                card.ExpMonth = int.Parse(this.ExpMonthBox.SelectedItem as string);
                card.ExpYear  = int.Parse(this.ExpYearBox.SelectedItem as string);

                var term = SubcriptionTimeFrame.Month;

                switch (this.PlanBox.SelectedIndex)
                {
                case 1:
                    term = SubcriptionTimeFrame.Biyear;
                    break;

                case 2:
                    term = SubcriptionTimeFrame.Year;
                    break;
                }

                UiBlockerUtility.Block("Subscribing...");
                var result =
                    await
                    App.Locator.AudioticaService.SubscribeAsync(
                        SubscriptionType.Silver,
                        term,
                        card,
                        this.CouponCode.Text.Trim());

                UiBlockerUtility.Unblock();

                if (result.Success)
                {
                    CurtainPrompt.Show("Welcome to the Cloud Club!");
                    App.Navigator.GoBack();
                }
                else
                {
                    CurtainPrompt.ShowError(result.Message);
                }
            }
        }
Beispiel #16
0
 private void LogoutExecute()
 {
     this.Service.Logout();
     _appSettingsHelper.Write("LastSyncTime", null);
     CurtainPrompt.Show("Goodbye!");
 }
 public void Show(string text, params object[] args)
 {
     CurtainPrompt.Show(text, args);
 }
Beispiel #18
0
        private async void PublishExecute()
        {
            if (!_findierService.IsAuthenticated)
            {
                NavigationService.Navigate(typeof(AuthenticationPage), true);
                return;
            }

            var     type  = PostType.Freebie;
            decimal price = 0;

            if (IsFixed)
            {
                type = PostType.Fixed;
                // convert the price into a decimal
                if (!decimal.TryParse(Price, out price) || price < 1)
                {
                    CurtainPrompt.ShowError("Please enter a valid price.");
                    return;
                }
            }
            else if (IsMoney)
            {
                type = PostType.Money;
            }

            if (string.IsNullOrWhiteSpace(Title))
            {
                CurtainPrompt.ShowError("Don't forget to set a title!");
                return;
            }
            if (Title.Length < 5)
            {
                CurtainPrompt.ShowError("The title is a bit too short.");
                return;
            }

            if (!string.IsNullOrWhiteSpace(Email) && !Email.IsEmail())
            {
                CurtainPrompt.ShowError("Please enter a valid email.");
                return;
            }

            if (!string.IsNullOrWhiteSpace(PhoneNumber) && !PhoneNumber.IsPhoneNumber())
            {
                CurtainPrompt.ShowError("Please enter a valid phone number.");
                return;
            }

            if (string.IsNullOrWhiteSpace(Email) &&
                string.IsNullOrWhiteSpace(PhoneNumber))
            {
                CurtainPrompt.ShowError("Please enter at least one contact method.");
                return;
            }

            var createPostRequest = new CreatePostRequest(_category.Id,
                                                          Title,
                                                          Text,
                                                          type,
                                                          price,
                                                          IsNsfw,
                                                          Email,
                                                          PhoneNumber);

            IsLoading = true;
            var restResponse = await _findierService.SendAsync <CreatePostRequest, string>(createPostRequest);

            IsLoading = false;

            if (restResponse.IsSuccessStatusCode)
            {
                CurtainPrompt.Show("You post is live!");
                NavigationService.GoBack();
            }
            else
            {
                CurtainPrompt.ShowError(restResponse.DeserializedResponse?.Error
                                        ?? "Problem publishing post. Try again later.");
            }

            var props = new Dictionary <string, string>();

            if (restResponse.IsSuccessStatusCode)
            {
                props.Add("Error", restResponse.DeserializedResponse?.Error ?? "Unknown");
                props.Add("StatusCode", restResponse.StatusCode.ToString());
            }
            _insightsService.TrackEvent("PublishPost", props);
        }