mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 18:38:27 +03:00
add timeout on timers
This commit is contained in:
parent
dfd39ebc95
commit
dd334858ff
4 changed files with 20 additions and 16 deletions
|
@ -11,7 +11,8 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
private readonly ZXingScannerView _zxing;
|
private readonly ZXingScannerView _zxing;
|
||||||
private readonly OverlayGrid _overlay;
|
private readonly OverlayGrid _overlay;
|
||||||
private bool _pageDisappeared = true;
|
private DateTime? _timerStarted = null;
|
||||||
|
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(3);
|
||||||
|
|
||||||
public ScanPage(Action<string> callback)
|
public ScanPage(Action<string> callback)
|
||||||
: base(updateActivity: false, requireAuth: false)
|
: base(updateActivity: false, requireAuth: false)
|
||||||
|
@ -79,12 +80,12 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = false;
|
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
_zxing.IsScanning = true;
|
_zxing.IsScanning = true;
|
||||||
|
_timerStarted = DateTime.Now;
|
||||||
Device.StartTimer(new TimeSpan(0, 0, 2), () =>
|
Device.StartTimer(new TimeSpan(0, 0, 2), () =>
|
||||||
{
|
{
|
||||||
if(_pageDisappeared)
|
if(_timerStarted == null || (DateTime.Now - _timerStarted) > _timerMaxLength)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = true;
|
_timerStarted = null;
|
||||||
_zxing.IsScanning = false;
|
_zxing.IsScanning = false;
|
||||||
base.OnDisappearing();
|
base.OnDisappearing();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ namespace Bit.App.Pages
|
||||||
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
||||||
private readonly IAppInfoService _appInfoService;
|
private readonly IAppInfoService _appInfoService;
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
private bool _pageDisappeared = false;
|
private DateTime? _timerStarted = null;
|
||||||
|
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(5);
|
||||||
|
|
||||||
public ToolsAccessibilityServicePage()
|
public ToolsAccessibilityServicePage()
|
||||||
{
|
{
|
||||||
|
@ -175,12 +176,12 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = false;
|
|
||||||
UpdateEnabled();
|
UpdateEnabled();
|
||||||
|
_timerStarted = DateTime.Now;
|
||||||
Device.StartTimer(new TimeSpan(0, 0, 3), () =>
|
Device.StartTimer(new TimeSpan(0, 0, 3), () =>
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("Check timer on accessibility");
|
System.Diagnostics.Debug.WriteLine("Check timer on accessibility");
|
||||||
if(_pageDisappeared)
|
if(_timerStarted == null || (DateTime.Now - _timerStarted) > _timerMaxLength)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +195,7 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = true;
|
_timerStarted = null;
|
||||||
base.OnDisappearing();
|
base.OnDisappearing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@ namespace Bit.App.Pages
|
||||||
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
private readonly IGoogleAnalyticsService _googleAnalyticsService;
|
||||||
private readonly IAppInfoService _appInfoService;
|
private readonly IAppInfoService _appInfoService;
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
private bool _pageDisappeared = false;
|
private DateTime? _timerStarted = null;
|
||||||
|
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(5);
|
||||||
|
|
||||||
public ToolsAutofillServicePage()
|
public ToolsAutofillServicePage()
|
||||||
{
|
{
|
||||||
|
@ -126,12 +127,12 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnAppearing()
|
protected override void OnAppearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = false;
|
|
||||||
UpdateEnabled();
|
UpdateEnabled();
|
||||||
|
_timerStarted = DateTime.Now;
|
||||||
Device.StartTimer(new TimeSpan(0, 0, 2), () =>
|
Device.StartTimer(new TimeSpan(0, 0, 2), () =>
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("Check timer on autofill");
|
System.Diagnostics.Debug.WriteLine("Check timer on autofill");
|
||||||
if(_pageDisappeared)
|
if(_timerStarted == null || (DateTime.Now - _timerStarted) > _timerMaxLength)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +146,7 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = true;
|
_timerStarted = null;
|
||||||
base.OnDisappearing();
|
base.OnDisappearing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ namespace Bit.App.Pages
|
||||||
private readonly ICipherService _cipherService;
|
private readonly ICipherService _cipherService;
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
private readonly ITokenService _tokenService;
|
private readonly ITokenService _tokenService;
|
||||||
private bool _pageDisappeared = true;
|
private DateTime? _timerStarted = null;
|
||||||
|
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(5);
|
||||||
|
|
||||||
public VaultViewCipherPage(CipherType type, string cipherId)
|
public VaultViewCipherPage(CipherType type, string cipherId)
|
||||||
{
|
{
|
||||||
|
@ -273,7 +274,6 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected async override void OnAppearing()
|
protected async override void OnAppearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = false;
|
|
||||||
NotesCell.Tapped += NotesCell_Tapped;
|
NotesCell.Tapped += NotesCell_Tapped;
|
||||||
EditItem?.InitEvents();
|
EditItem?.InitEvents();
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
{
|
{
|
||||||
_pageDisappeared = true;
|
_timerStarted = null;
|
||||||
NotesCell.Tapped -= NotesCell_Tapped;
|
NotesCell.Tapped -= NotesCell_Tapped;
|
||||||
EditItem?.Dispose();
|
EditItem?.Dispose();
|
||||||
CleanupAttachmentCells();
|
CleanupAttachmentCells();
|
||||||
|
@ -382,9 +382,10 @@ namespace Bit.App.Pages
|
||||||
if(!string.IsNullOrWhiteSpace(Model.LoginTotpCode))
|
if(!string.IsNullOrWhiteSpace(Model.LoginTotpCode))
|
||||||
{
|
{
|
||||||
TotpTick(totpKey);
|
TotpTick(totpKey);
|
||||||
|
_timerStarted = DateTime.Now;
|
||||||
Device.StartTimer(new TimeSpan(0, 0, 1), () =>
|
Device.StartTimer(new TimeSpan(0, 0, 1), () =>
|
||||||
{
|
{
|
||||||
if(_pageDisappeared)
|
if(_timerStarted == null || (DateTime.Now - _timerStarted) > _timerMaxLength)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue