private void Init() { // Name NameCell = new FormEntryCell(AppResources.Name); if (!string.IsNullOrWhiteSpace(_defaultName)) { NameCell.Entry.Text = _defaultName; } // Notes NotesCell = new FormEditorCell(Keyboard.Text, _type == CipherType.SecureNote ? 500 : 180); // Folders var folderOptions = new List <string> { AppResources.FolderNone }; Folders = _folderService.GetAllAsync().GetAwaiter().GetResult() .OrderBy(f => f.Name?.Decrypt()).ToList(); var selectedIndex = 0; var i = 1; foreach (var folder in Folders) { if (folder.Id == _defaultFolderId) { selectedIndex = i; } folderOptions.Add(folder.Name.Decrypt()); i++; } FolderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); FolderCell.Picker.SelectedIndex = selectedIndex; // Favorite FavoriteCell = new ExtendedSwitchCell { Text = AppResources.Favorite }; InitTable(); InitSave(); Title = AppResources.AddItem; Content = Table; if (Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
private void Init() { var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); CodeCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); CodeCell.Entry.Keyboard = Keyboard.Numeric; CodeCell.Entry.ReturnType = Enums.ReturnType.Go; CodeCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = true, NoFooter = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection() { CodeCell } } }; var codeLabel = new Label { Text = AppResources.EnterVerificationCode, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var lostAppButton = new ExtendedButton { Text = AppResources.Lost2FAApp, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(() => Lost2FAApp()), Uppercase = false, BackgroundColor = Color.Transparent }; var layout = new StackLayout { Children = { table, codeLabel, lostAppButton }, Spacing = 0 }; var scrollView = new ScrollView { Content = layout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var continueToolbarItem = new ToolbarItem(AppResources.Continue, null, async() => { await LogIn(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(continueToolbarItem); Title = AppResources.VerificationCode; Content = scrollView; }
private void Init() { NameCell = new FormEntryCell(AppResources.Name); var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { NameCell } } }; if(Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () => { if(_lastAction.LastActionWasRecent()) { return; } _lastAction = DateTime.UtcNow; if(!_connectivity.IsConnected) { AlertNoConnection(); return; } if(string.IsNullOrWhiteSpace(NameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } var folder = new Folder { Name = NameCell.Entry.Text.Encrypt() }; _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveResult = await _folderService.SaveAsync(folder); _userDialogs.HideLoading(); if(saveResult.Succeeded) { _userDialogs.Toast(AppResources.FolderCreated); _googleAnalyticsService.TrackAppEvent("CreatedFolder"); await Navigation.PopForDeviceAsync(); } else if(saveResult.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveResult.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }, ToolbarItemOrder.Default, 0); Title = AppResources.AddFolder; Content = table; ToolbarItems.Add(saveToolBarItem); if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
public void Init() { var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = false, VerticalOptions = LayoutOptions.Start, NoFooter = true, Root = new TableRoot { new TableSection { PasswordCell } } }; var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new StackLayout { Spacing = 10, Children = { table, logoutButton } }; var scrollView = new ScrollView { Content = stackLayout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var loginToolbarItem = new ToolbarItem("Submit", null, async() => { await CheckPasswordAsync(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(loginToolbarItem); Title = "Verify Master Password"; Content = scrollView; }
private void Init() { MessagingCenter.Send(Application.Current, "ShowStatusBar", true); var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope", containerPadding: padding); var lastLoginEmail = _settings.GetValueOrDefault(Constants.LastLoginEmail, string.Empty); if (!string.IsNullOrWhiteSpace(_email)) { EmailCell.Entry.Text = _email; } else if (!string.IsNullOrWhiteSpace(lastLoginEmail)) { EmailCell.Entry.Text = lastLoginEmail; } PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = true, NoFooter = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection() { EmailCell, PasswordCell } } }; var forgotPasswordButton = new ExtendedButton { Text = AppResources.GetPasswordHint, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(async() => await ForgotPasswordAsync()), Uppercase = false, BackgroundColor = Color.Transparent }; var layout = new StackLayout { Children = { table, forgotPasswordButton }, Spacing = Device.OnPlatform(iOS: 0, Android: 10, WinPhone: 0) }; var scrollView = new ScrollView { Content = layout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () => { MessagingCenter.Send(Application.Current, "ShowStatusBar", false); })); } var loginToolbarItem = new ToolbarItem(AppResources.LogIn, null, async() => { await LogIn(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(loginToolbarItem); Title = AppResources.Bitwarden; Content = scrollView; NavigationPage.SetBackButtonTitle(this, AppResources.LogIn); }
private void Init() { SubscribeYubiKey(true); if (_providers.Count > 1) { var sendEmailTask = SendEmailAsync(false); } ToolbarItems.Clear(); var scrollView = new ScrollView(); var anotherMethodButton = new ExtendedButton { Text = AppResources.UseAnotherTwoStepMethod, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 25), Command = new Command(() => AnotherMethodAsync()), Uppercase = false, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start }; var instruction = new Label { LineBreakMode = LineBreakMode.WordWrap, Margin = new Thickness(15), HorizontalTextAlignment = TextAlignment.Center }; RememberCell = new ExtendedSwitchCell { Text = AppResources.RememberMe, On = false }; if (!_providerType.HasValue) { instruction.Text = AppResources.NoTwoStepAvailable; var layout = new StackLayout { Children = { instruction, anotherMethodButton }, Spacing = 0 }; scrollView.Content = layout; Title = AppResources.LoginUnavailable; Content = scrollView; } else if (_providerType.Value == TwoFactorProviderType.Authenticator || _providerType.Value == TwoFactorProviderType.Email) { var continueToolbarItem = new ToolbarItem(AppResources.Continue, Helpers.ToolbarImage("login.png"), async() => { var token = TokenCell?.Entry.Text.Trim().Replace(" ", ""); await LogInAsync(token); }, ToolbarItemOrder.Default, 0); var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); TokenCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); TokenCell.Entry.Keyboard = Keyboard.Numeric; TokenCell.Entry.ReturnType = ReturnType.Go; var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { TokenCell, RememberCell }); var layout = new RedrawableStackLayout { Children = { instruction, table }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; switch (_providerType.Value) { case TwoFactorProviderType.Authenticator: instruction.Text = AppResources.EnterVerificationCodeApp; layout.Children.Add(anotherMethodButton); break; case TwoFactorProviderType.Email: var emailParams = _providers[TwoFactorProviderType.Email]; var redactedEmail = emailParams["Email"].ToString(); instruction.Text = string.Format(AppResources.EnterVerificationCodeEmail, redactedEmail); var resendEmailButton = new ExtendedButton { Text = AppResources.SendVerificationCodeAgain, Style = (Style)Application.Current.Resources["btn-primaryAccent"], Margin = new Thickness(15, 0, 15, 0), Command = new Command(async() => await SendEmailAsync(true)), Uppercase = false, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start }; layout.Children.Add(resendEmailButton); layout.Children.Add(anotherMethodButton); break; default: break; } ToolbarItems.Add(continueToolbarItem); Title = AppResources.VerificationCode; Content = scrollView; TokenCell.Entry.FocusWithDelay(); } else if (_providerType == TwoFactorProviderType.Duo) { var duoParams = _providers[TwoFactorProviderType.Duo]; var host = WebUtility.UrlEncode(duoParams["Host"].ToString()); var req = WebUtility.UrlEncode(duoParams["Signature"].ToString()); var webVaultUrl = "https://vault.bitwarden.com"; if (!string.IsNullOrWhiteSpace(_appSettingsService.BaseUrl)) { webVaultUrl = _appSettingsService.BaseUrl; } else if (!string.IsNullOrWhiteSpace(_appSettingsService.WebVaultUrl)) { webVaultUrl = _appSettingsService.WebVaultUrl; } var webView = new HybridWebView { Uri = $"{webVaultUrl}/duo-connector.html?host={host}&request={req}", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, MinimumHeightRequest = 400 }; webView.RegisterAction(async(sig) => { await LogInAsync(sig); }); var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { RememberCell }); var layout = new RedrawableStackLayout { Children = { webView, table, anotherMethodButton }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; Title = "Duo"; Content = scrollView; } else if (_providerType == TwoFactorProviderType.YubiKey) { instruction.Text = AppResources.YubiKeyInstruction; var image = new CachedImage { Source = "yubikey", VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Center, WidthRequest = 266, HeightRequest = 160, Margin = new Thickness(0, 0, 0, 25) }; var table = new TwoFactorTable( new TableSection(Helpers.GetEmptyTableSectionTitle()) { RememberCell }); var layout = new RedrawableStackLayout { Children = { instruction, image, table, anotherMethodButton }, Spacing = 0 }; table.WrappingStackLayout = () => layout; scrollView.Content = layout; Title = AppResources.YubiKeyTitle; Content = scrollView; } }
private void InitTable() { AttachmentsCell = new ExtendedTextCell { Text = AppResources.Attachments, ShowDisclousure = true }; CustomFieldsCell = new ExtendedTextCell { Text = AppResources.CustomFields, ShowDisclousure = true }; // Sections TopSection = new TableSection(AppResources.ItemInformation) { NameCell }; MiddleSection = new TableSection(Helpers.GetEmptyTableSectionTitle()) { FolderCell, FavoriteCell, AttachmentsCell, CustomFieldsCell }; // Types if (Cipher.Type == CipherType.Login) { LoginTotpCell = new FormEntryCell(AppResources.AuthenticatorKey, nextElement: NotesCell.Editor, useButton: _deviceInfo.HasCamera); if (_deviceInfo.HasCamera) { LoginTotpCell.Button.Image = "camera.png"; } LoginTotpCell.Entry.Text = Cipher.Login?.Totp?.Decrypt(Cipher.OrganizationId); LoginTotpCell.Entry.DisableAutocapitalize = true; LoginTotpCell.Entry.Autocorrect = false; LoginTotpCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier"); LoginPasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: LoginTotpCell.Entry, useButton: true); LoginPasswordCell.Entry.Text = Cipher.Login?.Password?.Decrypt(Cipher.OrganizationId); LoginPasswordCell.Button.Image = "eye.png"; LoginPasswordCell.Entry.DisableAutocapitalize = true; LoginPasswordCell.Entry.Autocorrect = false; LoginPasswordCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier"); LoginGenerateCell = new ExtendedTextCell { Text = AppResources.GeneratePassword, ShowDisclousure = true }; LoginUsernameCell = new FormEntryCell(AppResources.Username, nextElement: LoginPasswordCell.Entry); LoginUsernameCell.Entry.Text = Cipher.Login?.Username?.Decrypt(Cipher.OrganizationId); LoginUsernameCell.Entry.DisableAutocapitalize = true; LoginUsernameCell.Entry.Autocorrect = false; LoginUriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: LoginUsernameCell.Entry); LoginUriCell.Entry.Text = Cipher.Login?.Uri?.Decrypt(Cipher.OrganizationId); // Name NameCell.NextElement = LoginUriCell.Entry; // Build sections TopSection.Add(LoginUriCell); TopSection.Add(LoginUsernameCell); TopSection.Add(LoginPasswordCell); TopSection.Add(LoginGenerateCell); MiddleSection.Insert(0, LoginTotpCell); } else if (Cipher.Type == CipherType.Card) { CardCodeCell = new FormEntryCell(AppResources.SecurityCode, Keyboard.Numeric, nextElement: NotesCell.Editor); CardCodeCell.Entry.Text = Cipher.Card.Code?.Decrypt(Cipher.OrganizationId); CardExpYearCell = new FormEntryCell(AppResources.ExpirationYear, Keyboard.Numeric, nextElement: CardCodeCell.Entry); CardExpYearCell.Entry.Text = Cipher.Card.ExpYear?.Decrypt(Cipher.OrganizationId); var month = Cipher.Card.ExpMonth?.Decrypt(Cipher.OrganizationId); CardExpMonthCell = new FormPickerCell(AppResources.ExpirationMonth, new string[] { "--", AppResources.January, AppResources.February, AppResources.March, AppResources.April, AppResources.May, AppResources.June, AppResources.July, AppResources.August, AppResources.September, AppResources.October, AppResources.November, AppResources.December }); if (!string.IsNullOrWhiteSpace(month) && int.TryParse(month, out int monthIndex)) { CardExpMonthCell.Picker.SelectedIndex = monthIndex; } else { CardExpMonthCell.Picker.SelectedIndex = 0; } var brandOptions = new string[] { "--", "Visa", "Mastercard", "American Express", "Discover", "Diners Club", "JCB", "Maestro", "UnionPay", AppResources.Other }; var brand = Cipher.Card.Brand?.Decrypt(Cipher.OrganizationId); CardBrandCell = new FormPickerCell(AppResources.Brand, brandOptions); CardBrandCell.Picker.SelectedIndex = 0; if (!string.IsNullOrWhiteSpace(brand)) { var i = 0; foreach (var o in brandOptions) { var option = o; if (option == AppResources.Other) { option = "Other"; } if (option == brand) { CardBrandCell.Picker.SelectedIndex = i; break; } i++; } } CardNumberCell = new FormEntryCell(AppResources.Number, Keyboard.Numeric); CardNumberCell.Entry.Text = Cipher.Card.Number?.Decrypt(Cipher.OrganizationId); CardNameCell = new FormEntryCell(AppResources.CardholderName, nextElement: CardNumberCell.Entry); CardNameCell.Entry.Text = Cipher.Card.CardholderName?.Decrypt(Cipher.OrganizationId); // Name NameCell.NextElement = CardNameCell.Entry; // Build sections TopSection.Add(CardNameCell); TopSection.Add(CardNumberCell); TopSection.Add(CardBrandCell); TopSection.Add(CardExpMonthCell); TopSection.Add(CardExpYearCell); TopSection.Add(CardCodeCell); } else if (Cipher.Type == CipherType.Identity) { IdCountryCell = new FormEntryCell(AppResources.Country, nextElement: NotesCell.Editor); IdCountryCell.Entry.Text = Cipher.Identity.Country?.Decrypt(Cipher.OrganizationId); IdPostalCodeCell = new FormEntryCell(AppResources.ZipPostalCode, nextElement: IdCountryCell.Entry); IdPostalCodeCell.Entry.Text = Cipher.Identity.PostalCode?.Decrypt(Cipher.OrganizationId); IdPostalCodeCell.Entry.DisableAutocapitalize = true; IdPostalCodeCell.Entry.Autocorrect = false; IdStateCell = new FormEntryCell(AppResources.StateProvince, nextElement: IdPostalCodeCell.Entry); IdStateCell.Entry.Text = Cipher.Identity.State?.Decrypt(Cipher.OrganizationId); IdCityCell = new FormEntryCell(AppResources.CityTown, nextElement: IdStateCell.Entry); IdCityCell.Entry.Text = Cipher.Identity.City?.Decrypt(Cipher.OrganizationId); IdAddress3Cell = new FormEntryCell(AppResources.Address3, nextElement: IdCityCell.Entry); IdAddress3Cell.Entry.Text = Cipher.Identity.Address3?.Decrypt(Cipher.OrganizationId); IdAddress2Cell = new FormEntryCell(AppResources.Address2, nextElement: IdAddress3Cell.Entry); IdAddress2Cell.Entry.Text = Cipher.Identity.Address2?.Decrypt(Cipher.OrganizationId); IdAddress1Cell = new FormEntryCell(AppResources.Address1, nextElement: IdAddress2Cell.Entry); IdAddress1Cell.Entry.Text = Cipher.Identity.Address1?.Decrypt(Cipher.OrganizationId); IdPhoneCell = new FormEntryCell(AppResources.Phone, nextElement: IdAddress1Cell.Entry); IdPhoneCell.Entry.Text = Cipher.Identity.Phone?.Decrypt(Cipher.OrganizationId); IdPhoneCell.Entry.DisableAutocapitalize = true; IdPhoneCell.Entry.Autocorrect = false; IdEmailCell = new FormEntryCell(AppResources.Email, Keyboard.Email, nextElement: IdPhoneCell.Entry); IdEmailCell.Entry.Text = Cipher.Identity.Email?.Decrypt(Cipher.OrganizationId); IdEmailCell.Entry.DisableAutocapitalize = true; IdEmailCell.Entry.Autocorrect = false; IdLicenseNumberCell = new FormEntryCell(AppResources.LicenseNumber, nextElement: IdEmailCell.Entry); IdLicenseNumberCell.Entry.Text = Cipher.Identity.LicenseNumber?.Decrypt(Cipher.OrganizationId); IdLicenseNumberCell.Entry.DisableAutocapitalize = true; IdLicenseNumberCell.Entry.Autocorrect = false; IdPassportNumberCell = new FormEntryCell(AppResources.PassportNumber, nextElement: IdLicenseNumberCell.Entry); IdPassportNumberCell.Entry.Text = Cipher.Identity.PassportNumber?.Decrypt(Cipher.OrganizationId); IdPassportNumberCell.Entry.DisableAutocapitalize = true; IdPassportNumberCell.Entry.Autocorrect = false; IdSsnCell = new FormEntryCell(AppResources.SSN, nextElement: IdPassportNumberCell.Entry); IdSsnCell.Entry.Text = Cipher.Identity.SSN?.Decrypt(Cipher.OrganizationId); IdSsnCell.Entry.DisableAutocapitalize = true; IdSsnCell.Entry.Autocorrect = false; IdCompanyCell = new FormEntryCell(AppResources.Company, nextElement: IdSsnCell.Entry); IdCompanyCell.Entry.Text = Cipher.Identity.Company?.Decrypt(Cipher.OrganizationId); IdUsernameCell = new FormEntryCell(AppResources.Username, nextElement: IdCompanyCell.Entry); IdUsernameCell.Entry.Text = Cipher.Identity.Username?.Decrypt(Cipher.OrganizationId); IdUsernameCell.Entry.DisableAutocapitalize = true; IdUsernameCell.Entry.Autocorrect = false; IdLastNameCell = new FormEntryCell(AppResources.LastName, nextElement: IdUsernameCell.Entry); IdLastNameCell.Entry.Text = Cipher.Identity.LastName?.Decrypt(Cipher.OrganizationId); IdMiddleNameCell = new FormEntryCell(AppResources.MiddleName, nextElement: IdLastNameCell.Entry); IdMiddleNameCell.Entry.Text = Cipher.Identity.MiddleName?.Decrypt(Cipher.OrganizationId); IdFirstNameCell = new FormEntryCell(AppResources.FirstName, nextElement: IdMiddleNameCell.Entry); IdFirstNameCell.Entry.Text = Cipher.Identity.FirstName?.Decrypt(Cipher.OrganizationId); var titleOptions = new string[] { "--", AppResources.Mr, AppResources.Mrs, AppResources.Ms, AppResources.Dr }; IdTitleCell = new FormPickerCell(AppResources.Title, titleOptions); var title = Cipher.Identity.Title?.Decrypt(Cipher.OrganizationId); IdTitleCell.Picker.SelectedIndex = 0; if (!string.IsNullOrWhiteSpace(title)) { var i = 0; foreach (var o in titleOptions) { i++; if (o == title) { IdTitleCell.Picker.SelectedIndex = i; break; } } } // Name NameCell.NextElement = IdFirstNameCell.Entry; // Build sections TopSection.Add(IdTitleCell); TopSection.Add(IdFirstNameCell); TopSection.Add(IdMiddleNameCell); TopSection.Add(IdLastNameCell); TopSection.Add(IdUsernameCell); TopSection.Add(IdCompanyCell); TopSection.Add(IdSsnCell); TopSection.Add(IdPassportNumberCell); TopSection.Add(IdLicenseNumberCell); TopSection.Add(IdEmailCell); TopSection.Add(IdPhoneCell); TopSection.Add(IdAddress1Cell); TopSection.Add(IdAddress2Cell); TopSection.Add(IdAddress3Cell); TopSection.Add(IdCityCell); TopSection.Add(IdStateCell); TopSection.Add(IdPostalCodeCell); TopSection.Add(IdCountryCell); } else if (Cipher.Type == CipherType.SecureNote) { // Name NameCell.NextElement = NotesCell.Editor; } // Make table TableRoot = new TableRoot { TopSection, MiddleSection, new TableSection(AppResources.Notes) { NotesCell }, new TableSection(Helpers.GetEmptyTableSectionTitle()) { DeleteCell } }; Table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = TableRoot }; if (Device.RuntimePlatform == Device.iOS) { Table.RowHeight = -1; Table.EstimatedRowHeight = 70; } }
public void Init() { var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true, useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding); PasswordCell.Entry.TargetReturnType = Enums.ReturnType.Go; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = false, VerticalOptions = LayoutOptions.Start, NoFooter = true, Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { PasswordCell } } }; var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async() => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], BackgroundColor = Color.Transparent, Uppercase = false }; var stackLayout = new RedrawableStackLayout { Spacing = 10, Children = { table, logoutButton } }; table.WrappingStackLayout = () => stackLayout; var scrollView = new ScrollView { Content = stackLayout }; if (Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() => { await CheckPasswordAsync(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(loginToolbarItem); Title = AppResources.VerifyMasterPassword; Content = scrollView; }
private void InitTable() { // Sections TopSection = new TableSection(AppResources.ItemInformation) { NameCell }; MiddleSection = new TableSection(Helpers.GetEmptyTableSectionTitle()) { FolderCell, FavoriteCell }; if (_type == CipherType.Login) { LoginTotpCell = new FormEntryCell(AppResources.AuthenticatorKey, nextElement: NotesCell.Editor, useButton: _deviceInfo.HasCamera); if (_deviceInfo.HasCamera) { LoginTotpCell.Button.Image = "camera.png"; } LoginTotpCell.Entry.DisableAutocapitalize = true; LoginTotpCell.Entry.Autocorrect = false; LoginTotpCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); LoginPasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: LoginTotpCell.Entry, useButton: true); LoginPasswordCell.Button.Image = "eye.png"; LoginPasswordCell.Entry.DisableAutocapitalize = true; LoginPasswordCell.Entry.Autocorrect = false; LoginPasswordCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); if (!string.IsNullOrWhiteSpace(_defaultPassword)) { LoginPasswordCell.Entry.Text = _defaultPassword; } LoginGenerateCell = new ExtendedTextCell { Text = AppResources.GeneratePassword, ShowDisclousure = true }; LoginUsernameCell = new FormEntryCell(AppResources.Username, nextElement: LoginPasswordCell.Entry); LoginUsernameCell.Entry.DisableAutocapitalize = true; LoginUsernameCell.Entry.Autocorrect = false; if (!string.IsNullOrWhiteSpace(_defaultUsername)) { LoginUsernameCell.Entry.Text = _defaultUsername; } LoginUriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: LoginUsernameCell.Entry); if (!string.IsNullOrWhiteSpace(_defaultUri)) { LoginUriCell.Entry.Text = _defaultUri; } NameCell.NextElement = LoginUriCell.Entry; // Build sections TopSection.Add(LoginUriCell); TopSection.Add(LoginUsernameCell); TopSection.Add(LoginPasswordCell); TopSection.Add(LoginGenerateCell); MiddleSection.Insert(0, LoginTotpCell); } else if (_type == CipherType.Card) { CardCodeCell = new FormEntryCell(AppResources.SecurityCode, Keyboard.Numeric, nextElement: NotesCell.Editor); if (!string.IsNullOrWhiteSpace(_defaultCardCode)) { CardCodeCell.Entry.Text = _defaultCardCode; } CardExpYearCell = new FormEntryCell(AppResources.ExpirationYear, Keyboard.Numeric, nextElement: CardCodeCell.Entry); if (!string.IsNullOrWhiteSpace(_defaultCardExpYear)) { CardExpYearCell.Entry.Text = _defaultCardExpYear; } CardExpMonthCell = new FormPickerCell(AppResources.ExpirationMonth, new string[] { "--", AppResources.January, AppResources.February, AppResources.March, AppResources.April, AppResources.May, AppResources.June, AppResources.July, AppResources.August, AppResources.September, AppResources.October, AppResources.November, AppResources.December }); if (_defaultCardExpMonth.HasValue) { CardExpMonthCell.Picker.SelectedIndex = _defaultCardExpMonth.Value; } CardBrandCell = new FormPickerCell(AppResources.Brand, new string[] { "--", "Visa", "Mastercard", "American Express", "Discover", "Diners Club", "JCB", "Maestro", "UnionPay", AppResources.Other }); CardNumberCell = new FormEntryCell(AppResources.Number, Keyboard.Numeric); if (!string.IsNullOrWhiteSpace(_defaultCardNumber)) { CardNumberCell.Entry.Text = _defaultCardNumber; } CardNameCell = new FormEntryCell(AppResources.CardholderName, nextElement: CardNumberCell.Entry); if (!string.IsNullOrWhiteSpace(_defaultCardName)) { CardNameCell.Entry.Text = _defaultCardName; } NameCell.NextElement = CardNameCell.Entry; // Build sections TopSection.Add(CardNameCell); TopSection.Add(CardNumberCell); TopSection.Add(CardBrandCell); TopSection.Add(CardExpMonthCell); TopSection.Add(CardExpYearCell); TopSection.Add(CardCodeCell); } else if (_type == CipherType.Identity) { IdCountryCell = new FormEntryCell(AppResources.Country, nextElement: NotesCell.Editor); IdPostalCodeCell = new FormEntryCell(AppResources.ZipPostalCode, nextElement: IdCountryCell.Entry); IdPostalCodeCell.Entry.DisableAutocapitalize = true; IdPostalCodeCell.Entry.Autocorrect = false; IdStateCell = new FormEntryCell(AppResources.StateProvince, nextElement: IdPostalCodeCell.Entry); IdCityCell = new FormEntryCell(AppResources.CityTown, nextElement: IdStateCell.Entry); IdAddress3Cell = new FormEntryCell(AppResources.Address3, nextElement: IdCityCell.Entry); IdAddress2Cell = new FormEntryCell(AppResources.Address2, nextElement: IdAddress3Cell.Entry); IdAddress1Cell = new FormEntryCell(AppResources.Address1, nextElement: IdAddress2Cell.Entry); IdPhoneCell = new FormEntryCell(AppResources.Phone, nextElement: IdAddress1Cell.Entry); IdPhoneCell.Entry.DisableAutocapitalize = true; IdPhoneCell.Entry.Autocorrect = false; IdEmailCell = new FormEntryCell(AppResources.Email, Keyboard.Email, nextElement: IdPhoneCell.Entry); IdEmailCell.Entry.DisableAutocapitalize = true; IdEmailCell.Entry.Autocorrect = false; IdLicenseNumberCell = new FormEntryCell(AppResources.LicenseNumber, nextElement: IdEmailCell.Entry); IdLicenseNumberCell.Entry.DisableAutocapitalize = true; IdLicenseNumberCell.Entry.Autocorrect = false; IdPassportNumberCell = new FormEntryCell(AppResources.PassportNumber, nextElement: IdLicenseNumberCell.Entry); IdPassportNumberCell.Entry.DisableAutocapitalize = true; IdPassportNumberCell.Entry.Autocorrect = false; IdSsnCell = new FormEntryCell(AppResources.SSN, nextElement: IdPassportNumberCell.Entry); IdSsnCell.Entry.DisableAutocapitalize = true; IdSsnCell.Entry.Autocorrect = false; IdCompanyCell = new FormEntryCell(AppResources.Company, nextElement: IdSsnCell.Entry); IdUsernameCell = new FormEntryCell(AppResources.Username, nextElement: IdCompanyCell.Entry); IdUsernameCell.Entry.DisableAutocapitalize = true; IdUsernameCell.Entry.Autocorrect = false; IdLastNameCell = new FormEntryCell(AppResources.LastName, nextElement: IdUsernameCell.Entry); IdMiddleNameCell = new FormEntryCell(AppResources.MiddleName, nextElement: IdLastNameCell.Entry); IdFirstNameCell = new FormEntryCell(AppResources.FirstName, nextElement: IdMiddleNameCell.Entry); IdTitleCell = new FormPickerCell(AppResources.Title, new string[] { "--", AppResources.Mr, AppResources.Mrs, AppResources.Ms, AppResources.Dr }); // Name NameCell.NextElement = IdFirstNameCell.Entry; // Build sections TopSection.Add(IdTitleCell); TopSection.Add(IdFirstNameCell); TopSection.Add(IdMiddleNameCell); TopSection.Add(IdLastNameCell); TopSection.Add(IdUsernameCell); TopSection.Add(IdCompanyCell); TopSection.Add(IdSsnCell); TopSection.Add(IdPassportNumberCell); TopSection.Add(IdLicenseNumberCell); TopSection.Add(IdEmailCell); TopSection.Add(IdPhoneCell); TopSection.Add(IdAddress1Cell); TopSection.Add(IdAddress2Cell); TopSection.Add(IdAddress3Cell); TopSection.Add(IdCityCell); TopSection.Add(IdStateCell); TopSection.Add(IdPostalCodeCell); TopSection.Add(IdCountryCell); } else if (_type == CipherType.SecureNote) { // Name NameCell.NextElement = NotesCell.Editor; } // Make table TableRoot = new TableRoot { TopSection, MiddleSection, new TableSection(AppResources.Notes) { NotesCell } }; Table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = TableRoot }; if (Device.RuntimePlatform == Device.iOS) { Table.RowHeight = -1; Table.EstimatedRowHeight = 70; } else if (Device.RuntimePlatform == Device.Android) { Table.BottomPadding = 50; } }
private void Init() { MessagingCenter.Send(Application.Current, "ShowStatusBar", true); var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); PasswordHintCell = new FormEntryCell(AppResources.MasterPasswordHint, useLabelAsPlaceholder: true, imageSource: "lightbulb.png", containerPadding: padding); ConfirmPasswordCell = new FormEntryCell(AppResources.RetypeMasterPassword, isPassword: true, nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding); PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true, nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding); EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope.png", containerPadding: padding); PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done; var table = new FormTableView(this) { Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { EmailCell, PasswordCell } } }; PasswordLabel = new Label { Text = AppResources.MasterPasswordDescription, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var table2 = new FormTableView(this) { NoHeader = true, Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { ConfirmPasswordCell, PasswordHintCell } } }; HintLabel = new Label { Text = AppResources.MasterPasswordHintDescription, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; StackLayout = new RedrawableStackLayout { Children = { table, PasswordLabel, table2, HintLabel }, Spacing = 0 }; var scrollView = new ScrollView { Content = StackLayout }; var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() => { await Register(); }, ToolbarItemOrder.Default, 0); if (Device.RuntimePlatform == Device.iOS) { table.RowHeight = table2.RowHeight = -1; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () => { MessagingCenter.Send(Application.Current, "ShowStatusBar", false); })); } ToolbarItems.Add(loginToolbarItem); Title = AppResources.CreateAccount; Content = scrollView; }
private void InitTable() { AttachmentsCell = new ExtendedTextCell { Text = AppResources.Attachments, ShowDisclousure = true }; // Sections TopSection = new TableSection(AppResources.ItemInformation) { NameCell }; MiddleSection = new TableSection(Helpers.GetEmptyTableSectionTitle()) { FolderCell, FavoriteCell, AttachmentsCell }; // Types if (Cipher.Type == CipherType.Login) { LoginTotpCell = new FormEntryCell(AppResources.AuthenticatorKey, button1: _deviceInfo.HasCamera ? "camera.png" : null); LoginTotpCell.Entry.Text = Cipher.Login?.Totp?.Decrypt(Cipher.OrganizationId); LoginTotpCell.Entry.DisableAutocapitalize = true; LoginTotpCell.Entry.Autocorrect = false; LoginTotpCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); LoginPasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: LoginTotpCell.Entry, button1: "eye.png", button2: "refresh_alt.png"); LoginPasswordCell.Entry.Text = _originalLoginPassword = Cipher.Login?.Password?.Decrypt(Cipher.OrganizationId); LoginPasswordCell.Entry.DisableAutocapitalize = true; LoginPasswordCell.Entry.Autocorrect = false; LoginPasswordCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); LoginUsernameCell = new FormEntryCell(AppResources.Username, nextElement: LoginPasswordCell.Entry); LoginUsernameCell.Entry.Text = Cipher.Login?.Username?.Decrypt(Cipher.OrganizationId); LoginUsernameCell.Entry.DisableAutocapitalize = true; LoginUsernameCell.Entry.Autocorrect = false; // Name NameCell.NextElement = LoginUsernameCell.Entry; // Build sections TopSection.Add(LoginUsernameCell); TopSection.Add(LoginPasswordCell); TopSection.Add(LoginTotpCell); // Uris UrisSection = new TableSection(Helpers.GetEmptyTableSectionTitle()); AddUriCell = new ExtendedTextCell { Text = $"+ {AppResources.NewUri}", TextColor = Colors.Primary }; UrisSection.Add(AddUriCell); if (Cipher.Login?.Uris != null) { foreach (var uri in Cipher.Login.Uris) { var value = uri.Uri?.Decrypt(Cipher.OrganizationId); UrisSection.Insert(UrisSection.Count - 1, Helpers.MakeUriCell(value, uri.Match, UrisSection, this)); } } } else if (Cipher.Type == CipherType.Card) { CardCodeCell = new FormEntryCell(AppResources.SecurityCode, Keyboard.Numeric, isPassword: true, nextElement: NotesCell.Editor, button1: "eye.png"); CardCodeCell.Entry.Text = Cipher.Card.Code?.Decrypt(Cipher.OrganizationId); CardCodeCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); CardExpYearCell = new FormEntryCell(AppResources.ExpirationYear, Keyboard.Numeric, nextElement: CardCodeCell.Entry); CardExpYearCell.Entry.Text = Cipher.Card.ExpYear?.Decrypt(Cipher.OrganizationId); var month = Cipher.Card.ExpMonth?.Decrypt(Cipher.OrganizationId); CardExpMonthCell = new FormPickerCell(AppResources.ExpirationMonth, new string[] { "--", AppResources.January, AppResources.February, AppResources.March, AppResources.April, AppResources.May, AppResources.June, AppResources.July, AppResources.August, AppResources.September, AppResources.October, AppResources.November, AppResources.December }); if (!string.IsNullOrWhiteSpace(month) && int.TryParse(month, out int monthIndex)) { CardExpMonthCell.Picker.SelectedIndex = monthIndex; } else { CardExpMonthCell.Picker.SelectedIndex = 0; } var brandOptions = new string[] { "--", "Visa", "Mastercard", "American Express", "Discover", "Diners Club", "JCB", "Maestro", "UnionPay", AppResources.Other }; var brand = Cipher.Card.Brand?.Decrypt(Cipher.OrganizationId); CardBrandCell = new FormPickerCell(AppResources.Brand, brandOptions); CardBrandCell.Picker.SelectedIndex = 0; if (!string.IsNullOrWhiteSpace(brand)) { var i = 0; foreach (var o in brandOptions) { var option = o; if (option == AppResources.Other) { option = "Other"; } if (option == brand) { CardBrandCell.Picker.SelectedIndex = i; break; } i++; } } CardNumberCell = new FormEntryCell(AppResources.Number, Keyboard.Numeric); CardNumberCell.Entry.Text = Cipher.Card.Number?.Decrypt(Cipher.OrganizationId); CardNameCell = new FormEntryCell(AppResources.CardholderName, nextElement: CardNumberCell.Entry); CardNameCell.Entry.Text = Cipher.Card.CardholderName?.Decrypt(Cipher.OrganizationId); // Name NameCell.NextElement = CardNameCell.Entry; // Build sections TopSection.Add(CardNameCell); TopSection.Add(CardNumberCell); TopSection.Add(CardBrandCell); TopSection.Add(CardExpMonthCell); TopSection.Add(CardExpYearCell); TopSection.Add(CardCodeCell); } else if (Cipher.Type == CipherType.Identity) { IdCountryCell = new FormEntryCell(AppResources.Country, nextElement: NotesCell.Editor); IdCountryCell.Entry.Text = Cipher.Identity.Country?.Decrypt(Cipher.OrganizationId); IdPostalCodeCell = new FormEntryCell(AppResources.ZipPostalCode, nextElement: IdCountryCell.Entry); IdPostalCodeCell.Entry.Text = Cipher.Identity.PostalCode?.Decrypt(Cipher.OrganizationId); IdPostalCodeCell.Entry.DisableAutocapitalize = true; IdPostalCodeCell.Entry.Autocorrect = false; IdStateCell = new FormEntryCell(AppResources.StateProvince, nextElement: IdPostalCodeCell.Entry); IdStateCell.Entry.Text = Cipher.Identity.State?.Decrypt(Cipher.OrganizationId); IdCityCell = new FormEntryCell(AppResources.CityTown, nextElement: IdStateCell.Entry); IdCityCell.Entry.Text = Cipher.Identity.City?.Decrypt(Cipher.OrganizationId); IdAddress3Cell = new FormEntryCell(AppResources.Address3, nextElement: IdCityCell.Entry); IdAddress3Cell.Entry.Text = Cipher.Identity.Address3?.Decrypt(Cipher.OrganizationId); IdAddress2Cell = new FormEntryCell(AppResources.Address2, nextElement: IdAddress3Cell.Entry); IdAddress2Cell.Entry.Text = Cipher.Identity.Address2?.Decrypt(Cipher.OrganizationId); IdAddress1Cell = new FormEntryCell(AppResources.Address1, nextElement: IdAddress2Cell.Entry); IdAddress1Cell.Entry.Text = Cipher.Identity.Address1?.Decrypt(Cipher.OrganizationId); IdPhoneCell = new FormEntryCell(AppResources.Phone, nextElement: IdAddress1Cell.Entry); IdPhoneCell.Entry.Text = Cipher.Identity.Phone?.Decrypt(Cipher.OrganizationId); IdPhoneCell.Entry.DisableAutocapitalize = true; IdPhoneCell.Entry.Autocorrect = false; IdEmailCell = new FormEntryCell(AppResources.Email, Keyboard.Email, nextElement: IdPhoneCell.Entry); IdEmailCell.Entry.Text = Cipher.Identity.Email?.Decrypt(Cipher.OrganizationId); IdEmailCell.Entry.DisableAutocapitalize = true; IdEmailCell.Entry.Autocorrect = false; IdLicenseNumberCell = new FormEntryCell(AppResources.LicenseNumber, nextElement: IdEmailCell.Entry); IdLicenseNumberCell.Entry.Text = Cipher.Identity.LicenseNumber?.Decrypt(Cipher.OrganizationId); IdLicenseNumberCell.Entry.DisableAutocapitalize = true; IdLicenseNumberCell.Entry.Autocorrect = false; IdPassportNumberCell = new FormEntryCell(AppResources.PassportNumber, nextElement: IdLicenseNumberCell.Entry); IdPassportNumberCell.Entry.Text = Cipher.Identity.PassportNumber?.Decrypt(Cipher.OrganizationId); IdPassportNumberCell.Entry.DisableAutocapitalize = true; IdPassportNumberCell.Entry.Autocorrect = false; IdSsnCell = new FormEntryCell(AppResources.SSN, nextElement: IdPassportNumberCell.Entry); IdSsnCell.Entry.Text = Cipher.Identity.SSN?.Decrypt(Cipher.OrganizationId); IdSsnCell.Entry.DisableAutocapitalize = true; IdSsnCell.Entry.Autocorrect = false; IdCompanyCell = new FormEntryCell(AppResources.Company, nextElement: IdSsnCell.Entry); IdCompanyCell.Entry.Text = Cipher.Identity.Company?.Decrypt(Cipher.OrganizationId); IdUsernameCell = new FormEntryCell(AppResources.Username, nextElement: IdCompanyCell.Entry); IdUsernameCell.Entry.Text = Cipher.Identity.Username?.Decrypt(Cipher.OrganizationId); IdUsernameCell.Entry.DisableAutocapitalize = true; IdUsernameCell.Entry.Autocorrect = false; IdLastNameCell = new FormEntryCell(AppResources.LastName, nextElement: IdUsernameCell.Entry); IdLastNameCell.Entry.Text = Cipher.Identity.LastName?.Decrypt(Cipher.OrganizationId); IdMiddleNameCell = new FormEntryCell(AppResources.MiddleName, nextElement: IdLastNameCell.Entry); IdMiddleNameCell.Entry.Text = Cipher.Identity.MiddleName?.Decrypt(Cipher.OrganizationId); IdFirstNameCell = new FormEntryCell(AppResources.FirstName, nextElement: IdMiddleNameCell.Entry); IdFirstNameCell.Entry.Text = Cipher.Identity.FirstName?.Decrypt(Cipher.OrganizationId); var titleOptions = new string[] { "--", AppResources.Mr, AppResources.Mrs, AppResources.Ms, AppResources.Dr }; IdTitleCell = new FormPickerCell(AppResources.Title, titleOptions); var title = Cipher.Identity.Title?.Decrypt(Cipher.OrganizationId); IdTitleCell.Picker.SelectedIndex = 0; if (!string.IsNullOrWhiteSpace(title)) { var i = 0; foreach (var o in titleOptions) { i++; if (o == title) { IdTitleCell.Picker.SelectedIndex = i; break; } } } // Name NameCell.NextElement = IdFirstNameCell.Entry; // Build sections TopSection.Add(IdTitleCell); TopSection.Add(IdFirstNameCell); TopSection.Add(IdMiddleNameCell); TopSection.Add(IdLastNameCell); TopSection.Add(IdUsernameCell); TopSection.Add(IdCompanyCell); TopSection.Add(IdSsnCell); TopSection.Add(IdPassportNumberCell); TopSection.Add(IdLicenseNumberCell); TopSection.Add(IdEmailCell); TopSection.Add(IdPhoneCell); TopSection.Add(IdAddress1Cell); TopSection.Add(IdAddress2Cell); TopSection.Add(IdAddress3Cell); TopSection.Add(IdCityCell); TopSection.Add(IdStateCell); TopSection.Add(IdPostalCodeCell); TopSection.Add(IdCountryCell); } else if (Cipher.Type == CipherType.SecureNote) { // Name NameCell.NextElement = NotesCell.Editor; } FieldsSection = new TableSection(AppResources.CustomFields); if (Cipher.Fields != null) { foreach (var field in Cipher.Fields) { var label = field.Name?.Decrypt(Cipher.OrganizationId) ?? string.Empty; var value = field.Value?.Decrypt(Cipher.OrganizationId); var cell = Helpers.MakeFieldCell(field.Type, label, value, FieldsSection, this); if (cell != null) { FieldsSection.Add(cell); } if (!string.IsNullOrWhiteSpace(label) && !string.IsNullOrWhiteSpace(value) && field.Type == FieldType.Hidden) { _originalHiddenFields.Add(new Tuple <string, string>(label, value)); } } } AddFieldCell = new ExtendedTextCell { Text = $"+ {AppResources.NewCustomField}", TextColor = Colors.Primary }; FieldsSection.Add(AddFieldCell); // Make table TableRoot = new TableRoot { TopSection, MiddleSection, new TableSection(AppResources.Notes) { NotesCell }, FieldsSection, new TableSection(Helpers.GetEmptyTableSectionTitle()) { DeleteCell } }; if (UrisSection != null) { TableRoot.Insert(1, UrisSection); } Table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = TableRoot }; if (Device.RuntimePlatform == Device.iOS) { Table.RowHeight = -1; Table.EstimatedRowHeight = 70; } else if (Device.RuntimePlatform == Device.Android) { Table.BottomPadding = 50; } }
private void Init() { MessagingCenter.Send(Application.Current, "ShowStatusBar", true); IdentityUrlCell = new FormEntryCell(AppResources.IdentityUrl, entryKeyboard: Keyboard.Url); IdentityUrlCell.Entry.Text = _appSettings.IdentityUrl; ApiUrlCell = new FormEntryCell(AppResources.ApiUrl, nextElement: IdentityUrlCell.Entry, entryKeyboard: Keyboard.Url); ApiUrlCell.Entry.Text = _appSettings.ApiUrl; WebVaultUrlCell = new FormEntryCell(AppResources.WebVaultUrl, nextElement: ApiUrlCell.Entry, entryKeyboard: Keyboard.Url); WebVaultUrlCell.Entry.Text = _appSettings.WebVaultUrl; BaseUrlCell = new FormEntryCell(AppResources.ServerUrl, nextElement: WebVaultUrlCell.Entry, entryKeyboard: Keyboard.Url); BaseUrlCell.Entry.Text = _appSettings.BaseUrl; var table = new FormTableView { Root = new TableRoot { new TableSection(AppResources.SelfHostedEnvironment) { BaseUrlCell } } }; SelfHostLabel = new Label { Text = AppResources.SelfHostedEnvironmentFooter, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var table2 = new FormTableView { Root = new TableRoot { new TableSection(AppResources.CustomEnvironment) { WebVaultUrlCell, ApiUrlCell, IdentityUrlCell } } }; CustomLabel = new Label { Text = AppResources.CustomEnvironmentFooter, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; StackLayout = new StackLayout { Children = { table, SelfHostLabel, table2, CustomLabel }, Spacing = 0 }; var scrollView = new ScrollView { Content = StackLayout }; var toolbarItem = new ToolbarItem(AppResources.Save, null, async() => await SaveAsync(), ToolbarItemOrder.Default, 0); if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) { table.RowHeight = table2.RowHeight = -1; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close, () => { MessagingCenter.Send(Application.Current, "ShowStatusBar", false); })); } ToolbarItems.Add(toolbarItem); Title = AppResources.Settings; Content = scrollView; }
private void Init() { var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); EmailCell = new FormEntryCell(AppResources.EmailAddress, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope", containerPadding: padding); EmailCell.Entry.ReturnType = Enums.ReturnType.Go; EmailCell.Entry.Completed += Entry_Completed; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = true, NoFooter = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection() { EmailCell } } }; var hintLabel = new Label { Text = "Enter your account email address to receive your master password hint.", LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var layout = new StackLayout { Children = { table, hintLabel }, Spacing = 0 }; var scrollView = new ScrollView { Content = layout }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var submitToolbarItem = new ToolbarItem("Submit", null, async() => { await SubmitAsync(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(submitToolbarItem); Title = "Password Hint"; Content = scrollView; }
private void Init() { NotesCell = new FormEditorCell(height: 180); NotesCell.Editor.Keyboard = Keyboard.Text; TotpCell = new FormEntryCell(AppResources.AuthenticatorKey, nextElement: NotesCell.Editor, useButton: _deviceInfo.HasCamera); if (_deviceInfo.HasCamera) { TotpCell.Button.Image = "camera"; } TotpCell.Entry.DisableAutocapitalize = true; TotpCell.Entry.Autocorrect = false; TotpCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier"); PasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: TotpCell.Entry, useButton: true); PasswordCell.Button.Image = "eye"; PasswordCell.Entry.DisableAutocapitalize = true; PasswordCell.Entry.Autocorrect = false; PasswordCell.Entry.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier"); UsernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry); UsernameCell.Entry.DisableAutocapitalize = true; UsernameCell.Entry.Autocorrect = false; UriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: UsernameCell.Entry); if (!string.IsNullOrWhiteSpace(_defaultUri)) { UriCell.Entry.Text = _defaultUri; } NameCell = new FormEntryCell(AppResources.Name, nextElement: UriCell.Entry); if (!string.IsNullOrWhiteSpace(_defaultName)) { NameCell.Entry.Text = _defaultName; } var folderOptions = new List <string> { AppResources.FolderNone }; var folders = _folderService.GetAllAsync().GetAwaiter().GetResult() .OrderBy(f => f.Name?.Decrypt()).ToList(); foreach (var folder in folders) { folderOptions.Add(folder.Name.Decrypt()); } FolderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); GenerateCell = new ExtendedTextCell { Text = AppResources.GeneratePassword, ShowDisclousure = true }; var favoriteCell = new ExtendedSwitchCell { Text = AppResources.Favorite }; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = new TableRoot { new TableSection(AppResources.LoginInformation) { NameCell, UriCell, UsernameCell, PasswordCell, GenerateCell }, new TableSection(" ") { TotpCell, FolderCell, favoriteCell }, new TableSection(AppResources.Notes) { NotesCell } } }; if (Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } else if (Device.RuntimePlatform == Device.Android) { PasswordCell.Button.WidthRequest = 40; if (TotpCell.Button != null) { TotpCell.Button.WidthRequest = 40; } } var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async() => { if (_lastAction.LastActionWasRecent()) { return; } _lastAction = DateTime.UtcNow; if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (string.IsNullOrWhiteSpace(NameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } var login = new Login { Name = NameCell.Entry.Text.Encrypt(), Uri = string.IsNullOrWhiteSpace(UriCell.Entry.Text) ? null : UriCell.Entry.Text.Encrypt(), Username = string.IsNullOrWhiteSpace(UsernameCell.Entry.Text) ? null : UsernameCell.Entry.Text.Encrypt(), Password = string.IsNullOrWhiteSpace(PasswordCell.Entry.Text) ? null : PasswordCell.Entry.Text.Encrypt(), Notes = string.IsNullOrWhiteSpace(NotesCell.Editor.Text) ? null : NotesCell.Editor.Text.Encrypt(), Totp = string.IsNullOrWhiteSpace(TotpCell.Entry.Text) ? null : TotpCell.Entry.Text.Encrypt(), Favorite = favoriteCell.On }; if (FolderCell.Picker.SelectedIndex > 0) { login.FolderId = folders.ElementAt(FolderCell.Picker.SelectedIndex - 1).Id; } _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveTask = await _loginService.SaveAsync(login); _userDialogs.HideLoading(); if (saveTask.Succeeded) { _userDialogs.Toast(AppResources.NewLoginCreated); if (_fromAutofill) { _googleAnalyticsService.TrackExtensionEvent("CreatedLogin"); } else { _googleAnalyticsService.TrackAppEvent("CreatedLogin"); } await Navigation.PopForDeviceAsync(); } else if (saveTask.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }, ToolbarItemOrder.Default, 0); Title = AppResources.AddLogin; Content = table; ToolbarItems.Add(saveToolBarItem); if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
public static Cell MakeFieldCell(FieldType type, string label, string value, TableSection fieldsSection) { Cell cell; switch (type) { case FieldType.Text: case FieldType.Hidden: var hidden = type == FieldType.Hidden; var textFieldCell = new FormEntryCell(label, isPassword: hidden, button1: hidden ? "eye.png" : null); textFieldCell.Entry.Text = value; textFieldCell.Entry.DisableAutocapitalize = true; textFieldCell.Entry.Autocorrect = false; if (hidden) { textFieldCell.Entry.FontFamily = Helpers.OnPlatform( iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); textFieldCell.Button1.Command = new Command(() => { textFieldCell.Entry.InvokeToggleIsPassword(); textFieldCell.Button1.Image = "eye" + (!textFieldCell.Entry.IsPasswordFromToggled ? "_slash" : string.Empty) + ".png"; }); } cell = textFieldCell; break; case FieldType.Boolean: var switchFieldCell = new ExtendedSwitchCell { Text = label, On = value == "true" }; cell = switchFieldCell; break; default: cell = null; break; } if (cell != null) { var deleteAction = new MenuItem { Text = AppResources.Remove, IsDestructive = true }; deleteAction.Clicked += (sender, e) => { if (fieldsSection.Contains(cell)) { fieldsSection.Remove(cell); } if (cell is FormEntryCell feCell) { feCell.Dispose(); } cell = null; }; var editNameAction = new MenuItem { Text = AppResources.Edit }; editNameAction.Clicked += async(sender, e) => { string existingLabel = null; var feCell = cell as FormEntryCell; var esCell = cell as ExtendedSwitchCell; if (feCell != null) { existingLabel = feCell.Label.Text; } else if (esCell != null) { existingLabel = esCell.Text; } var daService = Resolver.Resolve <IDeviceActionService>(); var editLabel = await daService.DisplayPromptAync(AppResources.CustomFieldName, null, existingLabel); if (editLabel != null) { if (feCell != null) { feCell.Label.Text = editLabel; } else if (esCell != null) { esCell.Text = editLabel; } } }; cell.ContextActions.Add(editNameAction); cell.ContextActions.Add(deleteAction); } return(cell); }
private void Init() { var padding = Helpers.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), Windows: new Thickness(10, 8)); EmailCell = new FormEntryCell(AppResources.EmailAddress, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope.png", containerPadding: padding); EmailCell.Entry.ReturnType = Enums.ReturnType.Go; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, EnableSelection = true, NoFooter = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { EmailCell } } }; var hintLabel = new Label { Text = AppResources.EnterEmailForHint, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var layout = new RedrawableStackLayout { Children = { table, hintLabel }, Spacing = 0 }; table.WrappingStackLayout = () => layout; var scrollView = new ScrollView { Content = layout }; if (Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var submitToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() => { await SubmitAsync(); }, ToolbarItemOrder.Default, 0); ToolbarItems.Add(submitToolbarItem); Title = AppResources.PasswordHint; Content = scrollView; }
public static FormEntryCell MakeUriCell(string value, UriMatchType?match, TableSection urisSection, Page page) { var label = string.Format(AppResources.URIPosition, urisSection.Count); var cell = new FormEntryCell(label, entryKeyboard: Keyboard.Url); cell.Entry.Text = value; cell.Entry.DisableAutocapitalize = true; cell.Entry.Autocorrect = false; cell.MetaData = new Dictionary <string, object> { ["match"] = match }; var deleteAction = new MenuItem { Text = AppResources.Remove, IsDestructive = true }; deleteAction.Clicked += (sender, e) => { if (urisSection.Contains(cell)) { urisSection.Remove(cell); if (cell is FormEntryCell feCell) { feCell.Dispose(); } cell = null; for (int i = 0; i < urisSection.Count; i++) { if (urisSection[i] is FormEntryCell uriCell) { uriCell.Label.Text = string.Format(AppResources.URIPosition, i + 1); } } } }; var optionsAction = new MenuItem { Text = AppResources.Options }; optionsAction.Clicked += async(sender, e) => { var options = UriMatchOptionsMap.Select(v => v.Value).ToList(); options.Insert(0, AppResources.Default); var exactingMatchVal = cell.MetaData["match"] as UriMatchType?; var matchIndex = exactingMatchVal.HasValue ? Array.IndexOf(UriMatchOptionsMap.Keys.ToArray(), exactingMatchVal) + 1 : 0; options[matchIndex] = $"✓ {options[matchIndex]}"; var optionsArr = options.ToArray(); var val = await page.DisplayActionSheet(AppResources.URIMatchDetection, AppResources.Cancel, null, options.ToArray()); UriMatchType?selectedVal = null; if (val == AppResources.Cancel) { selectedVal = exactingMatchVal; } else if (val != AppResources.Default) { selectedVal = UriMatchOptionsMap.ElementAt(Array.IndexOf(optionsArr, val) - 1).Key; } cell.MetaData["match"] = selectedVal; }; cell.ContextActions.Add(optionsAction); cell.ContextActions.Add(deleteAction); return(cell); }
private void Init() { var notesCell = new FormEditorCell(height: 90); PasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: notesCell.Editor, useButton: true); PasswordCell.Button.Image = "eye"; PasswordCell.Button.Clicked += PasswordButton_Clicked; PasswordCell.Entry.DisableAutocapitalize = true; PasswordCell.Entry.Autocorrect = false; PasswordCell.Entry.FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); var usernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry); usernameCell.Entry.DisableAutocapitalize = true; usernameCell.Entry.Autocorrect = false; var uriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: usernameCell.Entry); var nameCell = new FormEntryCell(AppResources.Name, nextElement: uriCell.Entry); var folderOptions = new List <string> { AppResources.FolderNone }; var folders = _folderService.GetAllAsync().GetAwaiter().GetResult() .OrderBy(f => f.Name?.Decrypt()).ToList(); foreach (var folder in folders) { folderOptions.Add(folder.Name.Decrypt()); } var folderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); var generateCell = new ExtendedTextCell { Text = AppResources.GeneratePassword, ShowDisclousure = true }; generateCell.Tapped += GenerateCell_Tapped;; var favoriteCell = new ExtendedSwitchCell { Text = AppResources.Favorite }; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = new TableRoot { new TableSection(AppResources.SiteInformation) { nameCell, uriCell, usernameCell, PasswordCell, generateCell }, new TableSection { folderCell, favoriteCell }, new TableSection(AppResources.Notes) { notesCell } } }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } else if (Device.OS == TargetPlatform.Android) { PasswordCell.Button.WidthRequest = 40; } var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async() => { if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (string.IsNullOrWhiteSpace(nameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } var site = new Site { Uri = uriCell.Entry.Text?.Encrypt(), Name = nameCell.Entry.Text?.Encrypt(), Username = usernameCell.Entry.Text?.Encrypt(), Password = PasswordCell.Entry.Text?.Encrypt(), Notes = notesCell.Editor.Text?.Encrypt(), Favorite = favoriteCell.On }; if (folderCell.Picker.SelectedIndex > 0) { site.FolderId = folders.ElementAt(folderCell.Picker.SelectedIndex - 1).Id; } _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveTask = await _siteService.SaveAsync(site); _userDialogs.HideLoading(); if (saveTask.Succeeded) { await Navigation.PopForDeviceAsync(); _userDialogs.Toast(AppResources.NewSiteCreated); _googleAnalyticsService.TrackAppEvent("CreatedSite"); } else if (saveTask.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }, ToolbarItemOrder.Default, 0); Title = AppResources.AddSite; Content = table; ToolbarItems.Add(saveToolBarItem); if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
private void Init() { Cipher = _cipherService.GetByIdAsync(_cipherId).GetAwaiter().GetResult(); if (Cipher == null) { // TODO: handle error. navigate back? should never happen... return; } // Name NameCell = new FormEntryCell(AppResources.Name); NameCell.Entry.Text = Cipher.Name?.Decrypt(Cipher.OrganizationId); // Notes NotesCell = new FormEditorCell(Keyboard.Text, Cipher.Type == CipherType.SecureNote ? 500 : 180); NotesCell.Editor.Text = Cipher.Notes?.Decrypt(Cipher.OrganizationId); // Folders var folderOptions = new List <string> { AppResources.FolderNone }; Folders = _folderService.GetAllAsync().GetAwaiter().GetResult() .OrderBy(f => f.Name?.Decrypt()).ToList(); int selectedIndex = 0; int i = 0; foreach (var folder in Folders) { i++; if (folder.Id == Cipher.FolderId) { selectedIndex = i; } folderOptions.Add(folder.Name.Decrypt()); } FolderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); FolderCell.Picker.SelectedIndex = selectedIndex; // Favorite FavoriteCell = new ExtendedSwitchCell { Text = AppResources.Favorite, On = Cipher.Favorite }; // Delete DeleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red }; InitTable(); InitSave(); Title = AppResources.EditItem; Content = Table; if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
private void Init() { MessagingCenter.Send(Application.Current, "ShowStatusBar", true); var padding = Device.OnPlatform( iOS: new Thickness(15, 20), Android: new Thickness(15, 8), WinPhone: new Thickness(15, 20)); PasswordHintCell = new FormEntryCell(AppResources.MasterPasswordHint, useLabelAsPlaceholder: true, imageSource: "lightbulb", containerPadding: padding); ConfirmPasswordCell = new FormEntryCell(AppResources.RetypeMasterPassword, isPassword: true, nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true, nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock", containerPadding: padding); EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope", containerPadding: padding); PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done; PasswordHintCell.Entry.Completed += Entry_Completed; var table = new FormTableView { Root = new TableRoot { new TableSection { EmailCell, PasswordCell } } }; var passwordLabel = new Label { Text = AppResources.MasterPasswordDescription, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var table2 = new FormTableView { NoHeader = true, Root = new TableRoot { new TableSection { ConfirmPasswordCell, PasswordHintCell } } }; var hintLabel = new Label { Text = AppResources.MasterPasswordHintDescription, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"], Margin = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25) }; var layout = new StackLayout { Children = { table, passwordLabel, table2, hintLabel }, Spacing = 0 }; layout.LayoutChanged += (sender, args) => { passwordLabel.WidthRequest = layout.Bounds.Width - passwordLabel.Bounds.Left * 2; hintLabel.WidthRequest = layout.Bounds.Width - hintLabel.Bounds.Left * 2; }; var scrollView = new ScrollView { Content = layout }; var loginToolbarItem = new ToolbarItem(AppResources.Submit, null, async() => { await Register(); }, ToolbarItemOrder.Default, 0); if (Device.OS == TargetPlatform.iOS) { table.RowHeight = table2.RowHeight = table2.RowHeight = -1; table.EstimatedRowHeight = table2.EstimatedRowHeight = table2.EstimatedRowHeight = 70; ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () => { MessagingCenter.Send(Application.Current, "ShowStatusBar", false); })); } ToolbarItems.Add(loginToolbarItem); Title = AppResources.CreateAccount; Content = scrollView; }
private void Init() { var login = _loginService.GetByIdAsync(_loginId).GetAwaiter().GetResult(); if (login == null) { // TODO: handle error. navigate back? should never happen... return; } NotesCell = new FormEditorCell(height: 90); NotesCell.Editor.Text = login.Notes?.Decrypt(); PasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: NotesCell.Editor, useButton: true); PasswordCell.Entry.Text = login.Password?.Decrypt(); PasswordCell.Button.Image = "eye"; PasswordCell.Entry.DisableAutocapitalize = true; PasswordCell.Entry.Autocorrect = false; PasswordCell.Entry.FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); UsernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry); UsernameCell.Entry.Text = login.Username?.Decrypt(); UsernameCell.Entry.DisableAutocapitalize = true; UsernameCell.Entry.Autocorrect = false; UriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: UsernameCell.Entry); UriCell.Entry.Text = login.Uri?.Decrypt(); NameCell = new FormEntryCell(AppResources.Name, nextElement: UriCell.Entry); NameCell.Entry.Text = login.Name?.Decrypt(); GenerateCell = new ExtendedTextCell { Text = AppResources.GeneratePassword, ShowDisclousure = true }; var folderOptions = new List <string> { AppResources.FolderNone }; var folders = _folderService.GetAllAsync().GetAwaiter().GetResult() .OrderBy(f => f.Name?.Decrypt()).ToList(); int selectedIndex = 0; int i = 0; foreach (var folder in folders) { i++; if (folder.Id == login.FolderId) { selectedIndex = i; } folderOptions.Add(folder.Name.Decrypt()); } FolderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); FolderCell.Picker.SelectedIndex = selectedIndex; var favoriteCell = new ExtendedSwitchCell { Text = AppResources.Favorite, On = login.Favorite }; DeleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red }; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = new TableRoot { new TableSection(AppResources.LoginInformation) { NameCell, UriCell, UsernameCell, PasswordCell, GenerateCell }, new TableSection { FolderCell, favoriteCell }, new TableSection(AppResources.Notes) { NotesCell }, new TableSection { DeleteCell } } }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } else if (Device.OS == TargetPlatform.Android) { PasswordCell.Button.WidthRequest = 40; } var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async() => { if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (string.IsNullOrWhiteSpace(NameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } login.Uri = UriCell.Entry.Text?.Encrypt(); login.Name = NameCell.Entry.Text?.Encrypt(); login.Username = UsernameCell.Entry.Text?.Encrypt(); login.Password = PasswordCell.Entry.Text?.Encrypt(); login.Notes = NotesCell.Editor.Text?.Encrypt(); login.Favorite = favoriteCell.On; if (FolderCell.Picker.SelectedIndex > 0) { login.FolderId = folders.ElementAt(FolderCell.Picker.SelectedIndex - 1).Id; } else { login.FolderId = null; } _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveTask = await _loginService.SaveAsync(login); _userDialogs.HideLoading(); if (saveTask.Succeeded) { await Navigation.PopForDeviceAsync(); _userDialogs.Toast(AppResources.LoginUpdated); _googleAnalyticsService.TrackAppEvent("EditeLogin"); } else if (saveTask.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }, ToolbarItemOrder.Default, 0); Title = AppResources.EditLogin; Content = table; ToolbarItems.Add(saveToolBarItem); if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
public static Cell MakeFieldCell(FieldType type, string label, string value, TableSection fieldsSection, Page page) { Cell cell; FormEntryCell feCell = null; FormSwitchCell fsCell = null; switch (type) { case FieldType.Text: case FieldType.Hidden: var hidden = type == FieldType.Hidden; cell = feCell = new FormEntryCell(label, isPassword: hidden, button1: hidden ? "eye.png" : "cog_alt.png", button2: hidden ? "cog_alt.png" : null); feCell.Entry.Text = value; feCell.Entry.DisableAutocapitalize = true; feCell.Entry.Autocorrect = false; if (hidden) { feCell.Entry.FontFamily = OnPlatform(iOS: "Menlo-Regular", Android: "monospace", Windows: "Courier"); feCell.Button1.Command = new Command(() => { feCell.Entry.InvokeToggleIsPassword(); feCell.Button1.Image = "eye" + (!feCell.Entry.IsPasswordFromToggled ? "_slash" : string.Empty) + ".png"; }); } break; case FieldType.Boolean: cell = fsCell = new FormSwitchCell(label, "cog_alt.png"); fsCell.Switch.IsToggled = value == "true"; break; default: cell = null; break; } if (cell != null) { var optionsButton = feCell != null ? feCell.Button2 ?? feCell.Button1 : fsCell.Button1; optionsButton.Command = new Command(async() => { var optionsVal = await page.DisplayActionSheet(AppResources.Options, AppResources.Cancel, null, AppResources.Edit, AppResources.Remove); if (optionsVal == AppResources.Remove) { if (fieldsSection.Contains(cell)) { fieldsSection.Remove(cell); } if (feCell != null) { feCell.Dispose(); } cell = null; feCell = null; fsCell = null; } else if (optionsVal == AppResources.Edit) { var existingLabel = feCell?.Label.Text ?? fsCell?.Label.Text; var daService = Resolver.Resolve <IDeviceActionService>(); var editLabel = await daService.DisplayPromptAync(AppResources.CustomFieldName, null, existingLabel); if (editLabel != null) { if (feCell != null) { feCell.Label.Text = editLabel; } else if (fsCell != null) { fsCell.Label.Text = editLabel; } } } }); } return(cell); }
private void Init() { var folder = _folderService.GetByIdAsync(_folderId).GetAwaiter().GetResult(); if (folder == null) { // TODO: handle error. navigate back? should never happen... return; } NameCell = new FormEntryCell(AppResources.Name); NameCell.Entry.Text = folder.Name.Decrypt(); DeleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red }; var mainTable = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = false, HasUnevenRows = true, VerticalOptions = LayoutOptions.Start, Root = new TableRoot { new TableSection(" ") { NameCell }, new TableSection(" ") { DeleteCell } } }; if (Device.OS == TargetPlatform.iOS) { mainTable.RowHeight = -1; mainTable.EstimatedRowHeight = 70; } var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async() => { if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (string.IsNullOrWhiteSpace(NameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } folder.Name = NameCell.Entry.Text.Encrypt(); _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); var saveResult = await _folderService.SaveAsync(folder); _userDialogs.HideLoading(); if (saveResult.Succeeded) { await Navigation.PopForDeviceAsync(); _userDialogs.Toast(AppResources.FolderUpdated); _googleAnalyticsService.TrackAppEvent("EditedFolder"); } else if (saveResult.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveResult.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }, ToolbarItemOrder.Default, 0); Title = AppResources.EditFolder; Content = mainTable; ToolbarItems.Add(saveToolBarItem); if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
public static FormEntryCell MakeUriCell(string value, UriMatchType?match, TableSection urisSection, Page page) { var label = string.Format(AppResources.URIPosition, urisSection.Count); var cell = new FormEntryCell(label, entryKeyboard: Keyboard.Url, button1: "cog_alt.png"); cell.Entry.Text = value; cell.Entry.DisableAutocapitalize = true; cell.Entry.Autocorrect = false; cell.MetaData = new Dictionary <string, object> { ["match"] = match }; cell.Button1.Command = new Command(async() => { var optionsVal = await page.DisplayActionSheet(AppResources.Options, AppResources.Cancel, null, AppResources.MatchDetection, AppResources.Remove); if (optionsVal == AppResources.MatchDetection) { var options = UriMatchOptionsMap.Select(v => v.Value).ToList(); options.Insert(0, AppResources.Default); var exactingMatchVal = cell.MetaData["match"] as UriMatchType?; var matchIndex = exactingMatchVal.HasValue ? Array.IndexOf(UriMatchOptionsMap.Keys.ToArray(), exactingMatchVal) + 1 : 0; options[matchIndex] = $"✓ {options[matchIndex]}"; var optionsArr = options.ToArray(); var val = await page.DisplayActionSheet(AppResources.URIMatchDetection, AppResources.Cancel, null, options.ToArray()); UriMatchType?selectedVal = null; if (val == null || val == AppResources.Cancel) { selectedVal = exactingMatchVal; } else if (val.Replace("✓ ", string.Empty) != AppResources.Default) { selectedVal = UriMatchOptionsMap.ElementAt(Array.IndexOf(optionsArr, val) - 1).Key; } cell.MetaData["match"] = selectedVal; } else if (optionsVal == AppResources.Remove) { if (urisSection.Contains(cell)) { urisSection.Remove(cell); if (cell is FormEntryCell feCell) { feCell.Dispose(); } cell = null; for (int i = 0; i < urisSection.Count; i++) { if (urisSection[i] is FormEntryCell uriCell) { uriCell.Label.Text = string.Format(AppResources.URIPosition, i + 1); } } } } }); return(cell); }
private void Init() { var folder = _folderService.GetByIdAsync(_folderId).GetAwaiter().GetResult(); if (folder == null) { // TODO: handle error. navigate back? should never happen... return; } NameCell = new FormEntryCell(AppResources.Name); NameCell.Entry.Text = folder.Name.Decrypt(); DeleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red }; var mainTable = new ExtendedTableView { Intent = TableIntent.Settings, HasUnevenRows = true, Root = new TableRoot { new TableSection(Helpers.GetEmptyTableSectionTitle()) { NameCell }, new TableSection(Helpers.GetEmptyTableSectionTitle()) { DeleteCell } } }; if (Device.RuntimePlatform == Device.iOS) { mainTable.RowHeight = -1; mainTable.EstimatedRowHeight = 70; } else if (Device.RuntimePlatform == Device.Android) { mainTable.BottomPadding = 50; } var saveToolBarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async() => { if (_lastAction.LastActionWasRecent()) { return; } _lastAction = DateTime.UtcNow; if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (string.IsNullOrWhiteSpace(NameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } folder.Name = NameCell.Entry.Text.Encrypt(); _deviceActionService.ShowLoading(AppResources.Saving); var saveResult = await _folderService.SaveAsync(folder); _deviceActionService.HideLoading(); if (saveResult.Succeeded) { _deviceActionService.Toast(AppResources.FolderUpdated); _googleAnalyticsService.TrackAppEvent("EditedFolder"); await Navigation.PopForDeviceAsync(); } else if (saveResult.Errors.Count() > 0) { await DisplayAlert(AppResources.AnErrorHasOccurred, saveResult.Errors.First().Message, AppResources.Ok); } else { await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok); } }, ToolbarItemOrder.Default, 0); Title = AppResources.EditFolder; Content = mainTable; ToolbarItems.Add(saveToolBarItem); if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } }
private void Init() { var site = _siteService.GetByIdAsync(_siteId).GetAwaiter().GetResult(); if (site == null) { // TODO: handle error. navigate back? should never happen... return; } var notesCell = new FormEditorCell(height: 90); notesCell.Editor.Text = site.Notes?.Decrypt(); PasswordCell = new FormEntryCell(AppResources.Password, IsPassword: true, nextElement: notesCell.Editor); PasswordCell.Entry.Text = site.Password?.Decrypt(); var usernameCell = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry); usernameCell.Entry.Text = site.Username?.Decrypt(); usernameCell.Entry.DisableAutocapitalize = true; usernameCell.Entry.Autocorrect = false; usernameCell.Entry.FontFamily = PasswordCell.Entry.FontFamily = Device.OnPlatform( iOS: "Courier", Android: "monospace", WinPhone: "Courier"); var uriCell = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: usernameCell.Entry); uriCell.Entry.Text = site.Uri?.Decrypt(); var nameCell = new FormEntryCell(AppResources.Name, nextElement: uriCell.Entry); nameCell.Entry.Text = site.Name?.Decrypt(); var generateCell = new ExtendedTextCell { Text = "Generate Password", ShowDisclousure = true }; generateCell.Tapped += GenerateCell_Tapped;; var folderOptions = new List <string> { AppResources.FolderNone }; var folders = _folderService.GetAllAsync().GetAwaiter().GetResult() .OrderBy(f => f.Name?.Decrypt()).ToList(); int selectedIndex = 0; int i = 0; foreach (var folder in folders) { i++; if (folder.Id == site.FolderId) { selectedIndex = i; } folderOptions.Add(folder.Name.Decrypt()); } var folderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); folderCell.Picker.SelectedIndex = selectedIndex; var favoriteCell = new ExtendedSwitchCell { Text = "Favorite", On = site.Favorite }; var deleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red }; deleteCell.Tapped += DeleteCell_Tapped; var table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, Root = new TableRoot { new TableSection("Site Information") { nameCell, uriCell, usernameCell, PasswordCell, generateCell }, new TableSection { folderCell, favoriteCell }, new TableSection(AppResources.Notes) { notesCell }, new TableSection { deleteCell } } }; if (Device.OS == TargetPlatform.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; } var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async() => { if (!_connectivity.IsConnected) { AlertNoConnection(); return; } if (string.IsNullOrWhiteSpace(PasswordCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Password), AppResources.Ok); return; } if (string.IsNullOrWhiteSpace(nameCell.Entry.Text)) { await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired, AppResources.Name), AppResources.Ok); return; } site.Uri = uriCell.Entry.Text?.Encrypt(); site.Name = nameCell.Entry.Text?.Encrypt(); site.Username = usernameCell.Entry.Text?.Encrypt(); site.Password = PasswordCell.Entry.Text?.Encrypt(); site.Notes = notesCell.Editor.Text?.Encrypt(); site.Favorite = favoriteCell.On; if (folderCell.Picker.SelectedIndex > 0) { site.FolderId = folders.ElementAt(folderCell.Picker.SelectedIndex - 1).Id; } else { site.FolderId = null; } _userDialogs.ShowLoading("Saving...", MaskType.Black); var saveTask = await _siteService.SaveAsync(site); _userDialogs.HideLoading(); if (saveTask.Succeeded) { await Navigation.PopForDeviceAsync(); _userDialogs.Toast("Site updated."); _googleAnalyticsService.TrackAppEvent("EditedSite"); } else if (saveTask.Errors.Count() > 0) { await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred); } else { await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred); } }, ToolbarItemOrder.Default, 0); Title = "Edit Site"; Content = table; ToolbarItems.Add(saveToolBarItem); if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, "Cancel")); } }