1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-18 15:37:42 +01:00

lock now button

This commit is contained in:
Kyle Spearrin 2019-05-15 15:47:50 -04:00
parent 5cf2092576
commit f7bb091366
5 changed files with 26 additions and 0 deletions

View File

@ -19,12 +19,14 @@ namespace Bit.App
private readonly IUserService _userService; private readonly IUserService _userService;
private readonly IBroadcasterService _broadcasterService; private readonly IBroadcasterService _broadcasterService;
private readonly IMessagingService _messagingService; private readonly IMessagingService _messagingService;
private readonly IStateService _stateService;
public App() public App()
{ {
_userService = ServiceContainer.Resolve<IUserService>("userService"); _userService = ServiceContainer.Resolve<IUserService>("userService");
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService"); _broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService"); _messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService; _i18nService = ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService;
InitializeComponent(); InitializeComponent();
@ -53,6 +55,12 @@ namespace Bit.App
} }
_messagingService.Send("showDialogResolve", new Tuple<int, bool>(details.DialogId, confirmed)); _messagingService.Send("showDialogResolve", new Tuple<int, bool>(details.DialogId, confirmed));
} }
else if(message.Command == "locked")
{
await _stateService.PurgeAsync();
// TODO
// MainPage = new LockPage();
}
}); });
} }

View File

@ -84,6 +84,10 @@ namespace Bit.App.Pages
{ {
await _vm.LogOutAsync(); await _vm.LogOutAsync();
} }
else if(item.Name == AppResources.LockNow)
{
await _vm.LockAsync();
}
} }
} }
} }

View File

@ -17,6 +17,7 @@ namespace Bit.App.Pages
private readonly IDeviceActionService _deviceActionService; private readonly IDeviceActionService _deviceActionService;
private readonly IEnvironmentService _environmentService; private readonly IEnvironmentService _environmentService;
private readonly IMessagingService _messagingService; private readonly IMessagingService _messagingService;
private readonly ILockService _lockService;
public SettingsPageViewModel() public SettingsPageViewModel()
{ {
@ -26,6 +27,7 @@ namespace Bit.App.Pages
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService"); _deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService"); _environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService"); _messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
_lockService = ServiceContainer.Resolve<ILockService>("lockService");
PageTitle = AppResources.Settings; PageTitle = AppResources.Settings;
BuildList(); BuildList();
@ -129,6 +131,11 @@ namespace Bit.App.Pages
} }
} }
public async Task LockAsync()
{
await _lockService.LockAsync(true);
}
private void BuildList() private void BuildList()
{ {
var doUpper = Device.RuntimePlatform != Device.Android; var doUpper = Device.RuntimePlatform != Device.Android;

View File

@ -7,5 +7,6 @@ namespace Bit.Core.Abstractions
Task<T> GetAsync<T>(string key); Task<T> GetAsync<T>(string key);
Task RemoveAsync(string key); Task RemoveAsync(string key);
Task SaveAsync<T>(string key, T obj); Task SaveAsync<T>(string key, T obj);
Task PurgeAsync();
} }
} }

View File

@ -34,5 +34,11 @@ namespace Bit.Core.Services
} }
return Task.FromResult(0); return Task.FromResult(0);
} }
public Task PurgeAsync()
{
_state.Clear();
return Task.FromResult(0);
}
} }
} }