1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-19 17:53:47 +00:00

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
5 changed files with 78 additions and 23 deletions

View File

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

View File

@@ -63,7 +63,7 @@ namespace Bit.App.Pages
return; return;
} }
_appeared = true; _appeared = true;
await _vm.InitAsync(_autoPromptBiometric); await _vm.InitAsync();
if (!_vm.BiometricLock) if (!_vm.BiometricLock)
{ {
if (_vm.PinLock) if (_vm.PinLock)
@@ -75,6 +75,22 @@ namespace Bit.App.Pages
RequestFocus(MasterPasswordEntry); 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) private void Unlock_Clicked(object sender, EventArgs e)

View File

@@ -36,6 +36,7 @@ namespace Bit.App.Pages
private bool _biometricLock; private bool _biometricLock;
private bool _biometricIntegrityValid = true; private bool _biometricIntegrityValid = true;
private bool _biometricButtonVisible; private bool _biometricButtonVisible;
private bool _usingKeyConnector;
private string _biometricButtonText; private string _biometricButtonText;
private string _loggedInAsText; private string _loggedInAsText;
private string _lockedVerifyText; private string _lockedVerifyText;
@@ -78,6 +79,11 @@ namespace Bit.App.Pages
set => SetProperty(ref _pinLock, value); set => SetProperty(ref _pinLock, value);
} }
public bool UsingKeyConnector
{
get => _usingKeyConnector;
}
public bool BiometricLock public bool BiometricLock
{ {
get => _biometricLock; get => _biometricLock;
@@ -121,14 +127,15 @@ namespace Bit.App.Pages
public string Pin { get; set; } public string Pin { get; set; }
public Action UnlockedAction { get; set; } public Action UnlockedAction { get; set; }
public async Task InitAsync(bool autoPromptBiometric) public async Task InitAsync()
{ {
_pinSet = await _vaultTimeoutService.IsPinLockSetAsync(); _pinSet = await _vaultTimeoutService.IsPinLockSetAsync();
PinLock = (_pinSet.Item1 && _vaultTimeoutService.PinProtectedKey != null) || _pinSet.Item2; PinLock = (_pinSet.Item1 && _vaultTimeoutService.PinProtectedKey != null) || _pinSet.Item2;
BiometricLock = await _vaultTimeoutService.IsBiometricLockSetAsync() && await _cryptoService.HasKeyAsync(); BiometricLock = await _vaultTimeoutService.IsBiometricLockSetAsync() && await _cryptoService.HasKeyAsync();
// Users with key connector and without biometric or pin has no MP to unlock with // 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(); await _vaultTimeoutService.LogOutAsync();
} }
@@ -146,10 +153,18 @@ namespace Bit.App.Pages
LockedVerifyText = AppResources.VaultLockedPIN; LockedVerifyText = AppResources.VaultLockedPIN;
} }
else else
{
if (_usingKeyConnector)
{
PageTitle = AppResources.UnlockVault;
LockedVerifyText = AppResources.VaultLockedIdentity;
}
else
{ {
PageTitle = AppResources.VerifyMasterPassword; PageTitle = AppResources.VerifyMasterPassword;
LockedVerifyText = AppResources.VaultLockedMasterPassword; LockedVerifyText = AppResources.VaultLockedMasterPassword;
} }
}
if (BiometricLock) if (BiometricLock)
{ {
@@ -167,14 +182,7 @@ namespace Bit.App.Pages
BiometricButtonText = supportsFace ? AppResources.UseFaceIDToUnlock : BiometricButtonText = supportsFace ? AppResources.UseFaceIDToUnlock :
AppResources.UseFingerprintToUnlock; 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 { public static string ThirtyMinutes {
get { get {
return ResourceManager.GetString("ThirtyMinutes", resourceCulture); 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 { public static string Dark {
get { get {
return ResourceManager.GetString("Dark", resourceCulture); return ResourceManager.GetString("Dark", resourceCulture);

View File

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