//Register new LocalBox part 4 public void EnterPassphrase(LocalBox localBox) { LayoutInflater factory = LayoutInflateHelper.GetLayoutInflater(homeActivity); View viewNewPhrase = factory.Inflate(Resource.Layout.dialog_enter_passphrase, null); EditText editEnterPassphrase = (EditText)viewNewPhrase.FindViewById <EditText> (Resource.Id.editText_dialog_enter_passphrase); var dialogBuilder = new AlertDialog.Builder(homeActivity); dialogBuilder.SetTitle("Passphrase"); dialogBuilder.SetView(viewNewPhrase); dialogBuilder.SetPositiveButton("OK", (EventHandler <DialogClickEventArgs>)null); dialogBuilder.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); var dialog = dialogBuilder.Create(); dialog.Show(); var buttonCancel = dialog.GetButton((int)DialogButtonType.Negative); var buttonAddPassphrase = dialog.GetButton((int)DialogButtonType.Positive); buttonAddPassphrase.Click += async(sender, args) => { string passphrase = editEnterPassphrase.Text; if (String.IsNullOrEmpty(passphrase)) { homeActivity.ShowToast("Passphrase is niet ingevuld"); } else { try { homeActivity.ShowProgressDialog("Uw passphrase controleren. Een ogenblik geduld a.u.b."); bool correctPassphraseEntered = await BusinessLayer.Instance.ValidatePassPhrase(localBox, passphrase); homeActivity.HideProgressDialog(); if (!correctPassphraseEntered) { homeActivity.ShowToast("Passphrase onjuist. Probeer het a.u.b. opnieuw"); } else { dialog.Dismiss(); homeActivity.ShowToast("Passphrase geaccepteerd en Pleiobox succesvol geregistreerd"); homeActivity.menuFragment.UpdateLocalBoxes(); SplashActivity.intentData = null; } } catch (Exception ex) { Insights.Report(ex); homeActivity.HideProgressDialog(); homeActivity.ShowToast("Passphrase verifieren mislukt. Probeer het a.u.b. opnieuw"); } } }; buttonCancel.Click += (sender, args) => { DataLayer.Instance.DeleteLocalBox(localBox.Id); homeActivity.menuFragment.UpdateLocalBoxes(); dialog.Dismiss(); }; }
//Register new LocalBox part 4 public void SetUpPassphrase(LocalBox localBox) { LayoutInflater factory = LayoutInflateHelper.GetLayoutInflater(homeActivity); View viewNewPhrase = factory.Inflate(Resource.Layout.dialog_new_passphrase, null); EditText editNewPassphrase = (EditText)viewNewPhrase.FindViewById <EditText> (Resource.Id.editText_dialog_new_passphrase); EditText editNewPassphraseVerify = (EditText)viewNewPhrase.FindViewById <EditText> (Resource.Id.editText_dialog_new_passphrase_verify); var dialogBuilder = new AlertDialog.Builder(homeActivity); dialogBuilder.SetTitle("Passphrase"); dialogBuilder.SetView(viewNewPhrase); dialogBuilder.SetPositiveButton("OK", (EventHandler <DialogClickEventArgs>)null); dialogBuilder.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); var dialog = dialogBuilder.Create(); dialog.Show(); var buttonCancel = dialog.GetButton((int)DialogButtonType.Negative); var buttonAddPassphrase = dialog.GetButton((int)DialogButtonType.Positive); buttonAddPassphrase.Click += async(sender, args) => { string passphraseOne = editNewPassphrase.Text; string passphraseTwo = editNewPassphraseVerify.Text; if (String.IsNullOrEmpty(passphraseOne)) { homeActivity.ShowToast("Passphrase is niet ingevuld"); } else if (String.IsNullOrEmpty(passphraseTwo)) { homeActivity.ShowToast("U dient uw ingevoerde passphrase te verifieren"); } else { if (!passphraseOne.Equals(passphraseTwo)) { homeActivity.ShowToast("De ingevoerde passphrases komen niet overeen. Corrigeer dit a.u.b."); } else { try { homeActivity.ShowProgressDialog("Passphrase aanmaken. Dit kan enige tijd in beslag nemen. Een ogenblik geduld a.u.b."); bool newPassphraseSucceeded = await BusinessLayer.Instance.SetPublicAndPrivateKey(localBox, passphraseOne); homeActivity.HideProgressDialog(); if (!newPassphraseSucceeded) { homeActivity.ShowToast("Passphrase instellen mislukt. Probeer het a.u.b. opnieuw"); } else { dialog.Dismiss(); homeActivity.ShowToast("LocalBox succesvol geregistreerd"); homeActivity.menuFragment.UpdateLocalBoxes(); SplashActivity.intentData = null; } } catch (Exception ex) { Insights.Report(ex); homeActivity.HideProgressDialog(); homeActivity.ShowToast("Passphrase instellen mislukt. Probeer het a.u.b. opnieuw"); } } } }; buttonCancel.Click += (sender, args) => { DataLayer.Instance.DeleteLocalBox(localBox.Id); homeActivity.menuFragment.UpdateLocalBoxes(); dialog.Dismiss(); }; }
public void ShowNewFolderDialog() { LayoutInflater factory = LayoutInflateHelper.GetLayoutInflater(homeActivity); View viewNewFolder = factory.Inflate(Resource.Layout.dialog_new_folder, null); EditText editTextFolderName = (EditText)viewNewFolder.FindViewById <EditText> (Resource.Id.editText_dialog_folder_name); //Build the dialog var dialogBuilder = new AlertDialog.Builder(homeActivity); dialogBuilder.SetTitle(Resource.String.folder_new); dialogBuilder.SetView(viewNewFolder); dialogBuilder.SetPositiveButton(Resource.String.add, (EventHandler <DialogClickEventArgs>)null); dialogBuilder.SetNegativeButton(Resource.String.cancel, (EventHandler <DialogClickEventArgs>)null); var dialog = dialogBuilder.Create(); dialog.Show(); //Get the buttons var buttonAddFolder = dialog.GetButton((int)DialogButtonType.Positive); var buttonCancel = dialog.GetButton((int)DialogButtonType.Negative); buttonAddFolder.Click += async(sender, args) => { if (String.IsNullOrEmpty(editTextFolderName.Text)) { homeActivity.ShowToast("Naam is niet ingevuld"); } else { homeActivity.ShowProgressDialog("Map wordt aangemaakt. Een ogenblik geduld a.u.b."); try{ int numberOfDirectoriesOpened = ExplorerFragment.openedDirectories.Count; string directoryNameToUploadFileTo = ExplorerFragment.openedDirectories [numberOfDirectoriesOpened - 1]; bool addedSuccesfully = (await DataLayer.Instance.CreateFolder(System.IO.Path.Combine(directoryNameToUploadFileTo, (editTextFolderName.Text)))); dialog.Dismiss(); if (!addedSuccesfully) { homeActivity.HideProgressDialog(); homeActivity.ShowToast("Toevoegen map mislukt. Probeer het a.u.b. opnieuw"); } else { homeActivity.HideProgressDialog(); homeActivity.ShowToast("Map succesvol toegevoegd"); //Refresh data homeActivity.RefreshExplorerFragmentData(); } }catch (Exception ex) { Insights.Report(ex); homeActivity.HideProgressDialog(); homeActivity.ShowToast("Toevoegen map mislukt. Probeer het a.u.b. opnieuw"); } } }; buttonCancel.Click += (sender, args) => { dialog.Dismiss(); }; }