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

log user activity

This commit is contained in:
Kyle Spearrin 2019-05-16 12:30:13 -04:00
parent 3eb1ab0452
commit 84c9516659

View File

@ -1,4 +1,7 @@
using System;
using Bit.Core;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
@ -6,11 +9,25 @@ namespace Bit.App.Pages
{
public class BaseContentPage : ContentPage
{
private IStorageService _storageService;
protected int AndroidShowModalAnimationDelay = 400;
protected int AndroidShowPageAnimationDelay = 100;
public DateTime? LastPageAction { get; set; }
protected override void OnAppearing()
{
base.OnAppearing();
SaveActivity();
}
protected override void OnDisappearing()
{
base.OnDisappearing();
SaveActivity();
}
public bool DoOnce(Action action = null, int milliseconds = 1000)
{
if(LastPageAction.HasValue && (DateTime.UtcNow - LastPageAction.Value).TotalMilliseconds < milliseconds)
@ -84,5 +101,19 @@ namespace Bit.App.Pages
Device.BeginInvokeOnMainThread(() => input.Focus());
});
}
private void SetStorageService()
{
if(_storageService == null)
{
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
}
}
private void SaveActivity()
{
SetStorageService();
_storageService.SaveAsync(Constants.LastActiveKey, DateTime.UtcNow);
}
}
}