1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-10 21:33:36 +00:00

[PM-7369] Show passkey icon on android when the item has a Fido2 credential (#3148)

* PM-7369 Show passkey icon on android when the item has a Fido2 credential

* PM-7369 alternative way to show passkey icon only in scenarios where we are trying to create a passkey

* PM-7369 moved logic to show passkey icon to CipherItemViewModel

* Update src/Core/Utilities/IconGlyphConverter.cs

Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>

---------

Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
This commit is contained in:
Dinis Vieira
2024-04-11 13:14:45 +01:00
committed by GitHub
parent ab5e72ef83
commit 08f371b0db
6 changed files with 19 additions and 7 deletions

View File

@@ -50,7 +50,7 @@
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Center" VerticalOptions="Center"
StyleClass="list-icon, list-icon-platform" StyleClass="list-icon, list-icon-platform"
Text="{Binding Cipher, Converter={StaticResource iconGlyphConverter}}" Text="{Binding ., Converter={StaticResource iconGlyphConverter}}"
ShouldUpdateFontSizeDynamicallyForAccesibility="True" ShouldUpdateFontSizeDynamicallyForAccesibility="True"
AutomationProperties.IsInAccessibleTree="False" AutomationProperties.IsInAccessibleTree="False"
AutomationId="CipherTypeIcon" /> AutomationId="CipherTypeIcon" />

View File

@@ -52,7 +52,11 @@ namespace Bit.App.Pages
var groupedItems = new List<GroupingsPageListGroup>(); var groupedItems = new List<GroupingsPageListGroup>();
var ciphers = await _cipherService.GetAllDecryptedByUrlAsync(Uri, null); var ciphers = await _cipherService.GetAllDecryptedByUrlAsync(Uri, null);
var matching = ciphers.Item1?.Select(c => new CipherItemViewModel(c, WebsiteIconsEnabled)).ToList(); var matching = ciphers.Item1?.Select(c => new CipherItemViewModel(c, WebsiteIconsEnabled)
{
UsePasskeyIconAsPlaceholderFallback = _isAndroidFido2CredentialCreation
}).ToList();
var hasMatching = matching?.Any() ?? false; var hasMatching = matching?.Any() ?? false;
if (matching?.Any() ?? false) if (matching?.Any() ?? false)
{ {

View File

@@ -44,5 +44,7 @@ namespace Bit.App.Pages
/// This is useful to check when the cell is being reused. /// This is useful to check when the cell is being reused.
/// </summary> /// </summary>
public bool IconImageSuccesfullyLoaded { get; set; } public bool IconImageSuccesfullyLoaded { get; set; }
public bool UsePasskeyIconAsPlaceholderFallback { get; set; }
} }
} }

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Globalization; using System.Globalization;
using Bit.App.Pages;
using Bit.Core.Models.View; using Bit.Core.Models.View;
using Microsoft.Maui.Controls; using Microsoft.Maui.Controls;
using Microsoft.Maui; using Microsoft.Maui;
@@ -10,6 +11,11 @@ namespace Bit.App.Utilities
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
if (value is CipherItemViewModel cipherItemViewModel)
{
return cipherItemViewModel.Cipher?.GetIcon(cipherItemViewModel.UsePasskeyIconAsPlaceholderFallback);
}
if (value is CipherView cipher) if (value is CipherView cipher)
{ {
return cipher.GetIcon(); return cipher.GetIcon();

View File

@@ -6,12 +6,12 @@ namespace Bit.App.Utilities
{ {
public static class IconGlyphExtensions public static class IconGlyphExtensions
{ {
public static string GetIcon(this CipherView cipher) public static string GetIcon(this CipherView cipher, bool usePasskeyIconAsPlaceholderFallback = false)
{ {
switch (cipher.Type) switch (cipher.Type)
{ {
case CipherType.Login: case CipherType.Login:
return GetLoginIconGlyph(cipher); return GetLoginIconGlyph(cipher, usePasskeyIconAsPlaceholderFallback);
case CipherType.SecureNote: case CipherType.SecureNote:
return BitwardenIcons.StickyNote; return BitwardenIcons.StickyNote;
case CipherType.Card: case CipherType.Card:
@@ -22,9 +22,9 @@ namespace Bit.App.Utilities
return null; return null;
} }
static string GetLoginIconGlyph(CipherView cipher) static string GetLoginIconGlyph(CipherView cipher, bool usePasskeyIconAsPlaceholderFallback = false)
{ {
var icon = BitwardenIcons.Globe; var icon = cipher.HasFido2Credential && usePasskeyIconAsPlaceholderFallback ? BitwardenIcons.Passkey : BitwardenIcons.Globe;
if (cipher.Login.Uri != null) if (cipher.Login.Uri != null)
{ {
var hostnameUri = cipher.Login.Uri; var hostnameUri = cipher.Login.Uri;