subtitles for each type

This commit is contained in:
Kyle Spearrin 2017-10-20 12:47:05 -04:00
parent 296c9dc055
commit cc0bb65096
4 changed files with 56 additions and 32 deletions

View file

@ -140,14 +140,14 @@ namespace Bit.Android
{ {
var isPremium = Resolver.Resolve<ITokenService>()?.TokenPremium ?? false; var isPremium = Resolver.Resolve<ITokenService>()?.TokenPremium ?? false;
var autoCopyEnabled = !_settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, 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("uri", cipher.LoginUri.Value);
data.PutExtra("username", cipher.Username); data.PutExtra("username", cipher.LoginUsername);
data.PutExtra("password", cipher.Password.Value); data.PutExtra("password", cipher.LoginPassword.Value);
} }
if(Parent == null) if(Parent == null)

View file

@ -22,27 +22,48 @@ namespace Bit.App.Models.Page
switch(cipher.Type) switch(cipher.Type)
{ {
case CipherType.Login: case CipherType.Login:
Username = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " "; LoginUsername = cipher.Login?.Username?.Decrypt(cipher.OrganizationId) ?? " ";
Password = new Lazy<string>(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId)); LoginPassword = new Lazy<string>(() => cipher.Login?.Password?.Decrypt(cipher.OrganizationId));
Uri = new Lazy<string>(() => cipher.Login?.Uri?.Decrypt(cipher.OrganizationId)); LoginUri = new Lazy<string>(() => cipher.Login?.Uri?.Decrypt(cipher.OrganizationId));
Totp = new Lazy<string>(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId)); LoginTotp = new Lazy<string>(() => cipher.Login?.Totp?.Decrypt(cipher.OrganizationId));
Subtitle = Username; Subtitle = LoginUsername;
break; break;
case CipherType.SecureNote: case CipherType.SecureNote:
Subtitle = " "; Subtitle = " ";
break; break;
case CipherType.Card: 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) ?? " "; var cardBrand = cipher.Card?.Brand?.Decrypt(cipher.OrganizationId) ?? " ";
CardCode = new Lazy<string>(() => cipher.Card?.Code?.Decrypt(cipher.OrganizationId)); CardCode = new Lazy<string>(() => 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; break;
case CipherType.Identity: case CipherType.Identity:
var firstName = cipher.Identity?.FirstName?.Decrypt(cipher.OrganizationId) ?? " "; var firstName = cipher.Identity?.FirstName?.Decrypt(cipher.OrganizationId) ?? " ";
var lastName = cipher.Identity?.LastName?.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; break;
default: default:
break; break;
@ -58,10 +79,10 @@ namespace Bit.App.Models.Page
public CipherType Type { get; set; } public CipherType Type { get; set; }
// Login metadata // Login metadata
public string Username { get; set; } public string LoginUsername { get; set; }
public Lazy<string> Password { get; set; } public Lazy<string> LoginPassword { get; set; }
public Lazy<string> Uri { get; set; } public Lazy<string> LoginUri { get; set; }
public Lazy<string> Totp { get; set; } public Lazy<string> LoginTotp { get; set; }
// Login metadata // Login metadata
public string CardNumber { get; set; } public string CardNumber { get; set; }

View file

@ -176,7 +176,7 @@ namespace Bit.App.Pages
var fuzzyLogins = ciphers?.Item2.Select(l => new VaultListPageModel.AutofillCipher(l, true)) var fuzzyLogins = ciphers?.Item2.Select(l => new VaultListPageModel.AutofillCipher(l, true))
.OrderBy(s => s.Name) .OrderBy(s => s.Name)
.ThenBy(s => s.Username) .ThenBy(s => s.LoginUsername)
.ToList(); .ToList();
if(fuzzyLogins?.Any() ?? false) if(fuzzyLogins?.Any() ?? false)
{ {
@ -242,11 +242,11 @@ namespace Bit.App.Pages
if(cipher.Type == CipherType.Login) if(cipher.Type == CipherType.Login)
{ {
if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) if(!string.IsNullOrWhiteSpace(cipher.LoginPassword.Value))
{ {
buttons.Add(AppResources.CopyPassword); buttons.Add(AppResources.CopyPassword);
} }
if(!string.IsNullOrWhiteSpace(cipher.Username)) if(!string.IsNullOrWhiteSpace(cipher.LoginUsername))
{ {
buttons.Add(AppResources.CopyUsername); buttons.Add(AppResources.CopyUsername);
} }
@ -277,11 +277,11 @@ namespace Bit.App.Pages
} }
else if(selection == AppResources.CopyPassword) else if(selection == AppResources.CopyPassword)
{ {
Copy(cipher.Password.Value, AppResources.Password); Copy(cipher.LoginPassword.Value, AppResources.Password);
} }
else if(selection == AppResources.CopyUsername) else if(selection == AppResources.CopyUsername)
{ {
Copy(cipher.Username, AppResources.Username); Copy(cipher.LoginUsername, AppResources.Username);
} }
else if(selection == AppResources.CopyNumber) else if(selection == AppResources.CopyNumber)
{ {

View file

@ -175,7 +175,8 @@ namespace Bit.App.Pages
_filterResultsCancellationTokenSource); _filterResultsCancellationTokenSource);
} }
private CancellationTokenSource FilterResultsBackground(string searchFilter, CancellationTokenSource previousCts) private CancellationTokenSource FilterResultsBackground(string searchFilter,
CancellationTokenSource previousCts)
{ {
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
Task.Run(async () => Task.Run(async () =>
@ -239,7 +240,8 @@ namespace Bit.App.Pages
var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false); var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false);
Action registerAction = () => 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)) if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
{ {
_pushNotification.Register(); _pushNotification.Register();
@ -409,7 +411,8 @@ namespace Bit.App.Pages
} }
else else
{ {
_googleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App"); _googleAnalyticsService.TrackExtensionEvent("AutoFilled",
Uri.StartsWith("http") ? "Website" : "App");
MessagingCenter.Send(Application.Current, "Autofill", cipher); MessagingCenter.Send(Application.Current, "Autofill", cipher);
} }
} }
@ -423,16 +426,16 @@ namespace Bit.App.Pages
if(cipher.Type == CipherType.Login) if(cipher.Type == CipherType.Login)
{ {
if(!string.IsNullOrWhiteSpace(cipher.Password.Value)) if(!string.IsNullOrWhiteSpace(cipher.LoginPassword.Value))
{ {
buttons.Add(AppResources.CopyPassword); buttons.Add(AppResources.CopyPassword);
} }
if(!string.IsNullOrWhiteSpace(cipher.Username)) if(!string.IsNullOrWhiteSpace(cipher.LoginUsername))
{ {
buttons.Add(AppResources.CopyUsername); buttons.Add(AppResources.CopyUsername);
} }
if(!string.IsNullOrWhiteSpace(cipher.Uri.Value) && (cipher.Uri.Value.StartsWith("http://") if(!string.IsNullOrWhiteSpace(cipher.LoginUri.Value) && (cipher.LoginUri.Value.StartsWith("http://")
|| cipher.Uri.Value.StartsWith("https://"))) || cipher.LoginUri.Value.StartsWith("https://")))
{ {
buttons.Add(AppResources.GoToWebsite); buttons.Add(AppResources.GoToWebsite);
} }
@ -463,15 +466,15 @@ namespace Bit.App.Pages
} }
else if(selection == AppResources.CopyPassword) else if(selection == AppResources.CopyPassword)
{ {
Copy(cipher.Password.Value, AppResources.Password); Copy(cipher.LoginPassword.Value, AppResources.Password);
} }
else if(selection == AppResources.CopyUsername) else if(selection == AppResources.CopyUsername)
{ {
Copy(cipher.Username, AppResources.Username); Copy(cipher.LoginUsername, AppResources.Username);
} }
else if(selection == AppResources.GoToWebsite) else if(selection == AppResources.GoToWebsite)
{ {
Device.OpenUri(new Uri(cipher.Uri.Value)); Device.OpenUri(new Uri(cipher.LoginUri.Value));
} }
else if(selection == AppResources.CopyNumber) else if(selection == AppResources.CopyNumber)
{ {