public async Task SetPreviousPageInfoAsync() { 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 _stateService.SetPreviousPageInfoAsync(lastPageBeforeLock); }
public SendGroupingsPage(bool mainPage, SendType?type = null, string pageTitle = null, PreviousPageInfo previousPage = null) { _pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks); InitializeComponent(); ListView = _listView; _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _sendService = ServiceContainer.Resolve <ISendService>("sendService"); _vm = BindingContext as SendGroupingsPageViewModel; _vm.Page = this; _vm.MainPage = mainPage; _vm.Type = type; _previousPage = previousPage; if (pageTitle != null) { _vm.PageTitle = pageTitle; } if (Device.RuntimePlatform == Device.iOS) { _absLayout.Children.Remove(_fab); ToolbarItems.Add(_aboutIconItem); ToolbarItems.Add(_addItem); } else { ToolbarItems.Add(_syncItem); ToolbarItems.Add(_lockItem); ToolbarItems.Add(_aboutTextItem); } }
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null) { _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _keyConnectorService = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"); _groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage)) { Title = AppResources.MyVault, IconImageSource = "lock.png" }; Children.Add(_groupingsPage); _sendGroupingsPage = new NavigationPage(new SendGroupingsPage(true, null, null, appOptions)) { Title = AppResources.Send, IconImageSource = "send.png", }; Children.Add(_sendGroupingsPage); _generatorPage = new NavigationPage(new GeneratorPage(true, null, this)) { Title = AppResources.Generator, IconImageSource = "generate.png" }; Children.Add(_generatorPage); var settingsPage = new NavigationPage(new SettingsPage(this)) { Title = AppResources.Settings, IconImageSource = "cog_settings.png" }; Children.Add(settingsPage); if (Device.RuntimePlatform == Device.Android) { Effects.Add(new TabBarEffect()); Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetToolbarPlacement(this, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement.Bottom); Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false); Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSmoothScrollEnabled(this, false); } if (appOptions?.GeneratorTile ?? false) { appOptions.GeneratorTile = false; ResetToGeneratorPage(); } else if (appOptions?.MyVaultTile ?? false) { appOptions.MyVaultTile = false; } else if (appOptions?.CreateSend != null) { ResetToSendPage(); } }
public GroupingsPage(bool mainPage, CipherType?type = null, string folderId = null, string collectionId = null, string pageTitle = null, string vaultFilterSelection = null, PreviousPageInfo previousPage = null, bool deleted = false) { _pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks); InitializeComponent(); SetActivityIndicator(_mainContent); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _pushNotificationService = ServiceContainer.Resolve <IPushNotificationService>("pushNotificationService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _vm = BindingContext as GroupingsPageViewModel; _vm.Page = this; _vm.MainPage = mainPage; _vm.Type = type; _vm.FolderId = folderId; _vm.CollectionId = collectionId; _vm.Deleted = deleted; _previousPage = previousPage; if (pageTitle != null) { _vm.PageTitle = pageTitle; } if (vaultFilterSelection != null) { _vm.VaultFilterDescription = vaultFilterSelection; } if (Device.RuntimePlatform == Device.iOS) { _absLayout.Children.Remove(_fab); ToolbarItems.Add(_addItem); } else { ToolbarItems.Add(_syncItem); ToolbarItems.Add(_lockItem); ToolbarItems.Add(_exitItem); } if (deleted) { _absLayout.Children.Remove(_fab); ToolbarItems.Remove(_addItem); } if (!mainPage) { ToolbarItems.Remove(_accountAvatar); } }
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null) { _groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage)) { Title = AppResources.MyVault, IconImageSource = "lock.png" }; Children.Add(_groupingsPage); _sendGroupingsPage = new NavigationPage(new SendGroupingsPage(true)) { Title = AppResources.Send, IconImageSource = "paper_plane.png", }; Children.Add(_sendGroupingsPage); _generatorPage = new NavigationPage(new GeneratorPage(true, null, this)) { Title = AppResources.Generator, IconImageSource = "refresh.png" }; Children.Add(_generatorPage); var settingsPage = new NavigationPage(new SettingsPage(this)) { Title = AppResources.Settings, IconImageSource = "cog.png" }; Children.Add(settingsPage); if (Device.RuntimePlatform == Device.Android) { Effects.Add(new TabBarEffect()); Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetToolbarPlacement(this, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement.Bottom); Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false); Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSmoothScrollEnabled(this, false); } if (appOptions?.GeneratorTile ?? false) { appOptions.GeneratorTile = false; ResetToGeneratorPage(); } else if (appOptions?.MyVaultTile ?? false) { appOptions.MyVaultTile = false; } }
private async Task LockedAsync(string userId, bool userInitiated) { if (!await _stateService.IsActiveAccountAsync(userId)) { _platformUtilsService.ShowToast("info", null, AppResources.AccountLockedSuccessfully); return; } var autoPromptBiometric = !userInitiated; if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS) { var vaultTimeout = await _stateService.GetVaultTimeoutAsync(); if (vaultTimeout == 0) { autoPromptBiometric = 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 _stateService.SetPreviousPageInfoAsync(lastPageBeforeLock); var lockPage = new LockPage(Options, autoPromptBiometric); Device.BeginInvokeOnMainThread(() => Current.MainPage = new NavigationPage(lockPage)); }
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)); }
private async Task ShowPreviousPageAsync() { if (_previousPage == null) { return; } if (_previousPage.Page == "view" && !string.IsNullOrWhiteSpace(_previousPage.CipherId)) { await Navigation.PushModalAsync(new NavigationPage(new ViewPage(_previousPage.CipherId))); } else if (_previousPage.Page == "edit" && !string.IsNullOrWhiteSpace(_previousPage.CipherId)) { await Navigation.PushModalAsync(new NavigationPage(new AddEditPage(_previousPage.CipherId))); } _previousPage = null; }
private async Task ShowPreviousPageAsync() { if (_previousPage == null) { return; } await _accountListOverlay.HideAsync(); if (_previousPage.Page == "view" && !string.IsNullOrWhiteSpace(_previousPage.CipherId)) { await Navigation.PushModalAsync(new NavigationPage(new CipherDetailsPage(_previousPage.CipherId))); } else if (_previousPage.Page == "edit" && !string.IsNullOrWhiteSpace(_previousPage.CipherId)) { await Navigation.PushModalAsync(new NavigationPage(new CipherAddEditPage(_previousPage.CipherId))); } _previousPage = null; }
public GroupingsPage(bool mainPage, CipherType?type = null, string folderId = null, string collectionId = null, string pageTitle = null, PreviousPageInfo previousPage = null) { _pageName = string.Concat(nameof(GroupingsPage), "_", DateTime.UtcNow.Ticks); InitializeComponent(); ListView = _listView; SetActivityIndicator(_mainContent); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _pushNotificationService = ServiceContainer.Resolve <IPushNotificationService>("pushNotificationService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _lockService = ServiceContainer.Resolve <ILockService>("lockService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _vm = BindingContext as GroupingsPageViewModel; _vm.Page = this; _vm.MainPage = mainPage; _vm.Type = type; _vm.FolderId = folderId; _vm.CollectionId = collectionId; _previousPage = previousPage; if (pageTitle != null) { _vm.PageTitle = pageTitle; } if (Device.RuntimePlatform == Device.iOS) { _absLayout.Children.Remove(_fab); ToolbarItems.Add(_addItem); } else { _fab.Clicked = AddButton_Clicked; ToolbarItems.Add(_syncItem); ToolbarItems.Add(_lockItem); ToolbarItems.Add(_exitItem); } }