mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-23 11:45:38 +01:00
fingerprint setup
This commit is contained in:
parent
6e42f5ce7b
commit
22a0b262e1
@ -9,6 +9,9 @@ using Bit.Core.Abstractions;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Droid.Services;
|
||||
using Plugin.CurrentActivity;
|
||||
using Plugin.Fingerprint;
|
||||
using Plugin.Fingerprint.Abstractions;
|
||||
|
||||
namespace Bit.Droid
|
||||
{
|
||||
@ -34,14 +37,16 @@ namespace Bit.Droid
|
||||
{
|
||||
base.OnCreate();
|
||||
Bootstrap();
|
||||
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this);
|
||||
CrossCurrentActivity.Current.Init(this);
|
||||
}
|
||||
|
||||
private void RegisterLocalServices()
|
||||
{
|
||||
// CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
|
||||
Refractored.FabControl.Droid.FloatingActionButtonViewRenderer.Init();
|
||||
// Note: This might cause a race condition. Investigate more.
|
||||
Task.Run(() => FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true));
|
||||
CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);
|
||||
|
||||
var preferencesStorage = new PreferencesStorageService(null);
|
||||
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
|
982
src/Android/Resources/Resource.designer.cs
generated
982
src/Android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Plugin.Fingerprint" Version="1.4.9" />
|
||||
<PackageReference Include="Refractored.FloatingActionButtonForms" Version="2.1.0" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.9.961" />
|
||||
|
@ -23,6 +23,8 @@ namespace Bit.App.Pages
|
||||
private readonly IStorageService _storageService;
|
||||
private readonly ISyncService _syncService;
|
||||
|
||||
private string _fingerprintName;
|
||||
private bool _supportsFingerprint;
|
||||
private bool _pin;
|
||||
private bool _fingerprint;
|
||||
private string _lastSyncDate;
|
||||
@ -54,12 +56,20 @@ namespace Bit.App.Pages
|
||||
|
||||
GroupedItems = new ExtendedObservableCollection<SettingsPageListGroup>();
|
||||
PageTitle = AppResources.Settings;
|
||||
|
||||
_fingerprintName = AppResources.Fingerprint;
|
||||
if(Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
_fingerprintName = AppResources.TouchID;
|
||||
// TODO: face id
|
||||
}
|
||||
}
|
||||
|
||||
public ExtendedObservableCollection<SettingsPageListGroup> GroupedItems { get; set; }
|
||||
|
||||
public async Task InitAsync()
|
||||
{
|
||||
_supportsFingerprint = await _platformUtilsService.SupportsFingerprintAsync();
|
||||
var lastSync = await _syncService.GetLastSyncAsync();
|
||||
if(lastSync != null)
|
||||
{
|
||||
@ -228,7 +238,7 @@ namespace Bit.App.Pages
|
||||
await _storageService.RemoveAsync(Constants.PinProtectedKey);
|
||||
await _storageService.RemoveAsync(Constants.ProtectedPin);
|
||||
}
|
||||
|
||||
|
||||
BuildList();
|
||||
}
|
||||
|
||||
@ -243,11 +253,19 @@ namespace Bit.App.Pages
|
||||
var securityItems = new List<SettingsPageListItem>
|
||||
{
|
||||
new SettingsPageListItem { Name = AppResources.LockOptions, SubLabel = _lockOptionValue },
|
||||
new SettingsPageListItem { Name = string.Format(AppResources.UnlockWith, AppResources.Fingerprint) },
|
||||
new SettingsPageListItem { Name = AppResources.UnlockWithPIN, SubLabel = _pin ? "✓" : null },
|
||||
new SettingsPageListItem { Name = AppResources.LockNow },
|
||||
new SettingsPageListItem { Name = AppResources.TwoStepLogin }
|
||||
};
|
||||
if(_supportsFingerprint)
|
||||
{
|
||||
var item = new SettingsPageListItem
|
||||
{
|
||||
Name = string.Format(AppResources.UnlockWith, _fingerprintName),
|
||||
SubLabel = _fingerprint ? "✓" : null
|
||||
};
|
||||
securityItems.Insert(1, item);
|
||||
}
|
||||
var accountItems = new List<SettingsPageListItem>
|
||||
{
|
||||
new SettingsPageListItem { Name = AppResources.ChangeMasterPassword },
|
||||
|
@ -1,6 +1,9 @@
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Resources;
|
||||
using Bit.Core.Abstractions;
|
||||
using Plugin.Fingerprint;
|
||||
using Plugin.Fingerprint.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@ -184,5 +187,45 @@ namespace Bit.App.Services
|
||||
{
|
||||
return await Clipboard.GetTextAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> SupportsFingerprintAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await CrossFingerprint.Current.IsAvailableAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> AuthenticateFingerprintAsync(string text = null, Action fallback = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(text == null)
|
||||
{
|
||||
text = AppResources.FingerprintDirection;
|
||||
}
|
||||
var fingerprintRequest = new AuthenticationRequestConfiguration(text)
|
||||
{
|
||||
AllowAlternativeAuthentication = true,
|
||||
CancelTitle = AppResources.Cancel,
|
||||
FallbackTitle = AppResources.LogOut
|
||||
};
|
||||
var result = await CrossFingerprint.Current.AuthenticateAsync(fingerprintRequest);
|
||||
if(result.Authenticated)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(result.Status == FingerprintAuthenticationResultStatus.FallbackRequested)
|
||||
{
|
||||
fallback?.Invoke();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
@ -25,5 +26,7 @@ namespace Bit.Core.Abstractions
|
||||
void ShowToast(string type, string title, string[] text, Dictionary<string, object> options = null);
|
||||
bool SupportsU2f();
|
||||
bool SupportsDuo();
|
||||
Task<bool> SupportsFingerprintAsync();
|
||||
Task<bool> AuthenticateFingerprintAsync(string text = null, Action fallback = null);
|
||||
}
|
||||
}
|
@ -41,5 +41,7 @@
|
||||
<string>FontAwesome.ttf</string>
|
||||
<string>MaterialIcons_Regular.ttf</string>
|
||||
</array>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
<string>Use Face ID to unlock your vault.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
Loading…
Reference in New Issue
Block a user