diff --git a/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs b/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs
index fc57dd2da..56b61285c 100644
--- a/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs
+++ b/src/App/Pages/Vault/AutofillCiphersPageViewModel.cs
@@ -1,6 +1,7 @@
using Bit.App.Abstractions;
using Bit.App.Models;
using Bit.App.Resources;
+using Bit.App.Utilities;
using Bit.Core;
using Bit.Core.Abstractions;
using Bit.Core.Enums;
@@ -98,7 +99,7 @@ namespace Bit.App.Pages
{
if(_deviceActionService.SystemMajorVersion() < 21)
{
- // TODO
+ await AppHelpers.CipherListOptions(Page, cipher);
}
else
{
diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs
index 83317aa91..ef0770e2d 100644
--- a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs
+++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs
@@ -1,4 +1,5 @@
using Bit.App.Resources;
+using Bit.App.Utilities;
using Bit.Core.Abstractions;
using Bit.Core.Enums;
using Bit.Core.Models.Domain;
@@ -374,16 +375,10 @@ namespace Bit.App.Pages
private async void CipherOptionsAsync(CipherView cipher)
{
- if(!(Page as BaseContentPage).DoOnce())
+ if((Page as BaseContentPage).DoOnce())
{
- return;
+ await AppHelpers.CipherListOptions(Page, cipher);
}
- var option = await Page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, "1", "2");
- if(option == AppResources.Cancel)
- {
- return;
- }
- // TODO: process options
}
}
}
diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs
index c092e5047..fa82442b5 100644
--- a/src/App/Resources/AppResources.Designer.cs
+++ b/src/App/Resources/AppResources.Designer.cs
@@ -987,6 +987,15 @@ namespace Bit.App.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Copy Notes.
+ ///
+ public static string CopyNotes {
+ get {
+ return ResourceManager.GetString("CopyNotes", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Copy Number.
///
diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx
index 772231572..dbd110e16 100644
--- a/src/App/Resources/AppResources.resx
+++ b/src/App/Resources/AppResources.resx
@@ -1564,4 +1564,7 @@
Restarting...
+
+ Copy Notes
+
\ No newline at end of file
diff --git a/src/App/Utilities/AppHelpers.cs b/src/App/Utilities/AppHelpers.cs
new file mode 100644
index 000000000..fe3494874
--- /dev/null
+++ b/src/App/Utilities/AppHelpers.cs
@@ -0,0 +1,109 @@
+using Bit.App.Pages;
+using Bit.App.Resources;
+using Bit.Core.Abstractions;
+using Bit.Core.Models.View;
+using Bit.Core.Utilities;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+
+namespace Bit.App.Utilities
+{
+ public static class AppHelpers
+ {
+ public static async Task CipherListOptions(ContentPage page, CipherView cipher)
+ {
+ var platformUtilsService = ServiceContainer.Resolve("platformUtilsService");
+ var options = new List { AppResources.View, AppResources.Edit };
+ if(cipher.Type == Core.Enums.CipherType.Login)
+ {
+ if(!string.IsNullOrWhiteSpace(cipher.Login.Username))
+ {
+ options.Add(AppResources.CopyUsername);
+ }
+ if(!string.IsNullOrWhiteSpace(cipher.Login.Password))
+ {
+ options.Add(AppResources.CopyPassword);
+ }
+ if(!string.IsNullOrWhiteSpace(cipher.Login.Totp))
+ {
+ options.Add(AppResources.CopyTotp);
+ }
+ if(cipher.Login.CanLaunch)
+ {
+ options.Add(AppResources.Launch);
+ }
+ }
+ else if(cipher.Type == Core.Enums.CipherType.Card)
+ {
+ if(!string.IsNullOrWhiteSpace(cipher.Card.Number))
+ {
+ options.Add(AppResources.CopyNumber);
+ }
+ if(!string.IsNullOrWhiteSpace(cipher.Card.Code))
+ {
+ options.Add(AppResources.CopySecurityCode);
+ }
+ }
+ else if(cipher.Type == Core.Enums.CipherType.SecureNote)
+ {
+ if(!string.IsNullOrWhiteSpace(cipher.Notes))
+ {
+ options.Add(AppResources.CopyNotes);
+ }
+ }
+ var selection = await page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, options.ToArray());
+ if(selection == AppResources.View)
+ {
+ await page.Navigation.PushModalAsync(new NavigationPage(new ViewPage(cipher.Id)));
+ }
+ else if(selection == AppResources.Edit)
+ {
+ await page.Navigation.PushModalAsync(new NavigationPage(new AddEditPage(cipher.Id)));
+ }
+ else if(selection == AppResources.CopyUsername)
+ {
+ await platformUtilsService.CopyToClipboardAsync(cipher.Login.Username);
+ platformUtilsService.ShowToast("info", null, AppResources.CopiedUsername);
+ }
+ else if(selection == AppResources.CopyPassword)
+ {
+ await platformUtilsService.CopyToClipboardAsync(cipher.Login.Password);
+ platformUtilsService.ShowToast("info", null, AppResources.CopiedPassword);
+ }
+ else if(selection == AppResources.CopyTotp)
+ {
+ var totpService = ServiceContainer.Resolve("totpService");
+ var totp = await totpService.GetCodeAsync(cipher.Login.Totp);
+ if(!string.IsNullOrWhiteSpace(totp))
+ {
+ await platformUtilsService.CopyToClipboardAsync(totp);
+ platformUtilsService.ShowToast("info", null, AppResources.CopiedTotp);
+ }
+ }
+ else if(selection == AppResources.Launch)
+ {
+ platformUtilsService.LaunchUri(cipher.Login.LaunchUri);
+ }
+ else if(selection == AppResources.CopyNumber)
+ {
+ await platformUtilsService.CopyToClipboardAsync(cipher.Card.Number);
+ platformUtilsService.ShowToast("info", null,
+ string.Format(AppResources.ValueHasBeenCopied, AppResources.Number));
+ }
+ else if(selection == AppResources.CopySecurityCode)
+ {
+ await platformUtilsService.CopyToClipboardAsync(cipher.Card.Code);
+ platformUtilsService.ShowToast("info", null,
+ string.Format(AppResources.ValueHasBeenCopied, AppResources.SecurityCode));
+ }
+ else if(selection == AppResources.CopyNotes)
+ {
+ await platformUtilsService.CopyToClipboardAsync(cipher.Notes);
+ platformUtilsService.ShowToast("info", null,
+ string.Format(AppResources.ValueHasBeenCopied, AppResources.Notes));
+ }
+ return selection;
+ }
+ }
+}