android checklock

This commit is contained in:
Kyle Spearrin 2016-06-04 22:35:03 -04:00
parent 1c4de107b9
commit 6a5d40b3ef
2 changed files with 49 additions and 5 deletions

View file

@ -28,6 +28,7 @@ namespace Bit.Android
protected override void OnCreate(Bundle bundle) protected override void OnCreate(Bundle bundle)
{ {
base.OnCreate(bundle); base.OnCreate(bundle);
Console.WriteLine("A OnCreate");
global::Xamarin.Forms.Forms.Init(this, bundle); global::Xamarin.Forms.Forms.Init(this, bundle);
@ -43,6 +44,42 @@ namespace Bit.Android
Resolver.Resolve<ISettings>())); Resolver.Resolve<ISettings>()));
} }
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() private void SetIoc()
{ {
var container = new UnityContainer(); var container = new UnityContainer();

View file

@ -60,12 +60,22 @@ namespace Bit.App
{ {
// Handle when your app sleeps // Handle when your app sleeps
Debug.WriteLine("OnSleep"); Debug.WriteLine("OnSleep");
if(Device.OS == TargetPlatform.Android)
{
_settings.AddOrUpdateValue(Constants.SettingLastBackgroundedDate, DateTime.UtcNow);
}
} }
protected override void OnResume() protected override void OnResume()
{ {
// Handle when your app resumes // Handle when your app resumes
Debug.WriteLine("OnResume"); Debug.WriteLine("OnResume");
if(Device.OS == TargetPlatform.Android)
{
CheckLockAsync(false);
}
} }
private async Task CheckLockAsync(bool forceLock) private async Task CheckLockAsync(bool forceLock)
@ -100,12 +110,9 @@ namespace Bit.App
var pinUnlock = _settings.GetValueOrDefault<bool>(Constants.SettingPinUnlockOn); var pinUnlock = _settings.GetValueOrDefault<bool>(Constants.SettingPinUnlockOn);
if(fingerprintUnlock && _fingerprint.IsAvailable) 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) else if(pinUnlock)