stop timer when page disappears. autofocus camera.

This commit is contained in:
Kyle Spearrin 2017-07-24 12:26:34 -04:00
parent dbdc660464
commit 679859fb37
3 changed files with 39 additions and 0 deletions

View file

@ -11,6 +11,7 @@ namespace Bit.App.Pages
{
private readonly ZXingScannerView _zxing;
private readonly OverlayGrid _overlay;
private bool _pageDisappeared = true;
public ScanPage(Action<string> callback)
: base(updateActivity: false)
@ -78,12 +79,24 @@ namespace Bit.App.Pages
protected override void OnAppearing()
{
_pageDisappeared = false;
base.OnAppearing();
_zxing.IsScanning = true;
Device.StartTimer(new TimeSpan(0, 0, 2), () =>
{
if(_pageDisappeared)
{
return false;
}
_zxing.AutoFocus();
return true;
});
}
protected override void OnDisappearing()
{
_pageDisappeared = true;
_zxing.IsScanning = false;
base.OnDisappearing();
}

View file

@ -12,6 +12,7 @@ namespace Bit.App.Pages
{
private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly IAppInfoService _appInfoService;
private bool _pageDisappeared = false;
public ToolsAutofillServicePage()
{
@ -170,6 +171,11 @@ namespace Bit.App.Pages
UpdateEnabled();
Device.StartTimer(new TimeSpan(0, 0, 3), () =>
{
if(_pageDisappeared)
{
return false;
}
UpdateEnabled();
return true;
});
@ -178,6 +184,18 @@ namespace Bit.App.Pages
Content = ScrollView;
}
protected override void OnAppearing()
{
_pageDisappeared = false;
base.OnAppearing();
}
protected override void OnDisappearing()
{
_pageDisappeared = true;
base.OnDisappearing();
}
private void UpdateEnabled()
{
ScrollView.Content = _appInfoService.AutofillServiceEnabled ? EnabledStackLayout : DisabledStackLayout;

View file

@ -21,6 +21,7 @@ namespace Bit.App.Pages
private readonly IUserDialogs _userDialogs;
private readonly IDeviceActionService _deviceActionService;
private readonly ITokenService _tokenService;
private bool _pageDisappeared = true;
public VaultViewLoginPage(string loginId)
{
@ -153,6 +154,7 @@ namespace Bit.App.Pages
protected async override void OnAppearing()
{
_pageDisappeared = false;
NotesCell.Tapped += NotesCell_Tapped;
EditItem.InitEvents();
@ -217,6 +219,11 @@ namespace Bit.App.Pages
TotpTick(totpKey);
Device.StartTimer(new TimeSpan(0, 0, 1), () =>
{
if(_pageDisappeared)
{
return false;
}
TotpTick(totpKey);
return true;
});
@ -253,6 +260,7 @@ namespace Bit.App.Pages
protected override void OnDisappearing()
{
_pageDisappeared = true;
NotesCell.Tapped -= NotesCell_Tapped;
EditItem.Dispose();
CleanupAttachmentCells();