From 6cec61dc420fdad05fefbb64072aa11bd1c1d205 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 24 Aug 2016 00:15:13 -0400 Subject: [PATCH] Do not record LastActivityDate on sleep if currently viewing a lock page on android --- src/App/App.cs | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/App/App.cs b/src/App/App.cs index 941119c58..abbc8211f 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -94,7 +94,7 @@ namespace Bit.App // Handle when your app sleeps Debug.WriteLine("OnSleep"); - if(Device.OS == TargetPlatform.Android) + if(Device.OS == TargetPlatform.Android && !TopPageIsLock()) { _settings.AddOrUpdateValue(Constants.LastActivityDate, DateTime.UtcNow); } @@ -214,15 +214,18 @@ namespace Bit.App private async Task CheckLockAsync(bool forceLock) { + if(TopPageIsLock()) + { + // already locked + return; + } + var lockType = _lockService.GetLockType(forceLock); var currentPage = Current.MainPage.Navigation.ModalStack.LastOrDefault() as ExtendedNavigationPage; switch(lockType) { case Enums.LockType.Fingerprint: - if((currentPage?.CurrentPage as LockFingerprintPage) == null) - { - await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockFingerprintPage(!forceLock)), false); - } + await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockFingerprintPage(!forceLock)), false); break; case Enums.LockType.PIN: var lockPinPage = (currentPage?.CurrentPage as LockPinPage); @@ -234,16 +237,32 @@ namespace Bit.App } break; case Enums.LockType.Password: - if((currentPage?.CurrentPage as LockPasswordPage) == null) - { - await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockPasswordPage()), false); - } + await Current.MainPage.Navigation.PushModalAsync(new ExtendedNavigationPage(new LockPasswordPage()), false); break; default: break; } } + private bool TopPageIsLock() + { + var currentPage = Current.MainPage.Navigation.ModalStack.LastOrDefault() as ExtendedNavigationPage; + if((currentPage?.CurrentPage as LockFingerprintPage) != null) + { + return true; + } + if((currentPage?.CurrentPage as LockPinPage) != null) + { + return true; + } + if((currentPage?.CurrentPage as LockPasswordPage) != null) + { + return true; + } + + return false; + } + private void SetStyles() { var gray = Color.FromHex("333333");