mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
misc section with folders
This commit is contained in:
parent
b07afa7f11
commit
fb5c36071d
5 changed files with 103 additions and 44 deletions
|
@ -348,7 +348,7 @@
|
||||||
<controls:RepeaterView ItemsSource="{Binding Uris}">
|
<controls:RepeaterView ItemsSource="{Binding Uris}">
|
||||||
<controls:RepeaterView.ItemTemplate>
|
<controls:RepeaterView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="views:LoginUriView">
|
<DataTemplate x:DataType="views:LoginUriView">
|
||||||
<Grid StyleClass="box-row">
|
<Grid StyleClass="box-row, box-row-input">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
|
@ -383,12 +383,28 @@
|
||||||
<Button Text="{u:I18n NewUri}" StyleClass="box-button-row"
|
<Button Text="{u:I18n NewUri}" StyleClass="box-button-row"
|
||||||
Clicked="NewUri_Clicked"></Button>
|
Clicked="NewUri_Clicked"></Button>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box">
|
||||||
|
<StackLayout StyleClass="box-row-header">
|
||||||
|
<Label Text="{u:I18n Miscellaneous}"
|
||||||
|
StyleClass="box-header, box-header-platform" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box-row, box-row-input">
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n Folder}"
|
||||||
|
StyleClass="box-label" />
|
||||||
|
<Picker
|
||||||
|
x:Name="_folderPicker"
|
||||||
|
ItemsSource="{Binding FolderOptions, Mode=OneTime}"
|
||||||
|
SelectedIndex="{Binding FolderSelectedIndex}"
|
||||||
|
StyleClass="box-value" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
<StackLayout StyleClass="box">
|
<StackLayout StyleClass="box">
|
||||||
<StackLayout StyleClass="box-row-header">
|
<StackLayout StyleClass="box-row-header">
|
||||||
<Label Text="{u:I18n Notes}"
|
<Label Text="{u:I18n Notes}"
|
||||||
StyleClass="box-header, box-header-platform" />
|
StyleClass="box-header, box-header-platform" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout StyleClass="box-row">
|
<StackLayout StyleClass="box-row, box-row-input">
|
||||||
<Editor
|
<Editor
|
||||||
Text="{Binding Cipher.Notes}"
|
Text="{Binding Cipher.Notes}"
|
||||||
StyleClass="box-value"
|
StyleClass="box-value"
|
||||||
|
@ -404,7 +420,7 @@
|
||||||
<controls:RepeaterView.ItemTemplate>
|
<controls:RepeaterView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="pages:AddEditPageFieldViewModel">
|
<DataTemplate x:DataType="pages:AddEditPageFieldViewModel">
|
||||||
<StackLayout Spacing="0" Padding="0">
|
<StackLayout Spacing="0" Padding="0">
|
||||||
<Grid StyleClass="box-row">
|
<Grid StyleClass="box-row, box-row-input">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace Bit.App.Pages
|
||||||
_cardBrandPicker.ItemDisplayBinding = new Binding("Key");
|
_cardBrandPicker.ItemDisplayBinding = new Binding("Key");
|
||||||
_cardExpMonthPicker.ItemDisplayBinding = new Binding("Key");
|
_cardExpMonthPicker.ItemDisplayBinding = new Binding("Key");
|
||||||
_identityTitlePicker.ItemDisplayBinding = new Binding("Key");
|
_identityTitlePicker.ItemDisplayBinding = new Binding("Key");
|
||||||
|
_folderPicker.ItemDisplayBinding = new Binding("Key");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnAppearing()
|
protected override async void OnAppearing()
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
private readonly ICipherService _cipherService;
|
private readonly ICipherService _cipherService;
|
||||||
|
private readonly IFolderService _folderService;
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
private readonly IPlatformUtilsService _platformUtilsService;
|
private readonly IPlatformUtilsService _platformUtilsService;
|
||||||
private readonly IAuditService _auditService;
|
private readonly IAuditService _auditService;
|
||||||
|
@ -27,6 +28,7 @@ namespace Bit.App.Pages
|
||||||
private int _cardBrandSelectedIndex;
|
private int _cardBrandSelectedIndex;
|
||||||
private int _cardExpMonthSelectedIndex;
|
private int _cardExpMonthSelectedIndex;
|
||||||
private int _identityTitleSelectedIndex;
|
private int _identityTitleSelectedIndex;
|
||||||
|
private int _folderSelectedIndex;
|
||||||
private string[] _additionalCipherProperties = new string[]
|
private string[] _additionalCipherProperties = new string[]
|
||||||
{
|
{
|
||||||
nameof(IsLogin),
|
nameof(IsLogin),
|
||||||
|
@ -60,6 +62,7 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||||
_cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
_cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||||
|
_folderService = ServiceContainer.Resolve<IFolderService>("folderService");
|
||||||
_userService = ServiceContainer.Resolve<IUserService>("userService");
|
_userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||||
_auditService = ServiceContainer.Resolve<IAuditService>("auditService");
|
_auditService = ServiceContainer.Resolve<IAuditService>("auditService");
|
||||||
|
@ -117,6 +120,7 @@ namespace Bit.App.Pages
|
||||||
new KeyValuePair<string, string>(AppResources.Ms, AppResources.Ms),
|
new KeyValuePair<string, string>(AppResources.Ms, AppResources.Ms),
|
||||||
new KeyValuePair<string, string>(AppResources.Dr, AppResources.Dr),
|
new KeyValuePair<string, string>(AppResources.Dr, AppResources.Dr),
|
||||||
};
|
};
|
||||||
|
FolderOptions = new List<KeyValuePair<string, string>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command GeneratePasswordCommand { get; set; }
|
public Command GeneratePasswordCommand { get; set; }
|
||||||
|
@ -134,6 +138,7 @@ namespace Bit.App.Pages
|
||||||
public List<KeyValuePair<string, string>> CardBrandOptions { get; set; }
|
public List<KeyValuePair<string, string>> CardBrandOptions { get; set; }
|
||||||
public List<KeyValuePair<string, string>> CardExpMonthOptions { get; set; }
|
public List<KeyValuePair<string, string>> CardExpMonthOptions { get; set; }
|
||||||
public List<KeyValuePair<string, string>> IdentityTitleOptions { get; set; }
|
public List<KeyValuePair<string, string>> IdentityTitleOptions { get; set; }
|
||||||
|
public List<KeyValuePair<string, string>> FolderOptions { get; set; }
|
||||||
public ExtendedObservableCollection<LoginUriView> Uris { get; set; }
|
public ExtendedObservableCollection<LoginUriView> Uris { get; set; }
|
||||||
public ExtendedObservableCollection<AddEditPageFieldViewModel> Fields { get; set; }
|
public ExtendedObservableCollection<AddEditPageFieldViewModel> Fields { get; set; }
|
||||||
public int TypeSelectedIndex
|
public int TypeSelectedIndex
|
||||||
|
@ -172,6 +177,15 @@ namespace Bit.App.Pages
|
||||||
IdentityTitleChanged();
|
IdentityTitleChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public int FolderSelectedIndex
|
||||||
|
{
|
||||||
|
get => _folderSelectedIndex;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _folderSelectedIndex, value);
|
||||||
|
FolderChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
public CipherView Cipher
|
public CipherView Cipher
|
||||||
{
|
{
|
||||||
get => _cipher;
|
get => _cipher;
|
||||||
|
@ -217,12 +231,18 @@ namespace Bit.App.Pages
|
||||||
public async Task LoadAsync()
|
public async Task LoadAsync()
|
||||||
{
|
{
|
||||||
// TODO: load collections
|
// TODO: load collections
|
||||||
|
var folders = await _folderService.GetAllDecryptedAsync();
|
||||||
|
FolderOptions = folders.Select(f => new KeyValuePair<string, string>(f.Name, f.Id)).ToList();
|
||||||
|
|
||||||
|
if(Cipher == null)
|
||||||
|
{
|
||||||
if(EditMode)
|
if(EditMode)
|
||||||
{
|
{
|
||||||
var cipher = await _cipherService.GetAsync(CipherId);
|
var cipher = await _cipherService.GetAsync(CipherId);
|
||||||
Cipher = await cipher.DecryptAsync();
|
Cipher = await cipher.DecryptAsync();
|
||||||
|
|
||||||
|
FolderSelectedIndex = string.IsNullOrWhiteSpace(Cipher.FolderId) ? FolderOptions.Count - 1 :
|
||||||
|
FolderOptions.FindIndex(k => k.Value == Cipher.FolderId); ;
|
||||||
if(Cipher.Card != null)
|
if(Cipher.Card != null)
|
||||||
{
|
{
|
||||||
CardBrandSelectedIndex = string.IsNullOrWhiteSpace(Cipher.Card.Brand) ? 0 :
|
CardBrandSelectedIndex = string.IsNullOrWhiteSpace(Cipher.Card.Brand) ? 0 :
|
||||||
|
@ -255,6 +275,7 @@ namespace Bit.App.Pages
|
||||||
CardBrandSelectedIndex = 0;
|
CardBrandSelectedIndex = 0;
|
||||||
CardExpMonthSelectedIndex = 0;
|
CardExpMonthSelectedIndex = 0;
|
||||||
IdentityTitleSelectedIndex = 0;
|
IdentityTitleSelectedIndex = 0;
|
||||||
|
FolderSelectedIndex = FolderOptions.Count - 1;
|
||||||
// TODO: org/collection stuff
|
// TODO: org/collection stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +288,7 @@ namespace Bit.App.Pages
|
||||||
Fields.ResetWithRange(Cipher.Fields?.Select(f => new AddEditPageFieldViewModel(f)));
|
Fields.ResetWithRange(Cipher.Fields?.Select(f => new AddEditPageFieldViewModel(f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> SubmitAsync()
|
public async Task<bool> SubmitAsync()
|
||||||
{
|
{
|
||||||
|
@ -484,6 +506,14 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FolderChanged()
|
||||||
|
{
|
||||||
|
if(Cipher != null && FolderSelectedIndex > -1)
|
||||||
|
{
|
||||||
|
Cipher.FolderId = FolderOptions[FolderSelectedIndex].Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void TriggerCipherChanged()
|
private void TriggerCipherChanged()
|
||||||
{
|
{
|
||||||
TriggerPropertyChanged(nameof(Cipher), _additionalCipherProperties);
|
TriggerPropertyChanged(nameof(Cipher), _additionalCipherProperties);
|
||||||
|
|
9
src/App/Resources/AppResources.Designer.cs
generated
9
src/App/Resources/AppResources.Designer.cs
generated
|
@ -2274,6 +2274,15 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Miscellaneous.
|
||||||
|
/// </summary>
|
||||||
|
public static string Miscellaneous {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Miscellaneous", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to More.
|
/// Looks up a localized string similar to More.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1417,4 +1417,7 @@
|
||||||
<data name="MoveUp" xml:space="preserve">
|
<data name="MoveUp" xml:space="preserve">
|
||||||
<value>Move Up</value>
|
<value>Move Up</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Miscellaneous" xml:space="preserve">
|
||||||
|
<value>Miscellaneous</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in a new issue