public Task <bool> TryHandleUserInteractionAsync(object identifier, Func <System.Threading.CancellationToken, Task> operation, string errorMessage = null, [CallerMemberName] string callerFunctionName = "", [CallerFilePath] string callerFilePath = "")
        {
            return(HandleUserInteractionAsync(identifier, async(cancellationToken) =>
            {
                try
                {
                    DateTime start = DateTime.Now;

                    await operation(cancellationToken);

                    TimeSpan duration = DateTime.Now - start;
                    if (duration.TotalSeconds > 1.0)
                    {
                        // If these are taking longer than a second, that gives us an idea that we need to
                        // implement UI to show that the data operation is occurring
                        TelemetryExtension.Current?.TrackEvent("SlowInteractionOperation", new Dictionary <string, string>()
                        {
                            { "CallerFilePath", callerFilePath.Split('\\').LastOrDefault() ?? "" },
                            { "Duration", duration.TotalSeconds.ToString("0.0") },
                            { "CallerFunction", callerFunctionName }
                        });
                    }
                }
                catch (OperationCanceledException) { throw; }
                catch (Exception ex)
                {
                    TelemetryExtension.Current?.TrackException(ex);

                    if (errorMessage != null)
                    {
                        var dontWait = new PortableMessageDialog(errorMessage, "Error").ShowAsync();
                    }
                }
            }));
        }
