From 3c14eaf3f8890bd8197364f48708d955323a29cb Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 14 Jun 2016 22:36:37 -0400 Subject: [PATCH] Added site favorite option --- src/App/Models/Api/Request/SiteRequest.cs | 2 ++ src/App/Models/Api/Response/SiteResponse.cs | 1 + src/App/Models/Data/SiteData.cs | 3 +++ src/App/Models/Site.cs | 3 +++ src/App/Pages/VaultAddSitePage.cs | 7 +++++++ src/App/Pages/VaultEditSitePage.cs | 11 +++++++++++ 6 files changed, 27 insertions(+) diff --git a/src/App/Models/Api/Request/SiteRequest.cs b/src/App/Models/Api/Request/SiteRequest.cs index 7db37575d..2bca5e7d1 100644 --- a/src/App/Models/Api/Request/SiteRequest.cs +++ b/src/App/Models/Api/Request/SiteRequest.cs @@ -10,6 +10,7 @@ Username = site.Username?.EncryptedString; Password = site.Password?.EncryptedString; Notes = site.Notes?.EncryptedString; + Favorite = site.Favorite; } public string FolderId { get; set; } @@ -18,5 +19,6 @@ public string Username { get; set; } public string Password { get; set; } public string Notes { get; set; } + public bool Favorite { get; set; } } } diff --git a/src/App/Models/Api/Response/SiteResponse.cs b/src/App/Models/Api/Response/SiteResponse.cs index 1db44bda5..a748d77fb 100644 --- a/src/App/Models/Api/Response/SiteResponse.cs +++ b/src/App/Models/Api/Response/SiteResponse.cs @@ -11,6 +11,7 @@ namespace Bit.App.Models.Api public string Username { get; set; } public string Password { get; set; } public string Notes { get; set; } + public bool Favorite { get; set; } public DateTime RevisionDate { get; set; } // Expandables diff --git a/src/App/Models/Data/SiteData.cs b/src/App/Models/Data/SiteData.cs index c4f7ad4f1..9a1921056 100644 --- a/src/App/Models/Data/SiteData.cs +++ b/src/App/Models/Data/SiteData.cs @@ -21,6 +21,7 @@ namespace Bit.App.Models.Data Username = site.Username?.EncryptedString; Password = site.Password?.EncryptedString; Notes = site.Notes?.EncryptedString; + Favorite = site.Favorite; } public SiteData(SiteResponse site, string userId) @@ -33,6 +34,7 @@ namespace Bit.App.Models.Data Username = site.Username; Password = site.Password; Notes = site.Notes; + Favorite = site.Favorite; } [PrimaryKey] @@ -45,6 +47,7 @@ namespace Bit.App.Models.Data public string Username { get; set; } public string Password { get; set; } public string Notes { get; set; } + public bool Favorite { get; set; } public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow; public Site ToSite() diff --git a/src/App/Models/Site.cs b/src/App/Models/Site.cs index 3b5b77904..ca34e4b29 100644 --- a/src/App/Models/Site.cs +++ b/src/App/Models/Site.cs @@ -17,6 +17,7 @@ namespace Bit.App.Models Username = data.Username != null ? new CipherString(data.Username) : null; Password = data.Password != null ? new CipherString(data.Password) : null; Notes = data.Notes != null ? new CipherString(data.Notes) : null; + Favorite = data.Favorite; } public Site(SiteResponse response) @@ -28,6 +29,7 @@ namespace Bit.App.Models Username = response.Username != null ? new CipherString(response.Username) : null; Password = response.Password != null ? new CipherString(response.Password) : null; Notes = response.Notes != null ? new CipherString(response.Notes) : null; + Favorite = response.Favorite; } public string FolderId { get; set; } @@ -35,6 +37,7 @@ namespace Bit.App.Models public CipherString Username { get; set; } public CipherString Password { get; set; } public CipherString Notes { get; set; } + public bool Favorite { get; set; } public SiteRequest ToSiteRequest() { diff --git a/src/App/Pages/VaultAddSitePage.cs b/src/App/Pages/VaultAddSitePage.cs index 131880cd5..396f33b5b 100644 --- a/src/App/Pages/VaultAddSitePage.cs +++ b/src/App/Pages/VaultAddSitePage.cs @@ -50,6 +50,8 @@ namespace Bit.App.Pages } var folderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); + var favoriteCell = new ExtendedSwitchCell { Text = "Favorite" }; + var table = new ExtendedTableView { Intent = TableIntent.Settings, @@ -66,6 +68,10 @@ namespace Bit.App.Pages passwordCell, folderCell }, + new TableSection + { + favoriteCell + }, new TableSection(AppResources.Notes) { notesCell @@ -106,6 +112,7 @@ namespace Bit.App.Pages Username = usernameCell.Entry.Text?.Encrypt(), Password = passwordCell.Entry.Text?.Encrypt(), Notes = notesCell.Editor.Text?.Encrypt(), + Favorite = favoriteCell.On }; if(folderCell.Picker.SelectedIndex > 0) diff --git a/src/App/Pages/VaultEditSitePage.cs b/src/App/Pages/VaultEditSitePage.cs index e3844be2b..189a93da8 100644 --- a/src/App/Pages/VaultEditSitePage.cs +++ b/src/App/Pages/VaultEditSitePage.cs @@ -72,6 +72,12 @@ namespace Bit.App.Pages var folderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray()); folderCell.Picker.SelectedIndex = selectedIndex; + var favoriteCell = new ExtendedSwitchCell + { + Text = "Favorite", + On = site.Favorite + }; + var table = new ExtendedTableView { Intent = TableIntent.Settings, @@ -88,6 +94,10 @@ namespace Bit.App.Pages passwordCell, folderCell }, + new TableSection + { + favoriteCell + }, new TableSection(AppResources.Notes) { notesCell @@ -126,6 +136,7 @@ namespace Bit.App.Pages 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) {