From f7bb091366abef5df9cc84b6b7916d20361a317a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 15 May 2019 15:47:50 -0400 Subject: [PATCH] lock now button --- src/App/App.xaml.cs | 8 ++++++++ src/App/Pages/Settings/SettingsPage.xaml.cs | 4 ++++ src/App/Pages/Settings/SettingsPageViewModel.cs | 7 +++++++ src/Core/Abstractions/IStateService.cs | 1 + src/Core/Services/StateService.cs | 6 ++++++ 5 files changed, 26 insertions(+) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 0c72e069c..53d1ec65d 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -19,12 +19,14 @@ namespace Bit.App private readonly IUserService _userService; private readonly IBroadcasterService _broadcasterService; private readonly IMessagingService _messagingService; + private readonly IStateService _stateService; public App() { _userService = ServiceContainer.Resolve("userService"); _broadcasterService = ServiceContainer.Resolve("broadcasterService"); _messagingService = ServiceContainer.Resolve("messagingService"); + _stateService = ServiceContainer.Resolve("stateService"); _i18nService = ServiceContainer.Resolve("i18nService") as MobileI18nService; InitializeComponent(); @@ -53,6 +55,12 @@ namespace Bit.App } _messagingService.Send("showDialogResolve", new Tuple(details.DialogId, confirmed)); } + else if(message.Command == "locked") + { + await _stateService.PurgeAsync(); + // TODO + // MainPage = new LockPage(); + } }); } diff --git a/src/App/Pages/Settings/SettingsPage.xaml.cs b/src/App/Pages/Settings/SettingsPage.xaml.cs index 9bae64cfa..79870e544 100644 --- a/src/App/Pages/Settings/SettingsPage.xaml.cs +++ b/src/App/Pages/Settings/SettingsPage.xaml.cs @@ -84,6 +84,10 @@ namespace Bit.App.Pages { await _vm.LogOutAsync(); } + else if(item.Name == AppResources.LockNow) + { + await _vm.LockAsync(); + } } } } diff --git a/src/App/Pages/Settings/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPageViewModel.cs index 93a68f6f2..b941085d3 100644 --- a/src/App/Pages/Settings/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPageViewModel.cs @@ -17,6 +17,7 @@ namespace Bit.App.Pages private readonly IDeviceActionService _deviceActionService; private readonly IEnvironmentService _environmentService; private readonly IMessagingService _messagingService; + private readonly ILockService _lockService; public SettingsPageViewModel() { @@ -26,6 +27,7 @@ namespace Bit.App.Pages _deviceActionService = ServiceContainer.Resolve("deviceActionService"); _environmentService = ServiceContainer.Resolve("environmentService"); _messagingService = ServiceContainer.Resolve("messagingService"); + _lockService = ServiceContainer.Resolve("lockService"); PageTitle = AppResources.Settings; BuildList(); @@ -129,6 +131,11 @@ namespace Bit.App.Pages } } + public async Task LockAsync() + { + await _lockService.LockAsync(true); + } + private void BuildList() { var doUpper = Device.RuntimePlatform != Device.Android; diff --git a/src/Core/Abstractions/IStateService.cs b/src/Core/Abstractions/IStateService.cs index 03fe074b0..484ed6d52 100644 --- a/src/Core/Abstractions/IStateService.cs +++ b/src/Core/Abstractions/IStateService.cs @@ -7,5 +7,6 @@ namespace Bit.Core.Abstractions Task GetAsync(string key); Task RemoveAsync(string key); Task SaveAsync(string key, T obj); + Task PurgeAsync(); } } \ No newline at end of file diff --git a/src/Core/Services/StateService.cs b/src/Core/Services/StateService.cs index d345b88dd..c7096ec32 100644 --- a/src/Core/Services/StateService.cs +++ b/src/Core/Services/StateService.cs @@ -34,5 +34,11 @@ namespace Bit.Core.Services } return Task.FromResult(0); } + + public Task PurgeAsync() + { + _state.Clear(); + return Task.FromResult(0); + } } }