From d146870a74d98dc9cb0789f5da74834ed11ef40a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 19 Oct 2017 14:30:12 -0400 Subject: [PATCH] rename pages and props for login => cipher --- src/App/App.csproj | 4 +-- src/App/Pages/Vault/VaultAttachmentsPage.cs | 21 ++++++----- .../Vault/VaultAutofillListCiphersPage.cs | 8 ++--- src/App/Pages/Vault/VaultCustomFieldsPage.cs | 36 +++++++++---------- ...ditLoginPage.cs => VaultEditCipherPage.cs} | 16 ++++----- src/App/Pages/Vault/VaultListCiphersPage.cs | 10 +++--- ...iewLoginPage.cs => VaultViewCipherPage.cs} | 18 +++++----- 7 files changed, 56 insertions(+), 57 deletions(-) rename src/App/Pages/Vault/{VaultEditLoginPage.cs => VaultEditCipherPage.cs} (97%) rename src/App/Pages/Vault/{VaultViewLoginPage.cs => VaultViewCipherPage.cs} (95%) diff --git a/src/App/App.csproj b/src/App/App.csproj index 5c3351b5e..88ad4c42f 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -355,8 +355,8 @@ - - + + diff --git a/src/App/Pages/Vault/VaultAttachmentsPage.cs b/src/App/Pages/Vault/VaultAttachmentsPage.cs index 30ab36adc..9063bf51a 100644 --- a/src/App/Pages/Vault/VaultAttachmentsPage.cs +++ b/src/App/Pages/Vault/VaultAttachmentsPage.cs @@ -9,7 +9,6 @@ using Xamarin.Forms; using XLabs.Ioc; using Bit.App.Utilities; using Plugin.Connectivity.Abstractions; -using System.Collections.Generic; using Bit.App.Models; using System.Threading.Tasks; @@ -24,16 +23,16 @@ namespace Bit.App.Pages private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly ITokenService _tokenService; private readonly ICryptoService _cryptoService; - private readonly string _loginId; - private Cipher _login; + private readonly string _cipherId; + private Cipher _cipher; private byte[] _fileBytes; private DateTime? _lastAction; private bool _canUseAttachments = true; - public VaultAttachmentsPage(string loginId) + public VaultAttachmentsPage(string cipherId) : base(true) { - _loginId = loginId; + _cipherId = cipherId; _cipherService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); @@ -135,7 +134,7 @@ namespace Bit.App.Pages var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () => { - if(_lastAction.LastActionWasRecent() || _login == null) + if(_lastAction.LastActionWasRecent() || _cipher == null) { return; } @@ -162,7 +161,7 @@ namespace Bit.App.Pages } _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); - var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_login, _fileBytes, FileLabel.Text); + var saveTask = await _cipherService.EncryptAndSaveAttachmentAsync(_cipher, _fileBytes, FileLabel.Text); _userDialogs.HideLoading(); @@ -223,14 +222,14 @@ namespace Bit.App.Pages private async Task LoadAttachmentsAsync() { - _login = await _cipherService.GetByIdAsync(_loginId); - if(_login == null) + _cipher = await _cipherService.GetByIdAsync(_cipherId); + if(_cipher == null) { await Navigation.PopForDeviceAsync(); return; } - var attachmentsToAdd = _login.Attachments + var attachmentsToAdd = _cipher.Attachments .Select(a => new VaultAttachmentsPageModel.Attachment(a)) .OrderBy(s => s.Name); PresentationAttchments.ResetWithRange(attachmentsToAdd); @@ -268,7 +267,7 @@ namespace Bit.App.Pages } _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); - var saveTask = await _cipherService.DeleteAttachmentAsync(_login, attachment.Id); + var saveTask = await _cipherService.DeleteAttachmentAsync(_cipher, attachment.Id); _userDialogs.HideLoading(); if(saveTask.Succeeded) diff --git a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs index b30bdc8fe..18e67670a 100644 --- a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs +++ b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs @@ -240,7 +240,7 @@ namespace Bit.App.Pages { var buttons = new List { AppResources.View, AppResources.Edit }; - if(cipher.Type == Enums.CipherType.Login) + if(cipher.Type == CipherType.Login) { if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) { @@ -251,7 +251,7 @@ namespace Bit.App.Pages buttons.Add(AppResources.CopyUsername); } } - else if(cipher.Type == Enums.CipherType.Card) + else if(cipher.Type == CipherType.Card) { if(!string.IsNullOrWhiteSpace(cipher.CardNumber)) { @@ -267,12 +267,12 @@ namespace Bit.App.Pages if(selection == AppResources.View) { - var page = new VaultViewLoginPage(cipher.Id); + var page = new VaultViewCipherPage(cipher.Id); await Navigation.PushForDeviceAsync(page); } else if(selection == AppResources.Edit) { - var page = new VaultEditLoginPage(cipher.Id); + var page = new VaultEditCipherPage(cipher.Id); await Navigation.PushForDeviceAsync(page); } else if(selection == AppResources.CopyPassword) diff --git a/src/App/Pages/Vault/VaultCustomFieldsPage.cs b/src/App/Pages/Vault/VaultCustomFieldsPage.cs index ce9ec7073..b76cc27bd 100644 --- a/src/App/Pages/Vault/VaultCustomFieldsPage.cs +++ b/src/App/Pages/Vault/VaultCustomFieldsPage.cs @@ -20,14 +20,14 @@ namespace Bit.App.Pages private readonly IUserDialogs _userDialogs; private readonly IConnectivity _connectivity; private readonly IGoogleAnalyticsService _googleAnalyticsService; - private readonly string _loginId; - private Cipher _login; + private readonly string _cipherId; + private Cipher _cipher; private DateTime? _lastAction; - public VaultCustomFieldsPage(string loginId) + public VaultCustomFieldsPage(string cipherId) : base(true) { - _loginId = loginId; + _cipherId = cipherId; _cipherService = Resolver.Resolve(); _connectivity = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); @@ -66,7 +66,7 @@ namespace Bit.App.Pages SaveToolbarItem = new ToolbarItem(AppResources.Save, null, async () => { - if(_lastAction.LastActionWasRecent() || _login == null) + if(_lastAction.LastActionWasRecent() || _cipher == null) { return; } @@ -88,9 +88,9 @@ namespace Bit.App.Pages fields.Add(new Field { Name = string.IsNullOrWhiteSpace(entryCell.Label.Text) ? null : - entryCell.Label.Text.Encrypt(_login.OrganizationId), + entryCell.Label.Text.Encrypt(_cipher.OrganizationId), Value = string.IsNullOrWhiteSpace(entryCell.Entry.Text) ? null : - entryCell.Entry.Text.Encrypt(_login.OrganizationId), + entryCell.Entry.Text.Encrypt(_cipher.OrganizationId), Type = entryCell.Entry.IsPassword ? FieldType.Hidden : FieldType.Text }); } @@ -100,21 +100,21 @@ namespace Bit.App.Pages fields.Add(new Field { Name = string.IsNullOrWhiteSpace(switchCell.Text) ? null : - switchCell.Text.Encrypt(_login.OrganizationId), - Value = value.Encrypt(_login.OrganizationId), + switchCell.Text.Encrypt(_cipher.OrganizationId), + Value = value.Encrypt(_cipher.OrganizationId), Type = FieldType.Boolean }); } } - _login.Fields = fields; + _cipher.Fields = fields; } else { - _login.Fields = null; + _cipher.Fields = null; } _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black); - var saveTask = await _cipherService.SaveAsync(_login); + var saveTask = await _cipherService.SaveAsync(_cipher); _userDialogs.HideLoading(); @@ -148,14 +148,14 @@ namespace Bit.App.Pages { base.OnAppearing(); - _login = await _cipherService.GetByIdAsync(_loginId); - if(_login == null) + _cipher = await _cipherService.GetByIdAsync(_cipherId); + if(_cipher == null) { await Navigation.PopForDeviceAsync(); return; } - if(_login.Fields != null && _login.Fields.Any()) + if(_cipher.Fields != null && _cipher.Fields.Any()) { Content = Table; ToolbarItems.Add(SaveToolbarItem); @@ -164,10 +164,10 @@ namespace Bit.App.Pages ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } - foreach(var field in _login.Fields) + foreach(var field in _cipher.Fields) { - var label = field.Name?.Decrypt(_login.OrganizationId) ?? string.Empty; - var value = field.Value?.Decrypt(_login.OrganizationId); + var label = field.Name?.Decrypt(_cipher.OrganizationId) ?? string.Empty; + var value = field.Value?.Decrypt(_cipher.OrganizationId); switch(field.Type) { case FieldType.Text: diff --git a/src/App/Pages/Vault/VaultEditLoginPage.cs b/src/App/Pages/Vault/VaultEditCipherPage.cs similarity index 97% rename from src/App/Pages/Vault/VaultEditLoginPage.cs rename to src/App/Pages/Vault/VaultEditCipherPage.cs index 32bcec174..110f6001b 100644 --- a/src/App/Pages/Vault/VaultEditLoginPage.cs +++ b/src/App/Pages/Vault/VaultEditCipherPage.cs @@ -12,9 +12,9 @@ using Bit.App.Utilities; namespace Bit.App.Pages { - public class VaultEditLoginPage : ExtendedContentPage + public class VaultEditCipherPage : ExtendedContentPage { - private readonly string _loginId; + private readonly string _cipherId; private readonly ICipherService _cipherService; private readonly IFolderService _folderService; private readonly IUserDialogs _userDialogs; @@ -23,9 +23,9 @@ namespace Bit.App.Pages private readonly IGoogleAnalyticsService _googleAnalyticsService; private DateTime? _lastAction; - public VaultEditLoginPage(string loginId) + public VaultEditCipherPage(string cipherId) { - _loginId = loginId; + _cipherId = cipherId; _cipherService = Resolver.Resolve(); _folderService = Resolver.Resolve(); _userDialogs = Resolver.Resolve(); @@ -50,7 +50,7 @@ namespace Bit.App.Pages private void Init() { - var cipher = _cipherService.GetByIdAsync(_loginId).GetAwaiter().GetResult(); + var cipher = _cipherService.GetByIdAsync(_cipherId).GetAwaiter().GetResult(); if(cipher == null) { // TODO: handle error. navigate back? should never happen... @@ -385,13 +385,13 @@ namespace Bit.App.Pages private async void AttachmentsCell_Tapped(object sender, EventArgs e) { - var page = new ExtendedNavigationPage(new VaultAttachmentsPage(_loginId)); + var page = new ExtendedNavigationPage(new VaultAttachmentsPage(_cipherId)); await Navigation.PushModalAsync(page); } private async void CustomFieldsCell_Tapped(object sender, EventArgs e) { - var page = new ExtendedNavigationPage(new VaultCustomFieldsPage(_loginId)); + var page = new ExtendedNavigationPage(new VaultCustomFieldsPage(_cipherId)); await Navigation.PushModalAsync(page); } @@ -409,7 +409,7 @@ namespace Bit.App.Pages } _userDialogs.ShowLoading(AppResources.Deleting, MaskType.Black); - var deleteTask = await _cipherService.DeleteAsync(_loginId); + var deleteTask = await _cipherService.DeleteAsync(_cipherId); _userDialogs.HideLoading(); if(deleteTask.Succeeded) diff --git a/src/App/Pages/Vault/VaultListCiphersPage.cs b/src/App/Pages/Vault/VaultListCiphersPage.cs index 83efee095..ec4850115 100644 --- a/src/App/Pages/Vault/VaultListCiphersPage.cs +++ b/src/App/Pages/Vault/VaultListCiphersPage.cs @@ -398,7 +398,7 @@ namespace Bit.App.Pages if(selection == AppResources.View || string.IsNullOrWhiteSpace(Uri)) { - var page = new VaultViewLoginPage(cipher.Id); + var page = new VaultViewCipherPage(cipher.Id); await Navigation.PushForDeviceAsync(page); } else if(selection == AppResources.Autofill) @@ -421,7 +421,7 @@ namespace Bit.App.Pages { var buttons = new List { AppResources.View, AppResources.Edit }; - if(cipher.Type == Enums.CipherType.Login) + if(cipher.Type == CipherType.Login) { if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) { @@ -437,7 +437,7 @@ namespace Bit.App.Pages buttons.Add(AppResources.GoToWebsite); } } - else if(cipher.Type == Enums.CipherType.Card) + else if(cipher.Type == CipherType.Card) { if(!string.IsNullOrWhiteSpace(cipher.CardNumber)) { @@ -453,12 +453,12 @@ namespace Bit.App.Pages if(selection == AppResources.View) { - var page = new VaultViewLoginPage(cipher.Id); + var page = new VaultViewCipherPage(cipher.Id); await Navigation.PushForDeviceAsync(page); } else if(selection == AppResources.Edit) { - var page = new VaultEditLoginPage(cipher.Id); + var page = new VaultEditCipherPage(cipher.Id); await Navigation.PushForDeviceAsync(page); } else if(selection == AppResources.CopyPassword) diff --git a/src/App/Pages/Vault/VaultViewLoginPage.cs b/src/App/Pages/Vault/VaultViewCipherPage.cs similarity index 95% rename from src/App/Pages/Vault/VaultViewLoginPage.cs rename to src/App/Pages/Vault/VaultViewCipherPage.cs index aea5f9e60..6c825e2b6 100644 --- a/src/App/Pages/Vault/VaultViewLoginPage.cs +++ b/src/App/Pages/Vault/VaultViewCipherPage.cs @@ -15,7 +15,7 @@ using Bit.App.Enums; namespace Bit.App.Pages { - public class VaultViewLoginPage : ExtendedContentPage + public class VaultViewCipherPage : ExtendedContentPage { private readonly string _loginId; private readonly ICipherService _cipherService; @@ -24,7 +24,7 @@ namespace Bit.App.Pages private readonly ITokenService _tokenService; private bool _pageDisappeared = true; - public VaultViewLoginPage(string loginId) + public VaultViewCipherPage(string loginId) { _loginId = loginId; _cipherService = Resolver.Resolve(); @@ -372,10 +372,10 @@ namespace Bit.App.Pages private class EditLoginToolBarItem : ExtendedToolbarItem { - private readonly VaultViewLoginPage _page; + private readonly VaultViewCipherPage _page; private readonly string _loginId; - public EditLoginToolBarItem(VaultViewLoginPage page, string loginId) + public EditLoginToolBarItem(VaultViewCipherPage page, string loginId) { _page = page; _loginId = loginId; @@ -385,7 +385,7 @@ namespace Bit.App.Pages private async Task ClickedItem() { - var page = new VaultEditLoginPage(_loginId); + var page = new VaultEditCipherPage(_loginId); await _page.Navigation.PushForDeviceAsync(page); } } @@ -422,19 +422,19 @@ namespace Bit.App.Pages public class FieldViewCell : LabeledValueCell { - public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field) + public FieldViewCell(VaultViewCipherPage page, VaultViewLoginPageModel.Field field) : base(field.Name, field.Value == "true" ? "✓" : "-") { Init(page, field, null); } - public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, bool? a) + public FieldViewCell(VaultViewCipherPage page, VaultViewLoginPageModel.Field field, bool? a) : base(field.Name, field.Value, AppResources.Copy) { Init(page, field, Button1); } - public FieldViewCell(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, bool? a, bool? b) + public FieldViewCell(VaultViewCipherPage page, VaultViewLoginPageModel.Field field, bool? a, bool? b) : base(field.Name, field.MaskedValue, string.Empty, AppResources.Copy) { Value.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", @@ -464,7 +464,7 @@ namespace Bit.App.Pages Init(page, field, Button2); } - private void Init(VaultViewLoginPage page, VaultViewLoginPageModel.Field field, ExtendedButton copyButton) + private void Init(VaultViewCipherPage page, VaultViewLoginPageModel.Field field, ExtendedButton copyButton) { Value.LineBreakMode = LineBreakMode.WordWrap; if(copyButton != null)