Beispiel #2
0
        public static async Task ShowAsync(PortableMessageDialog portableDialog)
        {
            var dialog = new MessageDialog(portableDialog.Content);

            if (portableDialog.Title != null)
            {
                dialog.Title = portableDialog.Title;
            }

            await dialog.ShowAsync();
        }
        public async void ResetPassword()
        {
            IsResettingPassword = true;

            try
            {
                var email    = Email.Trim();
                var username = Username.Trim();

                ResetPasswordResponse resp = await WebHelper.Download <ResetPasswordRequest, ResetPasswordResponse>(
                    Website.URL + "resetpasswordmodern",
                    new ResetPasswordRequest()
                {
                    Username = username, Email = email
                },
                    Website.ApiKey);

                if (resp == null)
                {
                    return;
                }

                if (resp.Error != null)
                {
                    var dontWait = new PortableMessageDialog(resp.Error, PowerPlannerResources.GetString("ResetPassword_String_ErrorResettingPassword")).ShowAsync();
                }

                else
                {
                    IsResettingPassword = false;
                    var loginViewModel = Parent.GetPopupViewModelHost()?.Popups.OfType <LoginViewModel>().FirstOrDefault();
                    if (loginViewModel != null)
                    {
                        loginViewModel.Username = username;
                    }
                    await new PortableMessageDialog(resp.Message, PowerPlannerResources.GetString("ResetPassword_String_ResetSuccessHeader")).ShowAsync();
                    base.RemoveViewModel();
                }
            }

            catch (OperationCanceledException) { }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                var dontWait = new PortableMessageDialog(PowerPlannerResources.GetStringOfflineExplanation(), PowerPlannerResources.GetString("ResetPassword_String_ErrorResettingPassword")).ShowAsync();
            }

            finally
            {
                IsResettingPassword = false;
            }
        }
        public bool ShowErrorIfInvalid()
        {
            string errorMessage = null;
            string telemSubtype = null;
            string userData     = null;

            if (!IsRepeatIntervalValid())
            {
                errorMessage = "The repeat interval must be set to an integer value of 1 or greater. You entered: " + RepeatIntervalAsString;
                telemSubtype = "InvalidRepeatInterval";
                userData     = RepeatIntervalAsString;
            }
            else if (SelectedRepeatOption == RepeatOptions.Weekly && GetSelectedDaysOfWeek().Length == 0)
            {
                errorMessage = "You must select at least one day of the week to repeat on if using weekly recurrence.";
                telemSubtype = "NoDayOfWeekSelected";
                userData     = "";
            }
            else if (IsEndOccurrencesChecked && !IsEndOccurrencesValid())
            {
                errorMessage = "The occurrences value must be set to an integer of 2 or greater. You entered: " + EndOccurrencesAsString;
                telemSubtype = "InvalidOccurrences";
                userData     = EndOccurrencesAsString;
            }
            else if (IsEndOccurrencesChecked && GetEndOccurrencesAsNumber() > 50)
            {
                errorMessage = "The occurrences value cannot be greater than 50. Please reduce the number of occurrences. You entered: " + EndOccurrencesAsString;

                TelemetryExtension.Current?.TrackEvent("UserError_TooManyOccurrences", new Dictionary <string, string>()
                {
                    { "Error", "OccurrenceValueOver50" },
                    { "UserData", EndOccurrencesAsString }
                });
            }

            if (errorMessage != null)
            {
                if (telemSubtype != null && userData != null)
                {
                    TelemetryExtension.Current?.TrackEvent("UserError_InvalidRecurrence", new Dictionary <string, string>()
                    {
                        { "Error", telemSubtype },
                        { "UserData", userData }
                    });
                }

                var dontWait = new PortableMessageDialog(errorMessage, "Repeating occurrence invalid").ShowAsync();
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public async void Recover()
        {
            IsRecoveringUsernames = true;

            try
            {
                var email = Email.Trim();

                if (string.IsNullOrWhiteSpace(email))
                {
                    var dontWait = new PortableMessageDialog("You must enter an email address!", PowerPlannerResources.GetString("ForgotUsername_String_ErrorFindingUsername")).ShowAsync();
                    return;
                }

                ForgotUsernameResponse response = await WebHelper.Download <ForgotUsernameRequest, ForgotUsernameResponse>(
                    Website.URL + "forgotusernamemodern",
                    new ForgotUsernameRequest()
                {
                    Email = email
                },
                    Website.ApiKey);

                if (response == null)
                {
                    var dontWait = new PortableMessageDialog(response.Error, PowerPlannerResources.GetString("ForgotUsername_String_ErrorFindingUsername")).ShowAsync();
                    return;
                }

                if (response.Usernames.Count == 0)
                {
                    var dontWait = new PortableMessageDialog(string.Format(PowerPlannerResources.GetString("ForgotUsername_String_NoUsernameFoundExplanation"), email), PowerPlannerResources.GetString("ForgotUsername_String_NoUsernameFoundHeader")).ShowAsync();
                    return;
                }

                base.ShowPopup(new RecoveredUsernamesViewModel(Parent, response.Usernames.ToArray()));
                base.RemoveViewModel();
            }

            catch (OperationCanceledException) { }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                var dontWait = new PortableMessageDialog(PowerPlannerResources.GetStringOfflineExplanation(), PowerPlannerResources.GetString("ForgotUsername_String_ErrorFindingUsername")).ShowAsync();
            }

            finally
            {
                IsRecoveringUsernames = false;
            }
        }
        private void OpenHelp()
        {
            try
            {
                TelemetryExtension.Current?.TrackEvent("Action_OpenHelp");

                UIApplication.SharedApplication.OpenUrl(new NSUrl(SettingsListViewModel.HelpUrl));
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                var dontWait = new PortableMessageDialog("Failed to open web browser", "Error").ShowAsync();
            }
        }
        public async void PromptPurchase()
        {
            try
            {
                if (await InAppPurchaseExtension.Current?.PromptPurchase())
                {
                    RemoveViewModel();
                }
            }

            catch
            {
                var dontWait = new PortableMessageDialog("Something went wrong. If you can't purchase on this device, try a different device, and it will sync the premium status with your online account.", "Failed to purchase premium version").ShowAsync();
            }
        }
        private static void OpenStoreReview()
        {
            var  url    = $"itms-apps://itunes.apple.com/app/id1278178608?action=write-review";
            bool opened = false;

            try
            {
                opened = UIApplication.SharedApplication.OpenUrl(new NSUrl(url));
            }
            catch { }

            if (!opened)
            {
                var dontWait = new PortableMessageDialog("The Store failed to open. Try again later.", "Unable to open the Store").ShowAsync();
            }
        }
        public static void EmailDeveloper()
        {
            var    account     = PowerPlannerApp.Current.GetCurrentAccount();
            string accountInfo = "";

            if (account != null)
            {
                accountInfo = "%20-%20" + account.GetTelemetryUserId() + "%20-%20" + account.DeviceId;
            }

            NSUrl url = new NSUrl("mailto:[email protected]&subject=Power%20Planner%20for%20iOS%20-%20Contact%20Developer%20-%20" + Variables.VERSION + accountInfo);

            if (!UIApplication.SharedApplication.OpenUrl(url))
            {
                var dontWait = new PortableMessageDialog("Looks like you don't have email configured on your phone. You'll need to set up email before you can send an email.", "Email app not configured").ShowAsync();
            }
        }
Beispiel #10
0
        private AndroidMessageDialog(PortableMessageDialog dialog)
        {
            _rootDialog = dialog;

            var builder = new AlertDialog.Builder((PortableApp.Current.GetCurrentWindow().NativeAppWindow as NativeDroidAppWindow).Activity);

            if (!string.IsNullOrWhiteSpace(dialog.Title))
            {
                builder.SetTitle(dialog.Title);
            }

            if (!string.IsNullOrWhiteSpace(dialog.Content))
            {
                builder.SetMessage(dialog.Content);
            }

            _alertDialog = builder.Create();
        }
        private void OpenGoogleCalendarIntegration()
        {
            try
            {
                TelemetryExtension.Current?.TrackEvent("Action_OpenGoogleCalendarIntegration");

                if (ViewModel.AlertIfGoogleCalendarIntegrationNotPossible())
                {
                    return;
                }

                UIApplication.SharedApplication.OpenUrl(new NSUrl(GoogleCalendarIntegrationViewModel.Url));
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                var dontWait = new PortableMessageDialog("Failed to open web browser", "Error").ShowAsync();
            }
        }
        private void HandleVersionChange()
        {
            if (_alreadyHandledVersionChange)
            {
                // We'll make sure not to do this multiple times in single app lifecycle
                return;
            }

            _alreadyHandledVersionChange = true;

            const string VERSION = "Version";

            try
            {
                var versionString = CrossSettings.Current.GetValueOrDefault(VERSION, null);

                Version v;
                if (versionString != null && Version.TryParse(versionString, out v))
                {
                }
                else
                {
                    // If they have an account, that implies they were on version 5.3.16.0 which was the
                    // last version before I started storing the version number
                    if (AccountsManager.GetLastLoginLocalId() != Guid.Empty)
                    {
                        v = new Version(5, 3, 16, 0);
                    }
                    else
                    {
                        v = new Version(0, 0, 0, 0);
                    }
                }

                // Assign new version number
                if (v < Variables.VERSION)
                {
                    CrossSettings.Current.AddOrUpdateValue(VERSION, Variables.VERSION.ToString());
                }

                // If was an existing user and things have changed
                if (v.Major > 0 && v < Variables.VERSION)
                {
                    string changedText = "";

                    if (v < new Version(5, 4, 86, 0))
                    {
                        changedText += "\n - 2x improvement in app launch speed!";
                    }

                    if (v < new Version(5, 4, 78, 0))
                    {
                        changedText += "\n - Image attachments on tasks/events!";
                        changedText += "\n - Strikethrough on completed items";
                    }

                    if (v < new Version(5, 4, 72, 0))
                    {
                        changedText += "\n - Fixed GPA calculation handling of failed classes";
                    }

                    if (v < new Version(5, 4, 68, 0))
                    {
                        changedText += "\n - Pass/fail classes are now supported in the GPA grade system!\n - Custom selected due times are remembered for faster task entry";
                    }

                    if (v < new Version(5, 4, 60, 0))
                    {
                        changedText += "\n - Custom color picker for class colors!";
                        changedText += "\n - 24-hour time formatting fixed on schedule view";
                    }

                    if (v < new Version(5, 4, 36, 0))
                    {
                        changedText += "\n - Repeating bulk entry of tasks/events!";
                    }

                    if (v < new Version(5, 4, 32, 0))
                    {
                        changedText += "\n - Google Calendar integration! Go to the Settings page to try it out (requires an online account)";
                    }

                    if (v < new Version(5, 4, 26, 0) && v >= new Version(5, 4, 22, 0))
                    {
                        if (Build.VERSION.SdkInt < BuildVersionCodes.O)
                        {
                            // I broke the app icon in 5.4.22.0 for people not running Oreo
                            changedText += "\n - Fixed missing app icon";
                        }
                    }

                    if (v < new Version(5, 4, 24, 0))
                    {
                        if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                        {
                            changedText += "\n - The Android app now syncs in the background when you make a change on another device!";
                        }
                    }

                    if (v < new Version(5, 4, 22, 0))
                    {
                        if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                        {
                            changedText += "\n - Adaptive icon added!";
                        }
                    }

                    if (v < new Version(5, 4, 20, 0) && v == new Version(5, 4, 18, 0))
                    {
                        // These only get shown to users who were running 5.4.18.0 since that's where I introduced those bugs
                        if (Build.VERSION.SdkInt < BuildVersionCodes.Kitkat)
                        {
                            changedText += "\n - Fixed crashing when trying to add items";
                        }
                        else
                        {
                            changedText += "\n - Fixed crashes when opening add grade page";
                        }
                    }

                    if (v < new Version(5, 4, 18, 0))
                    {
                        changedText += "\n - New Schedule widget!";
                        changedText += "\n - Keyboard now auto-appears";
                    }

                    if (v < new Version(5, 4, 16, 0) && Build.VERSION.SdkInt >= BuildVersionCodes.O && v >= new Version(5, 4, 12, 0))
                    {
                        // Only show this to Oreo users who were running the app targeted to Oreo (5.4.12.0)
                        changedText += "\n - Fixed reminders not working on Android 8.0 Oreo devices";
                    }

                    if (v < new Version(5, 4, 14, 0))
                    {
                        changedText += "\n - Pinch-to-zoom on Schedule page!";
                    }

                    if (v < new Version(5, 4, 12, 0))
                    {
                        changedText += "\n - Disable Autofill on everything except username/password related fields";
                    }

                    if (v < new Version(5, 4, 4, 0))
                    {
                        changedText += "\n - Fixed issues with automatic reminders (day-before and day-of reminders)";
                    }

                    if (v < new Version(5, 4, 0, 0))
                    {
                        changedText += "\n - Widget added for Agenda!";
                    }

                    if (changedText.Length > 0)
                    {
                        var dontWait = new PortableMessageDialog("Power Planner just installed an update!\n\nHere's what's new...\n" + changedText, "Just updated").ShowAsync();
                    }
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
 private void ShowMessage(string message, string title)
 {
     var dontWait = new PortableMessageDialog(message, title).ShowAsync();
 }
 public static void Show(PortableMessageDialog dialog)
 {
     new IOSMessageDialog(dialog).Show();
 }
        private IOSMessageDialog(PortableMessageDialog dialog)
        {
            IUIAlertViewDelegate del = null;

            _alertView = new UIAlertView(dialog.Title, dialog.Content, del, "Ok", null);
        }
Beispiel #16
0
 public static void Show(PortableMessageDialog dialog)
 {
 }