private async void CopyKey()
        {
            var data = new DataPackage();

            data.SetText(this.Value);

            try
            {
                Clipboard.SetContent(data);
                SdkService.MegaSdk.masterKeyExported();
                ToastService.ShowTextNotification(
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyCopied_Title"),
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyCopied"));
            }
            catch (Exception e)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_ERROR, e.Message, e);

                if (DialogService.IsAnyDialogVisible())
                {
                    ToastService.ShowAlertNotification(
                        ResourceService.AppMessages.GetString("AM_RecoveryKeyCopiedFailed_Title"),
                        ResourceService.AppMessages.GetString("AM_RecoveryKeyCopiedFailed"));
                    return;
                }

                await DialogService.ShowAlertAsync(
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyCopiedFailed_Title"),
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyCopiedFailed"));
            }
        }
        /// <summary>
        /// Clear all the offline content of the app
        /// </summary>
        private async void ClearOffline()
        {
            var result = await DialogService.ShowOkCancelAsync(
                ResourceService.UiResources.GetString("UI_ClearOffline"),
                ResourceService.AppMessages.GetString("AM_ClearOfflineQuestion"),
                TwoButtonsDialogType.YesNo);

            if (!result)
            {
                return;
            }

            if (await AppService.ClearOfflineAsync())
            {
                ToastService.ShowTextNotification(
                    ResourceService.AppMessages.GetString("AM_ClearOfflineSuccess_Title"),
                    ResourceService.AppMessages.GetString("AM_ClearOfflineSuccess"));
            }
            else
            {
                await DialogService.ShowAlertAsync(
                    ResourceService.AppMessages.GetString("AM_ClearOfflineFailed_Title"),
                    ResourceService.AppMessages.GetString("AM_ClearOfflineFailed"));
            }

            this.GetOfflineSize();
        }
Beispiel #3
0
        private async void CloseOtherSessions()
        {
            var result = await DialogService.ShowOkCancelAsync(
                ResourceService.UiResources.GetString("UI_Warning"),
                ResourceService.AppMessages.GetString("AM_CloseOtherSessionsQuestionMessage"),
                TwoButtonsDialogType.YesNo);

            if (!result)
            {
                return;
            }

            var killAllSessions = new KillAllSessionsListenerAsync();

            result = await killAllSessions.ExecuteAsync(() =>
                                                        this.MegaSdk.killAllSessions(killAllSessions));

            if (!result)
            {
                await DialogService.ShowAlertAsync(
                    ResourceService.UiResources.GetString("UI_Warning"),
                    ResourceService.AppMessages.GetString("AM_CloseOtherSessionsFailed"));

                return;
            }

            ToastService.ShowTextNotification(
                ResourceService.UiResources.GetString("UI_CloseOtherSessions"),
                ResourceService.AppMessages.GetString("AM_CloseOtherSessionsSuccess"));
        }
Beispiel #4
0
        private async void ApiUrlChanged(object sender, EventArgs e)
        {
            // If the user is logged in, do a new login with the current session
            if (Convert.ToBoolean(MegaSdk.isLoggedIn()))
            {
                await this.FastLoginAsync(ResourceService.ProgressMessages.GetString("PM_Reloading"));
            }

            SettingsService.ReloadSettings();

            ToastService.ShowTextNotification("API URL changed");
        }
Beispiel #5
0
        /// <summary>
        /// Clear the app cache
        /// </summary>
        private async void ClearCache()
        {
            if (await AppService.ClearAppCacheAsync())
            {
                ToastService.ShowTextNotification(
                    ResourceService.AppMessages.GetString("AM_CacheCleared_Title"),
                    ResourceService.AppMessages.GetString("AM_CacheCleared"));
            }
            else
            {
                await DialogService.ShowAlertAsync(
                    ResourceService.AppMessages.GetString("AM_ClearCacheFailed_Title"),
                    ResourceService.AppMessages.GetString("AM_ClearCacheFailed"));
            }

            this.GetAppCacheSize();
        }
        private async Task <bool> SaveKey()
        {
            var file = await FileService.SaveFile(new KeyValuePair <string, IList <string> >(
                                                      ResourceService.UiResources.GetString("UI_PlainText"), new List <string>()
            {
                ".txt"
            }),
                                                  ResourceService.AppResources.GetString("AR_RecoveryKeyFileName"));

            if (file == null)
            {
                return(false);
            }
            try
            {
                await FileIO.WriteTextAsync(file, this.Value);

                SdkService.MegaSdk.masterKeyExported();
                ToastService.ShowTextNotification(
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyExported_Title"),
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyExported"));
                return(true);
            }
            catch (Exception e)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_ERROR, e.Message, e);

                if (DialogService.IsAnyDialogVisible())
                {
                    ToastService.ShowAlertNotification(
                        ResourceService.AppMessages.GetString("AM_RecoveryKeyExportFailed_Title"),
                        ResourceService.AppMessages.GetString("AM_RecoveryKeyExportFailed"));
                    return(false);
                }

                await DialogService.ShowAlertAsync(
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyExportFailed_Title"),
                    ResourceService.AppMessages.GetString("AM_RecoveryKeyExportFailed"));

                return(false);
            }
        }
Beispiel #7
0
        private async void CopySeed()
        {
            try
            {
                var data = new DataPackage();
                data.SetText(this.MultiFactorAuthCode);

                Clipboard.SetContent(data);

                ToastService.ShowTextNotification(
                    ResourceService.AppMessages.GetString("AM_MFA_SeedCopied_Title"),
                    ResourceService.AppMessages.GetString("AM_MFA_SeedCopied"));
            }
            catch (Exception e)
            {
                LogService.Log(MLogLevel.LOG_LEVEL_ERROR, e.Message, e);
                await DialogService.ShowAlertAsync(
                    ResourceService.AppMessages.GetString("AM_MFA_SeedCopiedFailed_Title"),
                    ResourceService.AppMessages.GetString("AM_MFA_SeedCopiedFailed"));
            }
        }