Exemple #1
0
        async Task Transfer(Xamarin.Forms.View element)
        {
            var choice = await App.Current.MainPage.DisplayActionSheet("Transfer profile?", "Cancel", null, "Transfer to another device", "Transfer to this device");


            if (choice.Contains("another"))
            {
                if (await DisplayAlert("Transfer profile out", "This will export your credentials that you can re-import on another device. Your credentials will remain on this device. Do you want to proceed?", "Yes, transfer", "Cancel"))
                {
                    var info = await SettingsService.TransferOut();

                    var bounds = element.GetAbsoluteBounds();

                    await Share.RequestAsync(new ShareTextRequest
                    {
                        PresentationSourceBounds = bounds.ToSystemRectangle(),
                        Title = "Island Tracker for ACNH Backup Codes",
                        Text  = info
                    });

                    Analytics.TrackEvent("Transfer", new Dictionary <string, string>
                    {
                        ["type"] = "out"
                    });
                }
            }
            else if (choice.Contains("this device"))
            {
                if (await DisplayAlert("Transfer in profile?", "Warning! This will start a transfer process that will override your existing profile. Ensure that you have exported your existing profile first as you can not go back. When a new account is imported your Pro status will be reset and you will have to retrieve it again. Do you still want to proceed?", "Yes, transfer in", "Cancel"))
                {
                    var info = await App.Current.MainPage.DisplayPromptAsync("Entry transfer code", "Enter your transfer code that you exported to continue.", "OK", "Cancel");

                    if (string.IsNullOrWhiteSpace(info) || info == "Cancel")
                    {
                        return;
                    }

                    Analytics.TrackEvent("Transfer", new Dictionary <string, string>
                    {
                        ["type"] = "in"
                    });

                    if (await SettingsService.TransferIn(info))
                    {
                        await DisplayAlert("Success", "Your profile has been updated. Ensure you update information in the app and sync with the cloud.");

                        SettingsService.IsPro        = false;
                        SettingsService.NeedsProSync = false;
                    }
                    else
                    {
                        await DisplayAlert("Error", "Please contact support with your transfer code for help.");
                    }
                }
            }
        }