mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
support for faceid labels
This commit is contained in:
parent
898b76a549
commit
14540b4cc0
11 changed files with 79 additions and 6 deletions
|
@ -46,7 +46,7 @@ namespace Bit.Android.Services
|
||||||
public bool NfcEnabled => Utilities.NfcEnabled();
|
public bool NfcEnabled => Utilities.NfcEnabled();
|
||||||
public bool HasCamera => Xamarin.Forms.Forms.Context.PackageManager.HasSystemFeature(PackageManager.FeatureCamera);
|
public bool HasCamera => Xamarin.Forms.Forms.Context.PackageManager.HasSystemFeature(PackageManager.FeatureCamera);
|
||||||
public bool AutofillServiceSupported => AutofillSupported();
|
public bool AutofillServiceSupported => AutofillSupported();
|
||||||
|
public bool HasFaceIdSupport => false;
|
||||||
private bool AutofillSupported()
|
private bool AutofillSupported()
|
||||||
{
|
{
|
||||||
if(Build.VERSION.SdkInt < BuildVersionCodes.O)
|
if(Build.VERSION.SdkInt < BuildVersionCodes.O)
|
||||||
|
|
|
@ -8,5 +8,6 @@
|
||||||
bool NfcEnabled { get; }
|
bool NfcEnabled { get; }
|
||||||
bool HasCamera { get; }
|
bool HasCamera { get; }
|
||||||
bool AutofillServiceSupported { get; }
|
bool AutofillServiceSupported { get; }
|
||||||
|
bool HasFaceIdSupport { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Bit.App.Pages
|
||||||
private readonly IFingerprint _fingerprint;
|
private readonly IFingerprint _fingerprint;
|
||||||
private readonly ISettings _settings;
|
private readonly ISettings _settings;
|
||||||
private readonly IAppSettingsService _appSettings;
|
private readonly IAppSettingsService _appSettings;
|
||||||
|
private readonly IDeviceInfoService _deviceInfoService;
|
||||||
private readonly bool _checkFingerprintImmediately;
|
private readonly bool _checkFingerprintImmediately;
|
||||||
private DateTime? _lastAction;
|
private DateTime? _lastAction;
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ namespace Bit.App.Pages
|
||||||
_fingerprint = Resolver.Resolve<IFingerprint>();
|
_fingerprint = Resolver.Resolve<IFingerprint>();
|
||||||
_settings = Resolver.Resolve<ISettings>();
|
_settings = Resolver.Resolve<ISettings>();
|
||||||
_appSettings = Resolver.Resolve<IAppSettingsService>();
|
_appSettings = Resolver.Resolve<IAppSettingsService>();
|
||||||
|
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +34,7 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
var fingerprintIcon = new ExtendedButton
|
var fingerprintIcon = new ExtendedButton
|
||||||
{
|
{
|
||||||
Image = "fingerprint.png",
|
Image = _deviceInfoService.HasFaceIdSupport ? "smile.png" : "fingerprint.png",
|
||||||
BackgroundColor = Color.Transparent,
|
BackgroundColor = Color.Transparent,
|
||||||
Command = new Command(async () => await CheckFingerprintAsync()),
|
Command = new Command(async () => await CheckFingerprintAsync()),
|
||||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||||
|
@ -41,7 +43,8 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
var fingerprintButton = new ExtendedButton
|
var fingerprintButton = new ExtendedButton
|
||||||
{
|
{
|
||||||
Text = AppResources.UseFingerprintToUnlock,
|
Text = _deviceInfoService.HasFaceIdSupport ? AppResources.UseFaceIDToUnlock :
|
||||||
|
AppResources.UseFingerprintToUnlock,
|
||||||
Command = new Command(async () => await CheckFingerprintAsync()),
|
Command = new Command(async () => await CheckFingerprintAsync()),
|
||||||
VerticalOptions = LayoutOptions.EndAndExpand,
|
VerticalOptions = LayoutOptions.EndAndExpand,
|
||||||
Style = (Style)Application.Current.Resources["btn-primary"]
|
Style = (Style)Application.Current.Resources["btn-primary"]
|
||||||
|
@ -64,7 +67,7 @@ namespace Bit.App.Pages
|
||||||
Children = { fingerprintIcon, fingerprintButton, logoutButton }
|
Children = { fingerprintIcon, fingerprintButton, logoutButton }
|
||||||
};
|
};
|
||||||
|
|
||||||
Title = AppResources.VerifyFingerprint;
|
Title = _deviceInfoService.HasFaceIdSupport ? AppResources.VerifyFaceID : AppResources.VerifyFingerprint;
|
||||||
Content = stackLayout;
|
Content = stackLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace Bit.App.Pages
|
||||||
private readonly IPushNotificationService _pushNotification;
|
private readonly IPushNotificationService _pushNotification;
|
||||||
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
|
private readonly IDeviceInfoService _deviceInfoService;
|
||||||
private readonly ILockService _lockService;
|
private readonly ILockService _lockService;
|
||||||
|
|
||||||
// TODO: Model binding context?
|
// TODO: Model binding context?
|
||||||
|
@ -33,6 +34,7 @@ namespace Bit.App.Pages
|
||||||
_pushNotification = Resolver.Resolve<IPushNotificationService>();
|
_pushNotification = Resolver.Resolve<IPushNotificationService>();
|
||||||
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
|
||||||
_deviceActionService = Resolver.Resolve<IDeviceActionService>();
|
_deviceActionService = Resolver.Resolve<IDeviceActionService>();
|
||||||
|
_deviceInfoService = Resolver.Resolve<IDeviceInfoService>();
|
||||||
_lockService = Resolver.Resolve<ILockService>();
|
_lockService = Resolver.Resolve<ILockService>();
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
@ -91,8 +93,9 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
if((await _fingerprint.GetAvailabilityAsync()) == FingerprintAvailability.Available)
|
if((await _fingerprint.GetAvailabilityAsync()) == FingerprintAvailability.Available)
|
||||||
{
|
{
|
||||||
var fingerprintName = Helpers.OnPlatform(iOS: AppResources.TouchID, Android: AppResources.Fingerprint,
|
var fingerprintName = Helpers.OnPlatform(
|
||||||
Windows: AppResources.Fingerprint, WinPhone: AppResources.Fingerprint);
|
iOS: _deviceInfoService.HasFaceIdSupport ? AppResources.FaceID : AppResources.TouchID,
|
||||||
|
Android: AppResources.Fingerprint, Windows: AppResources.Fingerprint, WinPhone: AppResources.Fingerprint);
|
||||||
FingerprintCell = new ExtendedSwitchCell
|
FingerprintCell = new ExtendedSwitchCell
|
||||||
{
|
{
|
||||||
Text = string.Format(AppResources.UnlockWith, fingerprintName),
|
Text = string.Format(AppResources.UnlockWith, fingerprintName),
|
||||||
|
|
36
src/App/Resources/AppResources.Designer.cs
generated
36
src/App/Resources/AppResources.Designer.cs
generated
|
@ -1303,6 +1303,24 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Face ID.
|
||||||
|
/// </summary>
|
||||||
|
public static string FaceID {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("FaceID", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Use Face ID to verify..
|
||||||
|
/// </summary>
|
||||||
|
public static string FaceIDDirection {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("FaceIDDirection", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Favorite.
|
/// Looks up a localized string similar to Favorite.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2905,6 +2923,15 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Use Face ID To Unlock.
|
||||||
|
/// </summary>
|
||||||
|
public static string UseFaceIDToUnlock {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("UseFaceIDToUnlock", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Use Fingerprint to Unlock.
|
/// Looks up a localized string similar to Use Fingerprint to Unlock.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2995,6 +3022,15 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Verify Face ID.
|
||||||
|
/// </summary>
|
||||||
|
public static string VerifyFaceID {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("VerifyFaceID", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Verify Fingerprint.
|
/// Looks up a localized string similar to Verify Fingerprint.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1218,4 +1218,17 @@
|
||||||
<data name="BitwardenAutofillServiceOpenAutofillSettings" xml:space="preserve">
|
<data name="BitwardenAutofillServiceOpenAutofillSettings" xml:space="preserve">
|
||||||
<value>Open Autofill Settings</value>
|
<value>Open Autofill Settings</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="FaceID" xml:space="preserve">
|
||||||
|
<value>Face ID</value>
|
||||||
|
<comment>What Apple calls their facial recognition reader.</comment>
|
||||||
|
</data>
|
||||||
|
<data name="FaceIDDirection" xml:space="preserve">
|
||||||
|
<value>Use Face ID to verify.</value>
|
||||||
|
</data>
|
||||||
|
<data name="UseFaceIDToUnlock" xml:space="preserve">
|
||||||
|
<value>Use Face ID To Unlock</value>
|
||||||
|
</data>
|
||||||
|
<data name="VerifyFaceID" xml:space="preserve">
|
||||||
|
<value>Verify Face ID</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -41,5 +41,6 @@ namespace Bit.UWP.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AutofillServiceSupported => false;
|
public bool AutofillServiceSupported => false;
|
||||||
|
public bool HasFaceIdSupport => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
|
using Foundation;
|
||||||
|
using LocalAuthentication;
|
||||||
using UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace Bit.iOS.Core.Services
|
namespace Bit.iOS.Core.Services
|
||||||
|
@ -25,5 +27,19 @@ namespace Bit.iOS.Core.Services
|
||||||
public bool NfcEnabled => false;
|
public bool NfcEnabled => false;
|
||||||
public bool HasCamera => true;
|
public bool HasCamera => true;
|
||||||
public bool AutofillServiceSupported => false;
|
public bool AutofillServiceSupported => false;
|
||||||
|
public bool HasFaceIdSupport
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(Version < 11)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var context = new LAContext();
|
||||||
|
return context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError e) &&
|
||||||
|
context.BiometryType == LABiometryType.TypeFaceId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
src/iOS/Resources/smile.png
Normal file
BIN
src/iOS/Resources/smile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
src/iOS/Resources/smile@2x.png
Normal file
BIN
src/iOS/Resources/smile@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
src/iOS/Resources/smile@3x.png
Normal file
BIN
src/iOS/Resources/smile@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in a new issue