public async Task <bool> MultipleDeleteContacts() { int count = MegaContactsList.Count(n => n.IsMultiSelected); if (count < 1) { return(false); } var customMessageDialog = new CustomMessageDialog( AppMessages.DeleteMultipleContactsQuestion_Title, String.Format(AppMessages.DeleteMultipleContactsQuestion, count), App.AppInformation, MessageDialogButtons.OkCancel); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveContact)); var helperList = new List <Contact>(count); helperList.AddRange(MegaContactsList.Where(n => n.IsMultiSelected)); foreach (var contact in helperList) { MegaSdk.removeContact(MegaSdk.getContact(contact.Email), new RemoveContactRequestListener(this, contact)); } Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false)); this.IsMultiSelectActive = false; }; return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes); }
public async Task <bool> MultipleRemoveItems() { int count = ChildNodes.Count(n => n.IsMultiSelected); if (count < 1) { return(false); } if (this.CurrentDisplayMode == DriveDisplayMode.RubbishBin || (this.CurrentDisplayMode == DriveDisplayMode.MultiSelect && this.PreviousDisplayMode == DriveDisplayMode.RubbishBin)) { var customMessageDialog = new CustomMessageDialog( AppMessages.MultiSelectRemoveQuestion_Title, String.Format(AppMessages.MultiSelectRemoveQuestion, count), App.AppInformation, MessageDialogButtons.OkCancel, MessageDialogImage.RubbishBin); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveNode)); RemoveOrRubbish(count); }; return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes); } else { var customMessageDialog = new CustomMessageDialog( AppMessages.MultiMoveToRubbishBinQuestion_Title, String.Format(AppMessages.MultiMoveToRubbishBinQuestion, count), App.AppInformation, MessageDialogButtons.OkCancel, MessageDialogImage.RubbishBin); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.NodeToTrash)); RemoveOrRubbish(count); }; return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes); } }
/// <summary> /// Change the API URL. /// </summary> private static async void ChangeApiUrl() { StopChangeApiUrlTimer(); var useStagingServer = SettingsService.LoadSetting <bool>(SettingsResources.UseStagingServer, false); if (!useStagingServer) { var confirmDialog = new CustomMessageDialog("Change to a testing server?", "Are you sure you want to change to a testing server? Your account may run irrecoverable problems.", App.AppInformation, MessageDialogButtons.OkCancel); var result = await confirmDialog.ShowDialogAsync(); confirmDialog.CloseDialog(); if (result != MessageDialogResult.OkYes) { return; } } useStagingServer = !useStagingServer; var newApiUrl = useStagingServer ? AppResources.AR_StagingUrl : AppResources.AR_ApiUrl; MegaSdk.changeApiUrl(newApiUrl); MegaSdkFolderLinks.changeApiUrl(newApiUrl); SettingsService.SaveSetting <bool>(SettingsResources.UseStagingServer, useStagingServer); // If the user is logged in, do a new login with the current session if (Convert.ToBoolean(MegaSdk.isLoggedIn())) { bool fastLoginResult; try { var fastLogin = new FastLoginRequestListenerAsync(); fastLoginResult = await fastLogin.ExecuteAsync(() => MegaSdk.fastLogin(SettingsService.LoadSetting <string>(SettingsResources.UserMegaSession), fastLogin)); } // Do nothing, app is already logging out catch (BadSessionIdException) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Login failed. Bad session ID."); return; } if (fastLoginResult) { // Fetch nodes from MEGA var fetchNodes = new FetchNodesRequestListenerAsync(); var fetchNodesResult = await fetchNodes.ExecuteAsync(() => MegaSdk.fetchNodes(fetchNodes)); if (fetchNodesResult != FetchNodesResult.Success) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Fetch nodes failed."); new CustomMessageDialog(AppMessages.FetchingNodesFailed_Title, AppMessages.FetchingNodesFailed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); } } else { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Resume session failed."); new CustomMessageDialog(UiResources.UI_ResumeSession, AppMessages.AM_ResumeSessionFailed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); } } // Reset the "Camera Uploads" service if is enabled if (MediaService.GetAutoCameraUploadStatus()) { LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Resetting CAMERA UPLOADS service (API URL changed)"); SettingsService.SaveSetting(SettingsResources.CameraUploadsIsEnabled, MediaService.SetAutoCameraUpload(true)); } new CustomMessageDialog(null, "API URL changed", App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); OnApiUrlChanged(); }