1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-27 03:52:57 +02:00

lazy decrypt password and username for vault listing. dynamically show copy and url launch options if provided.

This commit is contained in:
Kyle Spearrin 2016-07-06 22:59:13 -04:00
parent 29c7a0ccf0
commit 31ad96ff31
4 changed files with 25 additions and 8 deletions

View File

@ -16,16 +16,16 @@ namespace Bit.App.Models.Page
FolderId = folderId;
Name = site.Name?.Decrypt();
Username = site.Username?.Decrypt() ?? " ";
Password = site.Password?.Decrypt();
Uri = site.Uri?.Decrypt();
Password = new Lazy<string>(() => site.Password?.Decrypt());
Uri = new Lazy<string>(() => site.Uri?.Decrypt());
}
public string Id { get; set; }
public string FolderId { get; set; }
public string Name { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Uri { get; set; }
public Lazy<string> Password { get; set; }
public Lazy<string> Uri { get; set; }
}
public class Folder : List<Site>

View File

@ -61,9 +61,11 @@ namespace Bit.App.Models.Page
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Uri)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(UriHost)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowUri)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowLaunch)));
}
}
public bool ShowUri => !string.IsNullOrWhiteSpace(Uri);
public bool ShowLaunch => Uri.StartsWith("http://") || Uri.StartsWith("https://");
public string UriHost
{

View File

@ -13,6 +13,7 @@ using Bit.App.Utilities;
using PushNotification.Plugin.Abstractions;
using Plugin.Settings.Abstractions;
using Plugin.Connectivity.Abstractions;
using System.Collections.Generic;
namespace Bit.App.Pages
{
@ -121,8 +122,21 @@ namespace Bit.App.Pages
private async void MoreClickedAsync(VaultListPageModel.Site site)
{
var selection = await DisplayActionSheet(site.Name, AppResources.Cancel, null,
AppResources.View, AppResources.Edit, AppResources.CopyPassword, AppResources.CopyUsername, AppResources.GoToWebsite);
var buttons = new List<string> { AppResources.View, AppResources.Edit };
if(!string.IsNullOrWhiteSpace(site.Password.Value))
{
buttons.Add(AppResources.CopyPassword);
}
if(!string.IsNullOrWhiteSpace(site.Username))
{
buttons.Add(AppResources.CopyUsername);
}
if(!string.IsNullOrWhiteSpace(site.Uri.Value) && (site.Uri.Value.StartsWith("http://") || site.Uri.Value.StartsWith("https://")))
{
buttons.Add(AppResources.GoToWebsite);
}
var selection = await DisplayActionSheet(site.Name, AppResources.Cancel, null, buttons.ToArray());
if(selection == AppResources.View)
{
@ -136,7 +150,7 @@ namespace Bit.App.Pages
}
else if(selection == AppResources.CopyPassword)
{
Copy(site.Password, AppResources.Password);
Copy(site.Password.Value, AppResources.Password);
}
else if(selection == AppResources.CopyUsername)
{
@ -144,7 +158,7 @@ namespace Bit.App.Pages
}
else if(selection == AppResources.GoToWebsite)
{
Device.OpenUri(new Uri(site.Uri));
Device.OpenUri(new Uri(site.Uri.Value));
}
}

View File

@ -67,6 +67,7 @@ namespace Bit.App.Pages
// URI
UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch);
UriCell.Value.SetBinding<VaultViewSitePageModel>(Label.TextProperty, s => s.UriHost);
UriCell.Button1.SetBinding<VaultViewSitePageModel>(IsVisibleProperty, s => s.ShowLaunch);
UriCell.Button1.Command = new Command(() => Device.OpenUri(new Uri(Model.Uri)));
// Notes