1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 01:23:15 +00:00

Lock Screen Fixes

- Move settings to AppSettingsService
- Update activity on page disappaearing
- Always check if app is currently locked before updating last activity
date
This commit is contained in:
Kyle Spearrin
2017-04-28 11:07:26 -04:00
parent be47bb7263
commit 01736ca685
13 changed files with 102 additions and 23 deletions

View File

@@ -9,19 +9,32 @@ namespace Bit.App.Services
public class LockService : ILockService
{
private readonly ISettings _settings;
private readonly IAppSettingsService _appSettings;
private readonly IAuthService _authService;
private readonly IFingerprint _fingerprint;
public LockService(
ISettings settings,
IAppSettingsService appSettings,
IAuthService authService,
IFingerprint fingerprint)
{
_settings = settings;
_appSettings = appSettings;
_authService = authService;
_fingerprint = fingerprint;
}
public void UpdateLastActivity(DateTime? activityDate = null)
{
if(_appSettings.Locked)
{
return;
}
_appSettings.LastActivity = activityDate.GetValueOrDefault(DateTime.UtcNow);
}
public LockType GetLockType(bool forceLock)
{
// Only lock if they are logged in
@@ -31,7 +44,7 @@ namespace Bit.App.Services
}
// Are we forcing a lock? (i.e. clicking a button to lock the app manually, immediately)
if(!forceLock && !_settings.GetValueOrDefault(Constants.Locked, false))
if(!forceLock && !_appSettings.Locked)
{
// Lock seconds tells if they want to lock the app or not
var lockSeconds = _settings.GetValueOrDefault(Constants.SettingLockSeconds, 60 * 15);
@@ -42,8 +55,7 @@ namespace Bit.App.Services
// Has it been longer than lockSeconds since the last time the app was used?
var now = DateTime.UtcNow;
var lastBackground = _settings.GetValueOrDefault(Constants.LastActivityDate, now.AddYears(-1));
if((now - lastBackground).TotalSeconds < lockSeconds)
if((now - _appSettings.LastActivity).TotalSeconds < lockSeconds)
{
return LockType.None;
}