From 84c95166597809e0683d561645992503120be688 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 16 May 2019 12:30:13 -0400 Subject: [PATCH] log user activity --- src/App/Pages/BaseContentPage.cs | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/App/Pages/BaseContentPage.cs b/src/App/Pages/BaseContentPage.cs index c17544477..333712807 100644 --- a/src/App/Pages/BaseContentPage.cs +++ b/src/App/Pages/BaseContentPage.cs @@ -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("storageService"); + } + } + + private void SaveActivity() + { + SetStorageService(); + _storageService.SaveAsync(Constants.LastActiveKey, DateTime.UtcNow); + } } }