mirror of
https://github.com/bitwarden/mobile
synced 2026-01-05 18:13:36 +00:00
PM-1575 Added discoverable passkeys and WIP non-discoverable ones
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Bit.App.Controls
|
||||
public bool ShowIconImage
|
||||
{
|
||||
get => WebsiteIconsEnabled
|
||||
&& !string.IsNullOrWhiteSpace(Cipher.Login?.Uri)
|
||||
&& !string.IsNullOrWhiteSpace(Cipher.LaunchUri)
|
||||
&& IconImageSource != null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Bit.App.Controls
|
||||
{
|
||||
if (_iconImageSource == string.Empty) // default value since icon source can return null
|
||||
{
|
||||
_iconImageSource = IconImageHelper.GetLoginIconImage(Cipher);
|
||||
_iconImageSource = IconImageHelper.GetIconImage(Cipher);
|
||||
}
|
||||
return _iconImageSource;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace Bit.App.Pages
|
||||
set => SetProperty(ref _cipher, value, additionalPropertyNames: AdditionalPropertiesToRaiseOnCipherChanged);
|
||||
}
|
||||
|
||||
public string CreationDate => string.Format(AppResources.CreatedX, Cipher.CreationDate.ToShortDateString());
|
||||
|
||||
public AsyncCommand CheckPasswordCommand { get; }
|
||||
|
||||
protected async Task CheckPasswordAsync()
|
||||
|
||||
@@ -550,6 +550,38 @@
|
||||
StyleClass="box-value,capitalize-sentence-input" />
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
|
||||
<StackLayout IsVisible="{Binding IsFido2Key}" Spacing="0" Padding="0">
|
||||
<Label
|
||||
Text="{u:I18n Username}"
|
||||
StyleClass="box-label"
|
||||
Margin="0,10,0,0"/>
|
||||
<Entry
|
||||
x:Name="_fido2KeyUsernameEntry"
|
||||
Text="{Binding Cipher.Fido2Key.UserName}"
|
||||
StyleClass="box-value"
|
||||
Grid.Row="1"/>
|
||||
<Label
|
||||
Text="{u:I18n Passkey}"
|
||||
StyleClass="box-label"
|
||||
Margin="0,10,0,0"/>
|
||||
<Entry
|
||||
Text="{Binding CreationDate}"
|
||||
IsEnabled="False"
|
||||
StyleClass="box-value,text-muted" />
|
||||
<Label
|
||||
Text="{u:I18n Application}"
|
||||
StyleClass="box-label"
|
||||
Margin="0,10,0,0"/>
|
||||
<Entry
|
||||
Text="{Binding Cipher.Fido2Key.LaunchUri}"
|
||||
IsEnabled="False"
|
||||
StyleClass="box-value,text-muted" />
|
||||
<Label
|
||||
Text="{u:I18n YouCannotEditPasskeyApplicationBecauseItWouldInvalidateThePasskey}"
|
||||
StyleClass="box-sub-label" />
|
||||
</StackLayout>
|
||||
|
||||
</StackLayout>
|
||||
<StackLayout StyleClass="box" IsVisible="{Binding IsLogin}">
|
||||
<StackLayout StyleClass="box-row-header">
|
||||
|
||||
@@ -297,6 +297,7 @@ namespace Bit.App.Pages
|
||||
public bool IsIdentity => Cipher?.Type == CipherType.Identity;
|
||||
public bool IsCard => Cipher?.Type == CipherType.Card;
|
||||
public bool IsSecureNote => Cipher?.Type == CipherType.SecureNote;
|
||||
public bool IsFido2Key => Cipher?.Type == CipherType.Fido2Key;
|
||||
public bool ShowUris => IsLogin && Cipher.Login.HasUris;
|
||||
public bool ShowAttachments => Cipher.HasAttachments;
|
||||
public string ShowPasswordIcon => ShowPassword ? BitwardenIcons.EyeSlash : BitwardenIcons.Eye;
|
||||
|
||||
@@ -497,6 +497,56 @@
|
||||
</StackLayout>
|
||||
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowIdentityAddress}" />
|
||||
</StackLayout>
|
||||
<StackLayout
|
||||
IsVisible="{Binding IsFido2Key}"
|
||||
Spacing="0"
|
||||
Padding="0"
|
||||
Margin="0,10,0,0">
|
||||
<Label
|
||||
Text="{u:I18n Username}"
|
||||
StyleClass="box-label" />
|
||||
<Label
|
||||
Text="{Binding Cipher.Fido2Key.UserName, Mode=OneWay}"
|
||||
StyleClass="box-value" />
|
||||
<BoxView StyleClass="box-row-separator" Margin="0,10,0,0" />
|
||||
<Label
|
||||
Text="{u:I18n Passkey}"
|
||||
StyleClass="box-label"
|
||||
Margin="0,10,0,0" />
|
||||
<Label
|
||||
Text="{Binding CreationDate, Mode=OneWay}"
|
||||
StyleClass="box-value" />
|
||||
<BoxView StyleClass="box-row-separator" Margin="0,10,0,0" />
|
||||
<Grid
|
||||
StyleClass="box-row"
|
||||
RowDefinitions="Auto,*,Auto"
|
||||
ColumnDefinitions="*,Auto">
|
||||
<Label
|
||||
Text="{u:I18n Application}"
|
||||
StyleClass="box-label" />
|
||||
<Label
|
||||
Grid.Row="1"
|
||||
Text="{Binding Cipher.Fido2Key.LaunchUri, Mode=OneWay}"
|
||||
StyleClass="box-value" />
|
||||
<controls:IconButton
|
||||
StyleClass="box-row-button, box-row-button-platform"
|
||||
Text="{Binding Source={x:Static core:BitwardenIcons.ShareSquare}}"
|
||||
Command="{Binding LaunchUriCommand}"
|
||||
CommandParameter="{Binding Cipher.Fido2Key}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2"
|
||||
VerticalOptions="End"
|
||||
IsVisible="{Binding Cipher.Fido2Key.CanLaunch, Mode=OneWay}"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Launch}" />
|
||||
<BoxView
|
||||
StyleClass="box-row-separator"
|
||||
Margin="0,3,0,0"
|
||||
Grid.Row="2"
|
||||
Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
<StackLayout StyleClass="box" IsVisible="{Binding ShowUris}">
|
||||
<StackLayout StyleClass="box-row-header">
|
||||
|
||||
@@ -302,13 +302,13 @@ namespace Bit.App.Pages
|
||||
{
|
||||
ToolbarItems.Remove(_collectionsItem);
|
||||
}
|
||||
if (!ToolbarItems.Contains(_cloneItem))
|
||||
if (_vm.Cipher.Type != Core.Enums.CipherType.Fido2Key && !ToolbarItems.Contains(_cloneItem))
|
||||
{
|
||||
ToolbarItems.Insert(1, _cloneItem);
|
||||
}
|
||||
if (!ToolbarItems.Contains(_shareItem))
|
||||
{
|
||||
ToolbarItems.Insert(2, _shareItem);
|
||||
ToolbarItems.Insert(_vm.Cipher.Type == Core.Enums.CipherType.Fido2Key ? 1 : 2, _shareItem);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Bit.App.Pages
|
||||
CopyCommand = new AsyncCommand<string>((id) => CopyAsync(id, null), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false);
|
||||
CopyUriCommand = new AsyncCommand<LoginUriView>(uriView => CopyAsync("LoginUri", uriView.Uri), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false);
|
||||
CopyFieldCommand = new AsyncCommand<FieldView>(field => CopyAsync(field.Type == FieldType.Hidden ? "H_FieldValue" : "FieldValue", field.Value), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false);
|
||||
LaunchUriCommand = new Command<LoginUriView>(LaunchUri);
|
||||
LaunchUriCommand = new Command<ILaunchableView>(LaunchUri);
|
||||
TogglePasswordCommand = new Command(TogglePassword);
|
||||
ToggleCardNumberCommand = new Command(ToggleCardNumber);
|
||||
ToggleCardCodeCommand = new Command(ToggleCardCode);
|
||||
@@ -146,6 +146,7 @@ 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 IsFido2Key => Cipher?.Type == Core.Enums.CipherType.Fido2Key;
|
||||
public FormattedString ColoredPassword => GeneratedValueFormatter.Format(Cipher.Login.Password);
|
||||
public FormattedString UpdatedText
|
||||
{
|
||||
@@ -668,11 +669,11 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchUri(LoginUriView uri)
|
||||
private void LaunchUri(ILaunchableView launchableView)
|
||||
{
|
||||
if (uri.CanLaunch && (Page as BaseContentPage).DoOnce())
|
||||
if (launchableView.CanLaunch && (Page as BaseContentPage).DoOnce())
|
||||
{
|
||||
_platformUtilsService.LaunchUri(uri.LaunchUri);
|
||||
_platformUtilsService.LaunchUri(launchableView.LaunchUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,9 @@ namespace Bit.App.Pages
|
||||
case CipherType.Identity:
|
||||
_name = AppResources.TypeIdentity;
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
_name = AppResources.Passkey;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -107,6 +110,9 @@ namespace Bit.App.Pages
|
||||
case CipherType.Identity:
|
||||
_icon = BitwardenIcons.IdCard;
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
_icon = BitwardenIcons.Passkey;
|
||||
break;
|
||||
default:
|
||||
_icon = BitwardenIcons.Globe;
|
||||
break;
|
||||
|
||||
@@ -235,34 +235,17 @@ namespace Bit.App.Pages
|
||||
{
|
||||
AddTotpGroupItem(groupedItems, uppercaseGroupNames);
|
||||
|
||||
groupedItems.Add(new GroupingsPageListGroup(
|
||||
AppResources.Types, 4, uppercaseGroupNames, !hasFavorites)
|
||||
var types = Enum.GetValues(typeof(CipherType));
|
||||
var typesGroup = new GroupingsPageListGroup(AppResources.Types, types.Length, uppercaseGroupNames, !hasFavorites);
|
||||
foreach (CipherType t in types)
|
||||
{
|
||||
new GroupingsPageListItem
|
||||
typesGroup.Add(new GroupingsPageListItem
|
||||
{
|
||||
Type = CipherType.Login,
|
||||
ItemCount = (_typeCounts.ContainsKey(CipherType.Login) ?
|
||||
_typeCounts[CipherType.Login] : 0).ToString("N0")
|
||||
},
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Type = CipherType.Card,
|
||||
ItemCount = (_typeCounts.ContainsKey(CipherType.Card) ?
|
||||
_typeCounts[CipherType.Card] : 0).ToString("N0")
|
||||
},
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Type = CipherType.Identity,
|
||||
ItemCount = (_typeCounts.ContainsKey(CipherType.Identity) ?
|
||||
_typeCounts[CipherType.Identity] : 0).ToString("N0")
|
||||
},
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Type = CipherType.SecureNote,
|
||||
ItemCount = (_typeCounts.ContainsKey(CipherType.SecureNote) ?
|
||||
_typeCounts[CipherType.SecureNote] : 0).ToString("N0")
|
||||
},
|
||||
});
|
||||
Type = t,
|
||||
ItemCount = _typeCounts.GetValueOrDefault(t).ToString("N0")
|
||||
});
|
||||
}
|
||||
groupedItems.Add(typesGroup);
|
||||
}
|
||||
if (NestedFolders?.Any() ?? false)
|
||||
{
|
||||
@@ -472,6 +455,9 @@ namespace Bit.App.Pages
|
||||
case CipherType.Identity:
|
||||
title = AppResources.Identities;
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
title = AppResources.Passkeys;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -575,7 +561,9 @@ namespace Bit.App.Pages
|
||||
}
|
||||
else if (Type != null)
|
||||
{
|
||||
Filter = c => c.Type == Type.Value && !c.IsDeleted;
|
||||
Filter = c => !c.IsDeleted
|
||||
&&
|
||||
Type.Value.IsEqualToOrCanSignIn(c.Type);
|
||||
}
|
||||
else if (FolderId != null)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1" />
|
||||
<ToolbarItem Text="{u:I18n Move}" Clicked="Save_Clicked" />
|
||||
<ToolbarItem Text="{u:I18n Move}" Command="{Binding MoveCommand}" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Resources>
|
||||
|
||||
@@ -32,19 +32,6 @@ namespace Bit.App.Pages
|
||||
await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync());
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
}
|
||||
|
||||
private async void Save_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
if (DoOnce())
|
||||
{
|
||||
await _vm.SubmitAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async void Close_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
if (DoOnce())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Resources;
|
||||
using Bit.Core.Abstractions;
|
||||
@@ -8,6 +9,7 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
using Xamarin.CommunityToolkit.ObjectModel;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -34,6 +36,8 @@ namespace Bit.App.Pages
|
||||
Collections = new ExtendedObservableCollection<CollectionViewModel>();
|
||||
OrganizationOptions = new List<KeyValuePair<string, string>>();
|
||||
PageTitle = AppResources.MoveToOrganization;
|
||||
|
||||
MoveCommand = new AsyncCommand(MoveAsync, onException: ex => HandleException(ex), allowsMultipleExecutions: false);
|
||||
}
|
||||
|
||||
public string CipherId { get; set; }
|
||||
@@ -62,6 +66,8 @@ namespace Bit.App.Pages
|
||||
set => SetProperty(ref _hasOrganizations, value);
|
||||
}
|
||||
|
||||
public ICommand MoveCommand { get; }
|
||||
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
var allCollections = await _collectionService.GetAllDecryptedAsync();
|
||||
@@ -84,7 +90,7 @@ namespace Bit.App.Pages
|
||||
FilterCollections();
|
||||
}
|
||||
|
||||
public async Task<bool> SubmitAsync()
|
||||
public async Task<bool> MoveAsync()
|
||||
{
|
||||
var selectedCollectionIds = Collections?.Where(c => c.Checked).Select(c => c.Collection.Id);
|
||||
if (!selectedCollectionIds?.Any() ?? true)
|
||||
|
||||
81
src/App/Resources/AppResources.Designer.cs
generated
81
src/App/Resources/AppResources.Designer.cs
generated
@@ -202,6 +202,24 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Biometric unlock for this account is disabled pending verification of master password..
|
||||
/// </summary>
|
||||
public static string AccountBiometricInvalidated {
|
||||
get {
|
||||
return ResourceManager.GetString("AccountBiometricInvalidated", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Autofill biometric unlock for this account is disabled pending verification of master password..
|
||||
/// </summary>
|
||||
public static string AccountBiometricInvalidatedExtension {
|
||||
get {
|
||||
return ResourceManager.GetString("AccountBiometricInvalidatedExtension", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Your new account has been created! You may now log in..
|
||||
/// </summary>
|
||||
@@ -535,6 +553,15 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Application.
|
||||
/// </summary>
|
||||
public static string Application {
|
||||
get {
|
||||
return ResourceManager.GetString("Application", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Approve login requests.
|
||||
/// </summary>
|
||||
@@ -967,24 +994,6 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Biometric unlock disabled pending verification of master password..
|
||||
/// </summary>
|
||||
public static string AccountBiometricInvalidated {
|
||||
get {
|
||||
return ResourceManager.GetString("AccountBiometricInvalidated", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Biometric unlock for autofill disabled pending verification of master password..
|
||||
/// </summary>
|
||||
public static string AccountBiometricInvalidatedExtension {
|
||||
get {
|
||||
return ResourceManager.GetString("AccountBiometricInvalidatedExtension", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Biometrics.
|
||||
/// </summary>
|
||||
@@ -1660,6 +1669,15 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Created {0}.
|
||||
/// </summary>
|
||||
public static string CreatedX {
|
||||
get {
|
||||
return ResourceManager.GetString("CreatedX", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Creating account....
|
||||
/// </summary>
|
||||
@@ -4660,6 +4678,24 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Passkey.
|
||||
/// </summary>
|
||||
public static string Passkey {
|
||||
get {
|
||||
return ResourceManager.GetString("Passkey", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Passkeys.
|
||||
/// </summary>
|
||||
public static string Passkeys {
|
||||
get {
|
||||
return ResourceManager.GetString("Passkeys", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Passphrase.
|
||||
/// </summary>
|
||||
@@ -7037,6 +7073,15 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You cannot edit passkey application because it would invalidate the passkey.
|
||||
/// </summary>
|
||||
public static string YouCannotEditPasskeyApplicationBecauseItWouldInvalidateThePasskey {
|
||||
get {
|
||||
return ResourceManager.GetString("YouCannotEditPasskeyApplicationBecauseItWouldInvalidateThePasskey", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Your account has been permanently deleted.
|
||||
/// </summary>
|
||||
|
||||
@@ -2616,4 +2616,20 @@ Do you want to switch to this account?</value>
|
||||
<data name="CurrentMasterPassword" xml:space="preserve">
|
||||
<value>Current master password</value>
|
||||
</data>
|
||||
<data name="Passkey" xml:space="preserve">
|
||||
<value>Passkey</value>
|
||||
</data>
|
||||
<data name="Passkeys" xml:space="preserve">
|
||||
<value>Passkeys</value>
|
||||
</data>
|
||||
<data name="CreatedX" xml:space="preserve">
|
||||
<value>Created {0}</value>
|
||||
<comment>To state the date in which the cipher was created: Created 03/21/2023</comment>
|
||||
</data>
|
||||
<data name="Application" xml:space="preserve">
|
||||
<value>Application</value>
|
||||
</data>
|
||||
<data name="YouCannotEditPasskeyApplicationBecauseItWouldInvalidateThePasskey" xml:space="preserve">
|
||||
<value>You cannot edit passkey application because it would invalidate the passkey</value>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -78,6 +78,18 @@ namespace Bit.App.Utilities
|
||||
options.Add(AppResources.CopyNotes);
|
||||
}
|
||||
}
|
||||
if (cipher.Type == Core.Enums.CipherType.Fido2Key)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(cipher.Fido2Key.UserName))
|
||||
{
|
||||
options.Add(AppResources.CopyUsername);
|
||||
}
|
||||
if (cipher.Fido2Key.CanLaunch)
|
||||
{
|
||||
options.Add(AppResources.Launch);
|
||||
}
|
||||
}
|
||||
|
||||
var selection = await page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, options.ToArray());
|
||||
if (await vaultTimeoutService.IsLockedAsync())
|
||||
{
|
||||
@@ -96,7 +108,7 @@ namespace Bit.App.Utilities
|
||||
}
|
||||
else if (selection == AppResources.CopyUsername)
|
||||
{
|
||||
await clipboardService.CopyTextAsync(cipher.Login.Username);
|
||||
await clipboardService.CopyTextAsync(cipher.Type == CipherType.Login ? cipher.Login.Username : cipher.Fido2Key.UserName);
|
||||
platformUtilsService.ShowToastForCopiedValue(AppResources.Username);
|
||||
}
|
||||
else if (selection == AppResources.CopyPassword)
|
||||
@@ -121,9 +133,9 @@ namespace Bit.App.Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selection == AppResources.Launch)
|
||||
else if (selection == AppResources.Launch && cipher.CanLaunch)
|
||||
{
|
||||
platformUtilsService.LaunchUri(cipher.Login.LaunchUri);
|
||||
platformUtilsService.LaunchUri(cipher.LaunchUri);
|
||||
}
|
||||
else if (selection == AppResources.CopyNumber)
|
||||
{
|
||||
|
||||
@@ -8,25 +8,20 @@ namespace Bit.App.Utilities
|
||||
{
|
||||
public static string GetIcon(this CipherView cipher)
|
||||
{
|
||||
string icon = null;
|
||||
switch (cipher.Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
icon = GetLoginIconGlyph(cipher);
|
||||
break;
|
||||
return GetLoginIconGlyph(cipher);
|
||||
case CipherType.SecureNote:
|
||||
icon = BitwardenIcons.StickyNote;
|
||||
break;
|
||||
return BitwardenIcons.StickyNote;
|
||||
case CipherType.Card:
|
||||
icon = BitwardenIcons.CreditCard;
|
||||
break;
|
||||
return BitwardenIcons.CreditCard;
|
||||
case CipherType.Identity:
|
||||
icon = BitwardenIcons.IdCard;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return BitwardenIcons.IdCard;
|
||||
case CipherType.Fido2Key:
|
||||
return BitwardenIcons.Passkey;
|
||||
}
|
||||
return icon;
|
||||
return null;
|
||||
}
|
||||
|
||||
static string GetLoginIconGlyph(CipherView cipher)
|
||||
|
||||
@@ -13,31 +13,29 @@ namespace Bit.App.Utilities
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var cipher = value as CipherView;
|
||||
return GetIcon(cipher);
|
||||
return IconImageHelper.GetIconImage(cipher);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private string GetIcon(CipherView cipher)
|
||||
{
|
||||
string icon = null;
|
||||
switch (cipher.Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
icon = IconImageHelper.GetLoginIconImage(cipher);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
public static class IconImageHelper
|
||||
{
|
||||
public static string GetIconImage(CipherView cipher)
|
||||
{
|
||||
switch (cipher.Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
return IconImageHelper.GetLoginIconImage(cipher);
|
||||
case CipherType.Fido2Key:
|
||||
return IconImageHelper.GetFido2KeyIconImage(cipher);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetLoginIconImage(CipherView cipher)
|
||||
{
|
||||
string image = null;
|
||||
@@ -67,6 +65,26 @@ namespace Bit.App.Utilities
|
||||
return image;
|
||||
}
|
||||
|
||||
public static string GetFido2KeyIconImage(CipherView cipher)
|
||||
{
|
||||
var hostnameUri = cipher.Fido2Key.LaunchUri;
|
||||
if (!hostnameUri.Contains("."))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hostnameUri.Contains("://"))
|
||||
{
|
||||
hostnameUri = string.Concat("https://", hostnameUri);
|
||||
}
|
||||
if (hostnameUri.StartsWith("http"))
|
||||
{
|
||||
return GetIconUrl(hostnameUri);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetIconUrl(string hostnameUri)
|
||||
{
|
||||
IEnvironmentService _environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
|
||||
@@ -85,7 +103,6 @@ namespace Bit.App.Utilities
|
||||
}
|
||||
}
|
||||
return string.Format("{0}/{1}/icon.png", iconsUrl, hostname);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user