ui changes for lock screen if using key connector with biometrics (#1654)

This commit is contained in:
Jake Fink 2021-11-19 17:25:19 -05:00 committed by GitHub
parent 7d42d19ae3
commit 316cb4d21c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 23 deletions

View File

@ -34,7 +34,10 @@
<ScrollView>
<StackLayout Spacing="20">
<StackLayout StyleClass="box">
<Grid StyleClass="box-row" IsVisible="{Binding PinLock}">
<Grid
StyleClass="box-row"
IsVisible="{Binding PinLock}"
Padding="0, 10, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
@ -70,7 +73,11 @@
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ToggleVisibility}" />
</Grid>
<Grid StyleClass="box-row" IsVisible="{Binding PinLock, Converter={StaticResource inverseBool}}">
<Grid
x:Name="_passwordGrid"
StyleClass="box-row"
IsVisible="{Binding PinLock, Converter={StaticResource inverseBool}}"
Padding="0, 10, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
@ -105,13 +112,17 @@
AutomationProperties.IsInAccessibleTree="True"
AutomationProperties.Name="{u:I18n ToggleVisibility}" />
</Grid>
<Label
<StackLayout
StyleClass="box-row"
Padding="0, 10, 0, 0">
<Label
Text="{Binding LockedVerifyText}"
StyleClass="box-footer-label" />
<Label
Text="{Binding LoggedInAsText}"
StyleClass="box-footer-label"
Margin="0, 10, 0, 0" />
<Label
Text="{Binding LoggedInAsText}"
StyleClass="box-footer-label"
Margin="0, 10, 0, 0" />
</StackLayout>
</StackLayout>
<StackLayout Padding="10, 0">
<Label
@ -120,9 +131,11 @@
IsVisible="{Binding BiometricIntegrityValid, Converter={StaticResource inverseBool}}" />
<Button Text="{Binding BiometricButtonText}" Clicked="Biometric_Clicked"
IsVisible="{Binding BiometricButtonVisible}"></Button>
<Button Text="{u:I18n Unlock}"
StyleClass="btn-primary"
Clicked="Unlock_Clicked" />
<Button
x:Name="_unlockButton"
Text="{u:I18n Unlock}"
StyleClass="btn-primary"
Clicked="Unlock_Clicked" />
</StackLayout>
</StackLayout>
</ScrollView>

View File

@ -63,7 +63,7 @@ namespace Bit.App.Pages
return;
}
_appeared = true;
await _vm.InitAsync(_autoPromptBiometric);
await _vm.InitAsync();
if (!_vm.BiometricLock)
{
if (_vm.PinLock)
@ -75,6 +75,22 @@ namespace Bit.App.Pages
RequestFocus(MasterPasswordEntry);
}
}
else
{
if (_vm.UsingKeyConnector && !_vm.PinLock)
{
_passwordGrid.IsVisible = false;
_unlockButton.IsVisible = false;
}
if (_autoPromptBiometric)
{
var tasks = Task.Run(async () =>
{
await Task.Delay(500);
Device.BeginInvokeOnMainThread(async () => await _vm.PromptBiometricAsync());
});
}
}
}
private void Unlock_Clicked(object sender, EventArgs e)

View File

@ -36,6 +36,7 @@ namespace Bit.App.Pages
private bool _biometricLock;
private bool _biometricIntegrityValid = true;
private bool _biometricButtonVisible;
private bool _usingKeyConnector;
private string _biometricButtonText;
private string _loggedInAsText;
private string _lockedVerifyText;
@ -78,6 +79,11 @@ namespace Bit.App.Pages
set => SetProperty(ref _pinLock, value);
}
public bool UsingKeyConnector
{
get => _usingKeyConnector;
}
public bool BiometricLock
{
get => _biometricLock;
@ -121,14 +127,15 @@ namespace Bit.App.Pages
public string Pin { get; set; }
public Action UnlockedAction { get; set; }
public async Task InitAsync(bool autoPromptBiometric)
public async Task InitAsync()
{
_pinSet = await _vaultTimeoutService.IsPinLockSetAsync();
PinLock = (_pinSet.Item1 && _vaultTimeoutService.PinProtectedKey != null) || _pinSet.Item2;
BiometricLock = await _vaultTimeoutService.IsBiometricLockSetAsync() && await _cryptoService.HasKeyAsync();
// Users with key connector and without biometric or pin has no MP to unlock with
if (await _keyConnectorService.GetUsesKeyConnector() && !(BiometricLock || PinLock))
_usingKeyConnector = await _keyConnectorService.GetUsesKeyConnector();
if ( _usingKeyConnector && !(BiometricLock || PinLock))
{
await _vaultTimeoutService.LogOutAsync();
}
@ -147,8 +154,16 @@ namespace Bit.App.Pages
}
else
{
PageTitle = AppResources.VerifyMasterPassword;
LockedVerifyText = AppResources.VaultLockedMasterPassword;
if (_usingKeyConnector)
{
PageTitle = AppResources.UnlockVault;
LockedVerifyText = AppResources.VaultLockedIdentity;
}
else
{
PageTitle = AppResources.VerifyMasterPassword;
LockedVerifyText = AppResources.VaultLockedMasterPassword;
}
}
if (BiometricLock)
@ -167,14 +182,7 @@ namespace Bit.App.Pages
BiometricButtonText = supportsFace ? AppResources.UseFaceIDToUnlock :
AppResources.UseFingerprintToUnlock;
}
if (autoPromptBiometric)
{
var tasks = Task.Run(async () =>
{
await Task.Delay(500);
Device.BeginInvokeOnMainThread(async () => await PromptBiometricAsync());
});
}
}
}

View File

@ -2543,6 +2543,12 @@ namespace Bit.App.Resources {
}
}
public static string UnlockVault {
get {
return ResourceManager.GetString("UnlockVault", resourceCulture);
}
}
public static string ThirtyMinutes {
get {
return ResourceManager.GetString("ThirtyMinutes", resourceCulture);
@ -2573,6 +2579,12 @@ namespace Bit.App.Resources {
}
}
public static string VaultLockedIdentity {
get {
return ResourceManager.GetString("VaultLockedIdentity", resourceCulture);
}
}
public static string Dark {
get {
return ResourceManager.GetString("Dark", resourceCulture);

View File

@ -1455,6 +1455,9 @@
<data name="Unlock" xml:space="preserve">
<value>Unlock</value>
</data>
<data name="UnlockVault" xml:space="preserve">
<value>Unlock Vault</value>
</data>
<data name="ThirtyMinutes" xml:space="preserve">
<value>30 minutes</value>
</data>
@ -1471,6 +1474,9 @@
<data name="VaultLockedPIN" xml:space="preserve">
<value>Your vault is locked. Verify your PIN code to continue.</value>
</data>
<data name="VaultLockedIdentity" xml:space="preserve">
<value>Your vault is locked. Verify your identity to continue.</value>
</data>
<data name="Dark" xml:space="preserve">
<value>Dark</value>
<comment>A dark color</comment>