private async Task LockedAsync(bool autoPromptFingerprint) { await _stateService.PurgeAsync(); if (autoPromptFingerprint && Device.RuntimePlatform == Device.iOS) { var lockOptions = await _storageService.GetAsync <int?>(Constants.LockOptionKey); if (lockOptions == 0) { autoPromptFingerprint = false; } } else if (autoPromptFingerprint && Device.RuntimePlatform == Device.Android && _deviceActionService.UseNativeBiometric()) { autoPromptFingerprint = false; } PreviousPageInfo lastPageBeforeLock = null; if (Current.MainPage is TabbedPage tabbedPage && tabbedPage.Navigation.ModalStack.Count > 0) { var topPage = tabbedPage.Navigation.ModalStack[tabbedPage.Navigation.ModalStack.Count - 1]; if (topPage is NavigationPage navPage) { if (navPage.CurrentPage is ViewPage viewPage) { lastPageBeforeLock = new PreviousPageInfo { Page = "view", CipherId = viewPage.ViewModel.CipherId }; } else if (navPage.CurrentPage is AddEditPage addEditPage && addEditPage.ViewModel.EditMode) { lastPageBeforeLock = new PreviousPageInfo { Page = "edit", CipherId = addEditPage.ViewModel.CipherId }; } } } await _storageService.SaveAsync(Constants.PreviousPageKey, lastPageBeforeLock); var lockPage = new LockPage(_appOptions, autoPromptFingerprint); Device.BeginInvokeOnMainThread(() => Current.MainPage = new NavigationPage(lockPage)); }
public async Task <bool> AuthenticateBiometricAsync(string text = null, string fallbackText = null, Action fallback = null) { if (_deviceActionService.UseNativeBiometric()) { return(await _deviceActionService.AuthenticateBiometricAsync(text)); } else { try { if (text == null) { var supportsFace = await _deviceActionService.SupportsFaceBiometricAsync(); text = supportsFace ? AppResources.FaceIDDirection : AppResources.FingerprintDirection; } var fingerprintRequest = new AuthenticationRequestConfiguration(text, text) { 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); } }
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) { await Navigation.PushModalAsync(new NavigationPage(new ExportVaultPage())); } 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) { var supportsFace = await _deviceActionService.SupportsFaceBiometricAsync(); fingerprintName = supportsFace ? AppResources.FaceID : AppResources.TouchID; } else if (Device.RuntimePlatform == Device.Android && _deviceActionService.UseNativeBiometric()) { fingerprintName = AppResources.Biometrics; } if (item.Name == string.Format(AppResources.UnlockWith, fingerprintName)) { await _vm.UpdateFingerprintAsync(); } } }
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 }); } var accessibilityEnabled = _deviceActionService.AutofillAccessibilityServiceRunning() && _deviceActionService.AutofillAccessibilityOverlayPermitted(); autofillItems.Add(new SettingsPageListItem { Name = AppResources.AutofillAccessibilityService, SubLabel = accessibilityEnabled ? 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 || _fingerprint) { var fingerprintName = AppResources.Fingerprint; if (Device.RuntimePlatform == Device.iOS) { fingerprintName = _deviceActionService.SupportsFaceBiometric() ? AppResources.FaceID : AppResources.TouchID; } else if (Device.RuntimePlatform == Device.Android && _deviceActionService.UseNativeBiometric()) { fingerprintName = AppResources.Biometrics; } 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) }); }