mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
pass gen fixes
This commit is contained in:
parent
99f00b8e63
commit
9400c22e4f
4 changed files with 41 additions and 13 deletions
|
@ -35,7 +35,7 @@
|
|||
Text="{Binding Password}"
|
||||
Margin="0, 20"
|
||||
StyleClass="text-lg"
|
||||
HorizontalOptions="Center"
|
||||
HorizontalTextAlignment="Center"
|
||||
LineBreakMode="CharacterWrap" />
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Button Text="{u:I18n RegeneratePassword}"
|
||||
|
@ -78,8 +78,8 @@
|
|||
VerticalTextAlignment="Center" />
|
||||
<Stepper
|
||||
Value="{Binding NumWords}"
|
||||
Minimum="3"
|
||||
Maximum="20"
|
||||
Minimum="3"
|
||||
Increment="1" />
|
||||
</StackLayout>
|
||||
<BoxView StyleClass="box-row-separator" />
|
||||
|
@ -108,8 +108,8 @@
|
|||
StyleClass="box-value"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
Minimum="0"
|
||||
Maximum="128" />
|
||||
Maximum="128"
|
||||
Minimum="5" />
|
||||
</StackLayout>
|
||||
<BoxView StyleClass="box-row-separator" />
|
||||
<StackLayout StyleClass="box-row, box-row-switch">
|
||||
|
@ -171,8 +171,8 @@
|
|||
VerticalTextAlignment="Center" />
|
||||
<Stepper
|
||||
Value="{Binding MinNumber}"
|
||||
Minimum="0"
|
||||
Maximum="5"
|
||||
Minimum="0"
|
||||
Increment="1" />
|
||||
</StackLayout>
|
||||
<BoxView StyleClass="box-row-separator" />
|
||||
|
@ -191,8 +191,8 @@
|
|||
VerticalTextAlignment="Center" />
|
||||
<Stepper
|
||||
Value="{Binding MinSpecial}"
|
||||
Minimum="0"
|
||||
Maximum="5"
|
||||
Minimum="0"
|
||||
Increment="1" />
|
||||
</StackLayout>
|
||||
<BoxView StyleClass="box-row-separator" />
|
||||
|
|
|
@ -5,12 +5,22 @@ namespace Bit.App.Pages
|
|||
public partial class GeneratorPage : BaseContentPage
|
||||
{
|
||||
private GeneratorPageViewModel _vm;
|
||||
private readonly Action<string> _selectAction;
|
||||
|
||||
public GeneratorPage()
|
||||
: this(null)
|
||||
{ }
|
||||
|
||||
public GeneratorPage(Action<string> selectAction)
|
||||
{
|
||||
InitializeComponent();
|
||||
_vm = BindingContext as GeneratorPageViewModel;
|
||||
_vm.Page = this;
|
||||
_selectAction = selectAction;
|
||||
if(selectAction == null)
|
||||
{
|
||||
ToolbarItems.Remove(_selectItem);
|
||||
}
|
||||
}
|
||||
|
||||
protected async override void OnAppearing()
|
||||
|
@ -31,7 +41,7 @@ namespace Bit.App.Pages
|
|||
|
||||
private void Select_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
_selectAction?.Invoke(_vm.Password);
|
||||
}
|
||||
|
||||
private void History_Clicked(object sender, EventArgs e)
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace Bit.App.Pages
|
|||
private bool _avoidAmbiguous;
|
||||
private int _minNumber;
|
||||
private int _minSpecial;
|
||||
private int _length;
|
||||
private int _numWords;
|
||||
private int _length = 5;
|
||||
private int _numWords = 3;
|
||||
private string _wordSeparator;
|
||||
private int _typeSelectedIndex;
|
||||
private bool _doneIniting;
|
||||
|
@ -173,9 +173,10 @@ namespace Bit.App.Pages
|
|||
get => _wordSeparator;
|
||||
set
|
||||
{
|
||||
if(SetProperty(ref _wordSeparator, value))
|
||||
var val = value.Trim();
|
||||
if(SetProperty(ref _wordSeparator, val))
|
||||
{
|
||||
_options.WordSeparator = value;
|
||||
_options.WordSeparator = val;
|
||||
var task = SaveOptionsAsync();
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +245,7 @@ namespace Bit.App.Pages
|
|||
WordSeparator = _options.WordSeparator;
|
||||
Uppercase = _options.Uppercase.GetValueOrDefault();
|
||||
Lowercase = _options.Lowercase.GetValueOrDefault();
|
||||
Length = _options.Length.GetValueOrDefault(5);
|
||||
}
|
||||
|
||||
private void SetOptions()
|
||||
|
@ -258,6 +260,7 @@ namespace Bit.App.Pages
|
|||
_options.WordSeparator = WordSeparator;
|
||||
_options.Uppercase = Uppercase;
|
||||
_options.Lowercase = Lowercase;
|
||||
_options.Length = Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -418,9 +418,24 @@ namespace Bit.App.Pages
|
|||
return false;
|
||||
}
|
||||
|
||||
public void GeneratePassword()
|
||||
public async void GeneratePassword()
|
||||
{
|
||||
// TODO: push modal for generate page
|
||||
if(!string.IsNullOrWhiteSpace(Cipher?.Login?.Password))
|
||||
{
|
||||
var confirmed = await _platformUtilsService.ShowDialogAsync(AppResources.PasswordOverrideAlert,
|
||||
null, AppResources.Yes, AppResources.No);
|
||||
if(!confirmed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
var page = new GeneratorPage(async (password) =>
|
||||
{
|
||||
Cipher.Login.Password = password;
|
||||
TriggerCipherChanged();
|
||||
await Page.Navigation.PopModalAsync();
|
||||
});
|
||||
await Page.Navigation.PushModalAsync(new NavigationPage(page));
|
||||
}
|
||||
|
||||
public async void UriOptions(LoginUriView uri)
|
||||
|
|
Loading…
Reference in a new issue