From cc0bb650961406944031384132b6327c8802be6c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 20 Oct 2017 12:47:05 -0400 Subject: [PATCH] subtitles for each type --- src/Android/MainActivity.cs | 10 ++--- src/App/Models/Page/VaultListPageModel.cs | 45 ++++++++++++++----- .../Vault/VaultAutofillListCiphersPage.cs | 10 ++--- src/App/Pages/Vault/VaultListCiphersPage.cs | 23 +++++----- 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 43af41cd6..8852e9f31 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -140,14 +140,14 @@ namespace Bit.Android { var isPremium = Resolver.Resolve()?.TokenPremium ?? false; var autoCopyEnabled = !_settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false); - if(isPremium && autoCopyEnabled && _deviceActionService != null && cipher.Totp.Value != null) + if(isPremium && autoCopyEnabled && _deviceActionService != null && cipher.LoginTotp.Value != null) { - _deviceActionService.CopyToClipboard(App.Utilities.Crypto.Totp(cipher.Totp.Value)); + _deviceActionService.CopyToClipboard(App.Utilities.Crypto.Totp(cipher.LoginTotp.Value)); } - data.PutExtra("uri", cipher.Uri.Value); - data.PutExtra("username", cipher.Username); - data.PutExtra("password", cipher.Password.Value); + data.PutExtra("uri", cipher.LoginUri.Value); + data.PutExtra("username", cipher.LoginUsername); + data.PutExtra("password", cipher.LoginPassword.Value); } if(Parent == null) diff --git a/src/App/Models/Page/VaultListPageModel.cs b/src/App/Models/Page/VaultListPageModel.cs index 4e69166ef..521e97789 100644 --- a/src/App/Models/Page/VaultListPageModel.cs +++ b/src/App/Models/Page/VaultListPageModel.cs @@ -22,27 +22,48 @@ namespace Bit.App.Models.Page switch(cipher.Type) { case CipherType.Login: - Username = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " "; - Password = new Lazy(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId)); - Uri = new Lazy(() => cipher.Login?.Uri?.Decrypt(cipher.OrganizationId)); - Totp = new Lazy(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId)); + LoginUsername = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " "; + LoginPassword = new Lazy(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId)); + LoginUri = new Lazy(() => cipher.Login?.Uri?.Decrypt(cipher.OrganizationId)); + LoginTotp = new Lazy(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId)); - Subtitle = Username; + Subtitle = LoginUsername; break; case CipherType.SecureNote: Subtitle = " "; break; case CipherType.Card: - var cardNumber = cipher.Card?.Number?.Decrypt(cipher.OrganizationId) ?? " "; + CardNumber = cipher.Card?.Number?.Decrypt(cipher.OrganizationId) ?? " "; var cardBrand = cipher.Card?.Brand?.Decrypt(cipher.OrganizationId) ?? " "; CardCode = new Lazy(() => cipher.Card?.Code?.Decrypt(cipher.OrganizationId)); - Subtitle = $"{cardBrand}, *{cardNumber}"; + Subtitle = cardBrand; + if(!string.IsNullOrWhiteSpace(CardNumber) && CardNumber.Length >= 4) + { + if(!string.IsNullOrWhiteSpace(CardNumber)) + { + Subtitle += ", "; + } + Subtitle += ("*" + CardNumber.Substring(CardNumber.Length - 4)); + } break; case CipherType.Identity: var firstName = cipher.Identity?.FirstName?.Decrypt(cipher.OrganizationId) ?? " "; var lastName = cipher.Identity?.LastName?.Decrypt(cipher.OrganizationId) ?? " "; - Subtitle = $"{firstName} {lastName}"; + + Subtitle = " "; + if(!string.IsNullOrWhiteSpace(firstName)) + { + Subtitle = firstName; + } + if(!string.IsNullOrWhiteSpace(lastName)) + { + if(!string.IsNullOrWhiteSpace(Subtitle)) + { + Subtitle += " "; + } + Subtitle += lastName; + } break; default: break; @@ -58,10 +79,10 @@ namespace Bit.App.Models.Page public CipherType Type { get; set; } // Login metadata - public string Username { get; set; } - public Lazy Password { get; set; } - public Lazy Uri { get; set; } - public Lazy Totp { get; set; } + public string LoginUsername { get; set; } + public Lazy LoginPassword { get; set; } + public Lazy LoginUri { get; set; } + public Lazy LoginTotp { get; set; } // Login metadata public string CardNumber { get; set; } diff --git a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs index c8dd38af6..cfbc54ecb 100644 --- a/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs +++ b/src/App/Pages/Vault/VaultAutofillListCiphersPage.cs @@ -176,7 +176,7 @@ namespace Bit.App.Pages var fuzzyLogins = ciphers?.Item2.Select(l => new VaultListPageModel.AutofillCipher(l, true)) .OrderBy(s => s.Name) - .ThenBy(s => s.Username) + .ThenBy(s => s.LoginUsername) .ToList(); if(fuzzyLogins?.Any() ?? false) { @@ -242,11 +242,11 @@ namespace Bit.App.Pages if(cipher.Type == CipherType.Login) { - if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) + if(!string.IsNullOrWhiteSpace(cipher.LoginPassword.Value)) { buttons.Add(AppResources.CopyPassword); } - if(!string.IsNullOrWhiteSpace(cipher.Username)) + if(!string.IsNullOrWhiteSpace(cipher.LoginUsername)) { buttons.Add(AppResources.CopyUsername); } @@ -277,11 +277,11 @@ namespace Bit.App.Pages } else if(selection == AppResources.CopyPassword) { - Copy(cipher.Password.Value, AppResources.Password); + Copy(cipher.LoginPassword.Value, AppResources.Password); } else if(selection == AppResources.CopyUsername) { - Copy(cipher.Username, AppResources.Username); + Copy(cipher.LoginUsername, AppResources.Username); } else if(selection == AppResources.CopyNumber) { diff --git a/src/App/Pages/Vault/VaultListCiphersPage.cs b/src/App/Pages/Vault/VaultListCiphersPage.cs index 687bd7e90..ca581f250 100644 --- a/src/App/Pages/Vault/VaultListCiphersPage.cs +++ b/src/App/Pages/Vault/VaultListCiphersPage.cs @@ -175,7 +175,8 @@ namespace Bit.App.Pages _filterResultsCancellationTokenSource); } - private CancellationTokenSource FilterResultsBackground(string searchFilter, CancellationTokenSource previousCts) + private CancellationTokenSource FilterResultsBackground(string searchFilter, + CancellationTokenSource previousCts) { var cts = new CancellationTokenSource(); Task.Run(async () => @@ -239,7 +240,8 @@ namespace Bit.App.Pages var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false); Action registerAction = () => { - var lastPushRegistration = _settings.GetValueOrDefault(Constants.PushLastRegistrationDate, DateTime.MinValue); + var lastPushRegistration = + _settings.GetValueOrDefault(Constants.PushLastRegistrationDate, DateTime.MinValue); if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) { _pushNotification.Register(); @@ -409,7 +411,8 @@ namespace Bit.App.Pages } else { - _googleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App"); + _googleAnalyticsService.TrackExtensionEvent("AutoFilled", + Uri.StartsWith("http") ? "Website" : "App"); MessagingCenter.Send(Application.Current, "Autofill", cipher); } } @@ -423,16 +426,16 @@ namespace Bit.App.Pages if(cipher.Type == CipherType.Login) { - if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) + if(!string.IsNullOrWhiteSpace(cipher.LoginPassword.Value)) { buttons.Add(AppResources.CopyPassword); } - if(!string.IsNullOrWhiteSpace(cipher.Username)) + if(!string.IsNullOrWhiteSpace(cipher.LoginUsername)) { buttons.Add(AppResources.CopyUsername); } - if(!string.IsNullOrWhiteSpace(cipher.Uri.Value) && (cipher.Uri.Value.StartsWith("http://") - || cipher.Uri.Value.StartsWith("https://"))) + if(!string.IsNullOrWhiteSpace(cipher.LoginUri.Value) && (cipher.LoginUri.Value.StartsWith("http://") + || cipher.LoginUri.Value.StartsWith("https://"))) { buttons.Add(AppResources.GoToWebsite); } @@ -463,15 +466,15 @@ namespace Bit.App.Pages } else if(selection == AppResources.CopyPassword) { - Copy(cipher.Password.Value, AppResources.Password); + Copy(cipher.LoginPassword.Value, AppResources.Password); } else if(selection == AppResources.CopyUsername) { - Copy(cipher.Username, AppResources.Username); + Copy(cipher.LoginUsername, AppResources.Username); } else if(selection == AppResources.GoToWebsite) { - Device.OpenUri(new Uri(cipher.Uri.Value)); + Device.OpenUri(new Uri(cipher.LoginUri.Value)); } else if(selection == AppResources.CopyNumber) {