From 6a5d40b3efee04c0bee1061709123c1687ffe571 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 4 Jun 2016 22:35:03 -0400 Subject: [PATCH] android checklock --- src/Android/MainActivity.cs | 37 +++++++++++++++++++++++++++++++++++++ src/App/App.cs | 17 ++++++++++++----- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index e1c327b3d..b22e1e874 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -28,6 +28,7 @@ namespace Bit.Android protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); + Console.WriteLine("A OnCreate"); global::Xamarin.Forms.Forms.Init(this, bundle); @@ -43,6 +44,42 @@ namespace Bit.Android Resolver.Resolve())); } + protected override void OnPause() + { + Console.WriteLine("A OnPause"); + base.OnPause(); + } + + protected override void OnDestroy() + { + Console.WriteLine("A OnDestroy"); + base.OnDestroy(); + } + + protected override void OnRestart() + { + Console.WriteLine("A OnRestart"); + base.OnRestart(); + } + + protected override void OnStart() + { + Console.WriteLine("A OnStart"); + base.OnStart(); + } + + protected override void OnStop() + { + Console.WriteLine("A OnStop"); + base.OnStop(); + } + + protected override void OnResume() + { + Console.WriteLine("A OnResume"); + base.OnResume(); + } + private void SetIoc() { var container = new UnityContainer(); diff --git a/src/App/App.cs b/src/App/App.cs index e961f94e1..bb5850ef7 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -60,12 +60,22 @@ namespace Bit.App { // Handle when your app sleeps Debug.WriteLine("OnSleep"); + + if(Device.OS == TargetPlatform.Android) + { + _settings.AddOrUpdateValue(Constants.SettingLastBackgroundedDate, DateTime.UtcNow); + } } protected override void OnResume() { // Handle when your app resumes Debug.WriteLine("OnResume"); + + if(Device.OS == TargetPlatform.Android) + { + CheckLockAsync(false); + } } private async Task CheckLockAsync(bool forceLock) @@ -100,12 +110,9 @@ namespace Bit.App var pinUnlock = _settings.GetValueOrDefault(Constants.SettingPinUnlockOn); if(fingerprintUnlock && _fingerprint.IsAvailable) { - if(Device.OS == TargetPlatform.iOS) + if(Current.MainPage.Navigation.ModalStack.LastOrDefault() as LockFingerprintPage == null) { - if(Current.MainPage.Navigation.ModalStack.LastOrDefault() as LockFingerprintPage == null) - { - await Current.MainPage.Navigation.PushModalAsync(new LockFingerprintPage(!forceLock), false); - } + await Current.MainPage.Navigation.PushModalAsync(new LockFingerprintPage(!forceLock), false); } } else if(pinUnlock)