2019-05-17 23:36:29 +03:00
|
|
|
|
using Bit.App.Models;
|
|
|
|
|
using System;
|
2019-05-16 15:41:57 +03:00
|
|
|
|
using System.Threading.Tasks;
|
2019-05-16 00:37:59 +03:00
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Bit.App.Pages
|
|
|
|
|
{
|
|
|
|
|
public partial class LockPage : BaseContentPage
|
|
|
|
|
{
|
2019-05-17 23:36:29 +03:00
|
|
|
|
private readonly AppOptions _appOptions;
|
|
|
|
|
private readonly LockPageViewModel _vm;
|
2019-05-16 00:37:59 +03:00
|
|
|
|
|
2019-05-17 23:36:29 +03:00
|
|
|
|
public LockPage(AppOptions appOptions = null)
|
2019-05-16 00:37:59 +03:00
|
|
|
|
{
|
2019-05-17 23:36:29 +03:00
|
|
|
|
_appOptions = appOptions;
|
2019-05-16 00:37:59 +03:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
_vm = BindingContext as LockPageViewModel;
|
|
|
|
|
_vm.Page = this;
|
2019-05-17 23:36:29 +03:00
|
|
|
|
_vm.UnlockedAction = () =>
|
|
|
|
|
{
|
|
|
|
|
if(_appOptions != null)
|
|
|
|
|
{
|
|
|
|
|
if(_appOptions.FromAutofillFramework && _appOptions.SaveType.HasValue)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.MainPage = new NavigationPage(new AddEditPage(appOptions: _appOptions));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if(_appOptions.Uri != null)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.MainPage = new NavigationPage(new AutofillCiphersPage(_appOptions));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Application.Current.MainPage = new TabsPage();
|
|
|
|
|
};
|
2019-05-16 00:37:59 +03:00
|
|
|
|
MasterPasswordEntry = _masterPassword;
|
|
|
|
|
PinEntry = _pin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Entry MasterPasswordEntry { get; set; }
|
|
|
|
|
public Entry PinEntry { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override async void OnAppearing()
|
|
|
|
|
{
|
|
|
|
|
base.OnAppearing();
|
|
|
|
|
await _vm.InitAsync();
|
2019-05-17 00:31:08 +03:00
|
|
|
|
if(!_vm.FingerprintLock)
|
2019-05-16 00:37:59 +03:00
|
|
|
|
{
|
2019-05-17 00:31:08 +03:00
|
|
|
|
if(_vm.PinLock)
|
|
|
|
|
{
|
|
|
|
|
RequestFocus(PinEntry);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RequestFocus(MasterPasswordEntry);
|
|
|
|
|
}
|
2019-05-16 00:37:59 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-16 15:41:57 +03:00
|
|
|
|
private void Unlock_Clicked(object sender, EventArgs e)
|
2019-05-16 00:37:59 +03:00
|
|
|
|
{
|
|
|
|
|
if(DoOnce())
|
|
|
|
|
{
|
2019-05-16 15:41:57 +03:00
|
|
|
|
var tasks = Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(50);
|
|
|
|
|
Device.BeginInvokeOnMainThread(async () =>
|
|
|
|
|
{
|
|
|
|
|
await _vm.SubmitAsync();
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-05-16 00:37:59 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void LogOut_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(DoOnce())
|
|
|
|
|
{
|
|
|
|
|
await _vm.LogOutAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-17 16:42:20 +03:00
|
|
|
|
|
|
|
|
|
private async void Fingerprint_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(DoOnce())
|
|
|
|
|
{
|
|
|
|
|
await _vm.PromptFingerprintAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-16 00:37:59 +03:00
|
|
|
|
}
|
|
|
|
|
}
|