public async Task <bool> AuthenticateFingerprintAsync(string text = null, string fallbackText = null, Action fallback = null) { try { if (text == null) { text = _deviceActionService.SupportsFaceId() ? AppResources.FaceIDDirection : AppResources.FingerprintDirection; } var fingerprintRequest = new AuthenticationRequestConfiguration(text) { AllowAlternativeAuthentication = true, CancelTitle = AppResources.Cancel, FallbackTitle = fallbackText }; var result = await CrossFingerprint.Current.AuthenticateAsync(fingerprintRequest); if (result.Authenticated) { return(true); } else if (result.Status == FingerprintAuthenticationResultStatus.FallbackRequested) { fallback?.Invoke(); } } catch { } return(false); }
public override void ViewDidLoad() { _lockService = ServiceContainer.Resolve <ILockService>("lockService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _pinSet = _lockService.IsPinLockSetAsync().GetAwaiter().GetResult(); _hasKey = _cryptoService.HasKeyAsync().GetAwaiter().GetResult(); _pinLock = (_pinSet.Item1 && _hasKey) || _pinSet.Item2; _fingerprintLock = _lockService.IsFingerprintLockSetAsync().GetAwaiter().GetResult(); BaseNavItem.Title = _pinLock ? AppResources.VerifyPIN : AppResources.VerifyMasterPassword; BaseCancelButton.Title = AppResources.Cancel; BaseSubmitButton.Title = AppResources.Submit; var descriptor = UIFontDescriptor.PreferredBody; MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword; MasterPasswordCell.TextField.SecureTextEntry = true; MasterPasswordCell.TextField.ReturnKeyType = UIReturnKeyType.Go; MasterPasswordCell.TextField.ShouldReturn += (UITextField tf) => { CheckPasswordAsync().GetAwaiter().GetResult(); return(true); }; if (_pinLock) { MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad; } TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 70; TableView.Source = new TableSource(this); TableView.AllowsSelection = true; base.ViewDidLoad(); if (_fingerprintLock) { var fingerprintButtonText = _deviceActionService.SupportsFaceId() ? AppResources.UseFaceIDToUnlock : AppResources.UseFingerprintToUnlock; // TODO: set button text var tasks = Task.Run(async() => { await Task.Delay(500); NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptFingerprintAsync()); }); } }
public SettingsPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cryptoService = ServiceContainer.Resolve <ICryptoService>("cryptoService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _environmentService = ServiceContainer.Resolve <IEnvironmentService>("environmentService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _lockService = ServiceContainer.Resolve <ILockService>("lockService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); GroupedItems = new ExtendedObservableCollection <SettingsPageListGroup>(); PageTitle = AppResources.Settings; _fingerprintName = AppResources.Fingerprint; if (Device.RuntimePlatform == Device.iOS) { _fingerprintName = _deviceActionService.SupportsFaceId() ? AppResources.FaceID : AppResources.TouchID; } }
public void BuildList() { var doUpper = Device.RuntimePlatform != Device.Android; var autofillItems = new List <SettingsPageListItem>(); if (Device.RuntimePlatform == Device.Android) { if (_deviceActionService.SupportsAutofillService()) { autofillItems.Add(new SettingsPageListItem { Name = AppResources.AutofillService, SubLabel = _deviceActionService.AutofillServiceEnabled() ? AppResources.Enabled : AppResources.Disabled }); } autofillItems.Add(new SettingsPageListItem { Name = AppResources.AutofillAccessibilityService, SubLabel = _deviceActionService.AutofillAccessibilityServiceRunning() ? AppResources.Enabled : AppResources.Disabled }); } else { if (_deviceActionService.SystemMajorVersion() >= 12) { autofillItems.Add(new SettingsPageListItem { Name = AppResources.PasswordAutofill }); } autofillItems.Add(new SettingsPageListItem { Name = AppResources.AppExtension }); } var manageItems = new List <SettingsPageListItem> { new SettingsPageListItem { Name = AppResources.Folders }, new SettingsPageListItem { Name = AppResources.Sync, SubLabel = _lastSyncDate } }; var securityItems = new List <SettingsPageListItem> { new SettingsPageListItem { Name = AppResources.LockOptions, SubLabel = _lockOptionValue }, new SettingsPageListItem { Name = AppResources.UnlockWithPIN, SubLabel = _pin ? AppResources.Enabled : AppResources.Disabled }, new SettingsPageListItem { Name = AppResources.LockNow }, new SettingsPageListItem { Name = AppResources.TwoStepLogin } }; if (_supportsFingerprint) { var fingerprintName = AppResources.Fingerprint; if (Device.RuntimePlatform == Device.iOS) { fingerprintName = _deviceActionService.SupportsFaceId() ? AppResources.FaceID : AppResources.TouchID; } var item = new SettingsPageListItem { Name = string.Format(AppResources.UnlockWith, fingerprintName), SubLabel = _fingerprint ? AppResources.Enabled : AppResources.Disabled }; securityItems.Insert(1, item); } var accountItems = new List <SettingsPageListItem> { new SettingsPageListItem { Name = AppResources.ChangeMasterPassword }, new SettingsPageListItem { Name = AppResources.FingerprintPhrase }, new SettingsPageListItem { Name = AppResources.LogOut } }; var toolsItems = new List <SettingsPageListItem> { new SettingsPageListItem { Name = AppResources.ImportItems }, new SettingsPageListItem { Name = AppResources.ExportVault }, new SettingsPageListItem { Name = AppResources.ShareVault }, new SettingsPageListItem { Name = AppResources.WebVault } }; var otherItems = new List <SettingsPageListItem> { new SettingsPageListItem { Name = AppResources.Options }, new SettingsPageListItem { Name = AppResources.About }, new SettingsPageListItem { Name = AppResources.HelpAndFeedback }, new SettingsPageListItem { Name = AppResources.RateTheApp } }; GroupedItems.ResetWithRange(new List <SettingsPageListGroup> { new SettingsPageListGroup(autofillItems, AppResources.Autofill, doUpper, true), new SettingsPageListGroup(manageItems, AppResources.Manage, doUpper), new SettingsPageListGroup(securityItems, AppResources.Security, doUpper), new SettingsPageListGroup(accountItems, AppResources.Account, doUpper), new SettingsPageListGroup(toolsItems, AppResources.Tools, doUpper), new SettingsPageListGroup(otherItems, AppResources.Other, doUpper) }); }
private async void RowSelected(object sender, SelectedItemChangedEventArgs e) { ((ListView)sender).SelectedItem = null; if (!DoOnce()) { return; } if (!(e.SelectedItem is SettingsPageListItem item)) { return; } if (item.Name == AppResources.Sync) { await Navigation.PushModalAsync(new NavigationPage(new SyncPage())); } else if (item.Name == AppResources.AutofillAccessibilityService) { await Navigation.PushModalAsync(new NavigationPage(new AccessibilityServicePage(this))); } else if (item.Name == AppResources.AutofillService) { await Navigation.PushModalAsync(new NavigationPage(new AutofillServicePage(this))); } else if (item.Name == AppResources.PasswordAutofill) { await Navigation.PushModalAsync(new NavigationPage(new AutofillPage())); } else if (item.Name == AppResources.AppExtension) { await Navigation.PushModalAsync(new NavigationPage(new ExtensionPage())); } else if (item.Name == AppResources.Options) { await Navigation.PushModalAsync(new NavigationPage(new OptionsPage())); } else if (item.Name == AppResources.Folders) { await Navigation.PushModalAsync(new NavigationPage(new FoldersPage())); } else if (item.Name == AppResources.About) { await _vm.AboutAsync(); } else if (item.Name == AppResources.HelpAndFeedback) { _vm.Help(); } else if (item.Name == AppResources.FingerprintPhrase) { await _vm.FingerprintAsync(); } else if (item.Name == AppResources.RateTheApp) { _vm.Rate(); } else if (item.Name == AppResources.ImportItems) { _vm.Import(); } else if (item.Name == AppResources.ExportVault) { _vm.Export(); } else if (item.Name == AppResources.ShareVault) { await _vm.ShareAsync(); } else if (item.Name == AppResources.WebVault) { _vm.WebVault(); } else if (item.Name == AppResources.ChangeMasterPassword) { await _vm.ChangePasswordAsync(); } else if (item.Name == AppResources.TwoStepLogin) { await _vm.TwoStepAsync(); } else if (item.Name == AppResources.LogOut) { await _vm.LogOutAsync(); } else if (item.Name == AppResources.LockNow) { await _vm.LockAsync(); } else if (item.Name == AppResources.LockOptions) { await _vm.LockOptionsAsync(); } else if (item.Name == AppResources.UnlockWithPIN) { await _vm.UpdatePinAsync(); } else { var fingerprintName = AppResources.Fingerprint; if (Device.RuntimePlatform == Device.iOS) { fingerprintName = _deviceActionService.SupportsFaceId() ? AppResources.FaceID : AppResources.TouchID; } if (item.Name == string.Format(AppResources.UnlockWith, fingerprintName)) { await _vm.UpdateFingerprintAsync(); } } }