1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

PS-70 added copy button to totp edit cipher. Added row button when totp is null.

This commit is contained in:
André Bispo
2022-06-22 19:01:23 +01:00
parent 64beb23239
commit 9bc8e6912d
4 changed files with 70 additions and 4 deletions

View File

@@ -184,31 +184,48 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label
Text="{u:I18n AuthenticatorKey}"
StyleClass="box-label"
Grid.Row="0"
Grid.Column="0" />
<Button
Text="{Binding SetupTotpText}"
IsVisible="{Binding HasTotpValue, Converter={StaticResource inverseBool}}"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
Clicked="ScanTotp_Clicked"/>
<controls:MonoEntry
x:Name="_loginTotpEntry"
Text="{Binding Cipher.Login.Totp}"
IsSpellCheckEnabled="False"
IsTextPredictionEnabled="False"
IsVisible="{Binding HasTotpValue}"
IsPassword="{Binding Cipher.ViewPassword, Converter={StaticResource inverseBool}}"
IsEnabled="{Binding Cipher.ViewPassword}"
StyleClass="box-value"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="{Binding TotpColumnSpan}" />
<controls:IconButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding Source={x:Static core:BitwardenIcons.Clone}}"
Command="{Binding CopyCommand}"
IsVisible="{Binding HasTotpValue}"
Grid.Row="0"
Grid.Column="1"
Grid.RowSpan="2" />
<controls:IconButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding Source={x:Static core:BitwardenIcons.Camera}}"
Clicked="ScanTotp_Clicked"
Grid.Row="0"
Grid.Column="1"
Grid.Column="2"
Grid.RowSpan="2"
IsVisible="{Binding Cipher.ViewPassword}"
IsVisible="{Binding HasTotpValue}"
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ScanQrTitle}" />
</Grid>

View File

@@ -29,6 +29,7 @@ namespace Bit.App.Pages
private readonly IEventService _eventService;
private readonly IPolicyService _policyService;
private readonly ILogger _logger;
private readonly IClipboardService _clipboardService;
private CipherView _cipher;
private bool _showNotesSeparator;
@@ -53,6 +54,7 @@ namespace Bit.App.Pages
nameof(ShowUris),
nameof(ShowAttachments),
nameof(ShowCollections),
nameof(HasTotpValue)
};
private List<KeyValuePair<UriMatchType?, string>> _matchDetectionOptions =
new List<KeyValuePair<UriMatchType?, string>>
@@ -80,6 +82,7 @@ namespace Bit.App.Pages
_eventService = ServiceContainer.Resolve<IEventService>("eventService");
_policyService = ServiceContainer.Resolve<IPolicyService>("policyService");
_logger = ServiceContainer.Resolve<ILogger>("logger");
_clipboardService = ServiceContainer.Resolve<IClipboardService>("clipboardService");
GeneratePasswordCommand = new Command(GeneratePassword);
TogglePasswordCommand = new Command(TogglePassword);
@@ -89,6 +92,7 @@ namespace Bit.App.Pages
UriOptionsCommand = new Command<LoginUriView>(UriOptions);
FieldOptionsCommand = new Command<AddEditPageFieldViewModel>(FieldOptions);
PasswordPromptHelpCommand = new Command(PasswordPromptHelp);
CopyCommand = new Command(CopyTotpClipboard);
Uris = new ExtendedObservableCollection<LoginUriView>();
Fields = new ExtendedObservableCollection<AddEditPageFieldViewModel>();
Collections = new ExtendedObservableCollection<CollectionViewModel>();
@@ -150,6 +154,7 @@ namespace Bit.App.Pages
public Command UriOptionsCommand { get; set; }
public Command FieldOptionsCommand { get; set; }
public Command PasswordPromptHelpCommand { get; set; }
public Command CopyCommand { get; set; }
public string CipherId { get; set; }
public string OrganizationId { get; set; }
public string FolderId { get; set; }
@@ -300,7 +305,8 @@ namespace Bit.App.Pages
public bool AllowPersonal { get; set; }
public bool PasswordPrompt => Cipher.Reprompt != CipherRepromptType.None;
public string PasswordVisibilityAccessibilityText => ShowPassword ? AppResources.PasswordIsVisibleTapToHide : AppResources.PasswordIsNotVisibleTapToShow;
public bool HasTotpValue => !string.IsNullOrEmpty(Cipher.Login.Totp);
public string SetupTotpText => $"{BitwardenIcons.Camera} {AppResources.SetupTOTP}";
public void Init()
{
PageTitle = EditMode && !CloneMode ? AppResources.EditItem : AppResources.AddItem;
@@ -858,6 +864,11 @@ namespace Bit.App.Pages
await _platformUtilsService.ShowDialogAsync(AppResources.PasswordSafe);
}
}
private async void CopyTotpClipboard()
{
await _clipboardService.CopyTextAsync(_cipher.Login.Totp);
_platformUtilsService.ShowToast("info", null, string.Format(AppResources.ValueHasBeenCopied, AppResources.AuthenticatorKeyScanner));
}
}
public class AddEditPageFieldViewModel : ExtendedViewModel

View File

@@ -1,6 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -9,6 +10,7 @@
namespace Bit.App.Resources {
using System;
using System.Reflection;
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
@@ -4059,6 +4061,12 @@ namespace Bit.App.Resources {
}
}
public static string AuthenticatorKeyScanner {
get {
return ResourceManager.GetString("AuthenticatorKeyScanner", resourceCulture);
}
}
public static string EnterCodeManually {
get {
return ResourceManager.GetString("EnterCodeManually", resourceCulture);
@@ -4070,5 +4078,23 @@ namespace Bit.App.Resources {
return ResourceManager.GetString("AddTotp", resourceCulture);
}
}
public static string SetupTOTP {
get {
return ResourceManager.GetString("SetupTOTP", resourceCulture);
}
}
public static string OnceTheKeyIsSuccessfullyEntered {
get {
return ResourceManager.GetString("OnceTheKeyIsSuccessfullyEntered", resourceCulture);
}
}
public static string SelectAddTotpToStoreTheKeySafely {
get {
return ResourceManager.GetString("SelectAddTotpToStoreTheKeySafely", resourceCulture);
}
}
}
}

View File

@@ -2266,10 +2266,22 @@
<data name="CannotScanQRCode" xml:space="preserve">
<value>Cannot scan QR Code? </value>
</data>
<data name="AuthenticatorKeyScanner" xml:space="preserve">
<value>Authenticator Key</value>
</data>
<data name="EnterCodeManually" xml:space="preserve">
<value>Enter code manually</value>
<value>Enter Key Manually</value>
</data>
<data name="AddTotp" xml:space="preserve">
<value>Add TOTP</value>
</data>
<data name="SetupTOTP" xml:space="preserve">
<value>Set up TOTP</value>
</data>
<data name="OnceTheKeyIsSuccessfullyEntered" xml:space="preserve">
<value>Once the key is successfully entered,</value>
</data>
<data name="SelectAddTotpToStoreTheKeySafely" xml:space="preserve">
<value>select Add TOTP to store the key safely</value>
</data>
</root>