mirror of
https://github.com/bitwarden/mobile
synced 2025-12-24 04:04:34 +00:00
log user activity
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
using System;
|
using Bit.Core;
|
||||||
|
using Bit.Core.Abstractions;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
@@ -6,11 +9,25 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
public class BaseContentPage : ContentPage
|
public class BaseContentPage : ContentPage
|
||||||
{
|
{
|
||||||
|
private IStorageService _storageService;
|
||||||
|
|
||||||
protected int AndroidShowModalAnimationDelay = 400;
|
protected int AndroidShowModalAnimationDelay = 400;
|
||||||
protected int AndroidShowPageAnimationDelay = 100;
|
protected int AndroidShowPageAnimationDelay = 100;
|
||||||
|
|
||||||
public DateTime? LastPageAction { get; set; }
|
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)
|
public bool DoOnce(Action action = null, int milliseconds = 1000)
|
||||||
{
|
{
|
||||||
if(LastPageAction.HasValue && (DateTime.UtcNow - LastPageAction.Value).TotalMilliseconds < milliseconds)
|
if(LastPageAction.HasValue && (DateTime.UtcNow - LastPageAction.Value).TotalMilliseconds < milliseconds)
|
||||||
@@ -84,5 +101,19 @@ namespace Bit.App.Pages
|
|||||||
Device.BeginInvokeOnMainThread(() => input.Focus());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user