From d7312e2977f274a1f613a16d71975f25da6862ff Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 26 Apr 2019 16:58:20 -0400 Subject: [PATCH] uris, fields, etc to view page --- .../Vault/GroupingsPage/GroupingsPage.xaml.cs | 1 + src/App/Pages/Vault/ViewPage.xaml | 361 ++++++++++++------ src/App/Pages/Vault/ViewPageViewModel.cs | 43 ++- src/App/Resources/AppResources.Designer.cs | 9 + src/App/Resources/AppResources.resx | 4 + src/App/Styles/Android.xaml | 4 +- src/Core/Models/View/LoginView.cs | 8 +- 7 files changed, 295 insertions(+), 135 deletions(-) diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index ce355507f..a34b5a8f0 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -42,6 +42,7 @@ namespace Bit.App.Pages protected async override void OnAppearing() { base.OnAppearing(); + // await _syncService.FullSyncAsync(true); _broadcasterService.Subscribe(nameof(GroupingsPage), async (message) => { if(message.Command == "syncCompleted") diff --git a/src/App/Pages/Vault/ViewPage.xaml b/src/App/Pages/Vault/ViewPage.xaml index 3bb3fc26c..d64e29036 100644 --- a/src/App/Pages/Vault/ViewPage.xaml +++ b/src/App/Pages/Vault/ViewPage.xaml @@ -6,7 +6,9 @@ xmlns:pages="clr-namespace:Bit.App.Pages" xmlns:u="clr-namespace:Bit.App.Utilities" xmlns:controls="clr-namespace:Bit.App.Controls" + xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore" x:DataType="pages:ViewPageViewModel" + x:Name="_page" Title="{Binding PageTitle}"> @@ -17,130 +19,241 @@ Text="{u:I18n Edit}" /> - - - + diff --git a/src/App/Pages/Vault/ViewPageViewModel.cs b/src/App/Pages/Vault/ViewPageViewModel.cs index b078403fa..e45cdfdda 100644 --- a/src/App/Pages/Vault/ViewPageViewModel.cs +++ b/src/App/Pages/Vault/ViewPageViewModel.cs @@ -31,12 +31,16 @@ namespace Bit.App.Pages _userService = ServiceContainer.Resolve("userService"); _totpService = ServiceContainer.Resolve("totpService"); _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); - CopyCommand = new Command(CopyAsync); + CopyCommand = new Command((id) => CopyAsync(id, null)); + CopyUriCommand = new Command(CopyUriAsync); + LaunchUriCommand = new Command(LaunchUriAsync); PageTitle = AppResources.ViewItem; } public Command CopyCommand { get; set; } + public Command CopyUriCommand { get; set; } + public Command LaunchUriCommand { get; set; } public string CipherId { get; set; } public CipherView Cipher { @@ -47,7 +51,11 @@ namespace Bit.App.Pages nameof(IsLogin), nameof(IsIdentity), nameof(IsCard), - nameof(IsSecureNote) + nameof(IsSecureNote), + nameof(ShowUris), + nameof(ShowFields), + nameof(ShowNotes), + nameof(ShowTotp) }); } public bool CanAccessPremium @@ -59,10 +67,19 @@ namespace Bit.App.Pages public bool IsIdentity => _cipher?.Type == Core.Enums.CipherType.Identity; public bool IsCard => _cipher?.Type == Core.Enums.CipherType.Card; public bool IsSecureNote => _cipher?.Type == Core.Enums.CipherType.SecureNote; + public bool ShowUris => IsLogin && _cipher.Login.HasUris; + public bool ShowNotes => !string.IsNullOrWhiteSpace(_cipher.Notes); + public bool ShowFields => _cipher.HasFields; + public bool ShowTotp => !string.IsNullOrWhiteSpace(_cipher.Login.Totp) && + !string.IsNullOrWhiteSpace(TotpCodeFormatted); public string TotpCodeFormatted { get => _totpCodeFormatted; - set => SetProperty(ref _totpCodeFormatted, value); + set => SetProperty(ref _totpCodeFormatted, value, + additionalPropertyNames: new string[] + { + nameof(ShowTotp) + }); } public string TotpSec { @@ -151,9 +168,8 @@ namespace Bit.App.Pages } } - private async void CopyAsync(string id) + private async void CopyAsync(string id, string text = null) { - string text = null; string name = null; if(id == "LoginUsername") { @@ -170,6 +186,10 @@ namespace Bit.App.Pages text = _totpCode; name = AppResources.VerificationCodeTotp; } + else if(id == "LoginUri") + { + name = AppResources.URI; + } if(text != null) { @@ -180,5 +200,18 @@ namespace Bit.App.Pages } } } + + private void CopyUriAsync(LoginUriView uri) + { + CopyAsync("LoginUri", uri.Uri); + } + + private void LaunchUriAsync(LoginUriView uri) + { + if(uri.CanLaunch) + { + _platformUtilsService.LaunchUri(uri.LaunchUri); + } + } } } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index e70d9b87a..fe38a3fa7 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -3246,6 +3246,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to URIs. + /// + internal static string URIs { + get { + return ResourceManager.GetString("URIs", resourceCulture); + } + } + /// /// Looks up a localized string similar to Use another two-step login method. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 85b65c2eb..21e91a76a 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1364,4 +1364,8 @@ All Items + + URIs + Plural form of a URI + \ No newline at end of file diff --git a/src/App/Styles/Android.xaml b/src/App/Styles/Android.xaml index 1d9580ef3..ef55b6be4 100644 --- a/src/App/Styles/Android.xaml +++ b/src/App/Styles/Android.xaml @@ -40,8 +40,8 @@ ApplyToDerivedTypes="True" Class="box-row-button-platform"> + Value="37" /> + Value="25" /> diff --git a/src/Core/Models/View/LoginView.cs b/src/Core/Models/View/LoginView.cs index 0164ca9cf..e0d0ba3b5 100644 --- a/src/Core/Models/View/LoginView.cs +++ b/src/Core/Models/View/LoginView.cs @@ -19,11 +19,11 @@ namespace Bit.Core.Models.View public DateTime? PasswordRevisionDate { get; set; } public string Totp { get; set; } public List Uris { get; set; } - public string Uri => HashUris ? Uris[0].Uri : null; + public string Uri => HasUris ? Uris[0].Uri : null; public string MaskedPassword => Password != null ? "••••••••" : null; public string SubTitle => Username; - public bool CanLaunch => HashUris && Uris.Any(u => u.CanLaunch); - public string LaunchUri => HashUris ? Uris.FirstOrDefault(u => u.CanLaunch)?.LaunchUri : null; - public bool HashUris => (Uris?.Count ?? 0) > 0; + public bool CanLaunch => HasUris && Uris.Any(u => u.CanLaunch); + public string LaunchUri => HasUris ? Uris.FirstOrDefault(u => u.CanLaunch)?.LaunchUri : null; + public bool HasUris => (Uris?.Count ?? 0) > 0; } }