1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-30 04:17:55 +02:00

Clear intent from autofill. Background app when back button on lock page.

This commit is contained in:
Kyle Spearrin 2017-02-09 18:12:34 -05:00
parent 99e78092ed
commit e970ca49e8
6 changed files with 57 additions and 61 deletions

View File

@ -31,7 +31,12 @@ namespace Bit.Android
var uri = Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory) ? null : Intent.GetStringExtra("uri");
if(Intent.HasExtra("uri"))
{
// Clear intent for future. ref: http://stackoverflow.com/a/29947867/1090359
Intent.RemoveExtra("uri");
Intent.ReplaceExtras(new Bundle());
Intent.SetAction(string.Empty);
Intent.SetData(null);
Intent.SetFlags(0);
}
if(uri != null && !Resolver.IsSet)
@ -95,6 +100,11 @@ namespace Bit.Android
{
ReturnCredentials(args);
});
MessagingCenter.Subscribe<Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "BackgroundApp", (sender) =>
{
MoveTaskToBack(true);
});
}
private void ReturnCredentials(VaultListPageModel.Login login)

View File

@ -120,6 +120,7 @@
<Compile Include="Models\Login.cs" />
<Compile Include="Models\Page\VaultViewLoginPageModel.cs" />
<Compile Include="Pages\HomePage.cs" />
<Compile Include="Pages\Lock\BaseLockPage.cs" />
<Compile Include="Pages\Lock\LockPasswordPage.cs" />
<Compile Include="Pages\LoginTwoFactorPage.cs" />
<Compile Include="Pages\PasswordHintPage.cs" />

View File

@ -0,0 +1,41 @@
using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Controls;
using Bit.App.Resources;
using Xamarin.Forms;
using XLabs.Ioc;
namespace Bit.App.Pages
{
public class BaseLockPage : ExtendedContentPage
{
public BaseLockPage()
: base(false, false)
{
UserDialogs = Resolver.Resolve<IUserDialogs>();
}
protected IUserDialogs UserDialogs { get; set; }
protected override bool OnBackButtonPressed()
{
if(Device.OS == TargetPlatform.Android)
{
MessagingCenter.Send(Application.Current, "BackgroundApp");
}
return true;
}
protected async Task LogoutAsync()
{
if(!await UserDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel))
{
return;
}
MessagingCenter.Send(Application.Current, "Logout", (string)null);
}
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Controls;
using Bit.App.Resources;
using Xamarin.Forms;
@ -10,19 +9,16 @@ using Plugin.Settings.Abstractions;
namespace Bit.App.Pages
{
public class LockFingerprintPage : ExtendedContentPage
public class LockFingerprintPage : BaseLockPage
{
private readonly IFingerprint _fingerprint;
private readonly IUserDialogs _userDialogs;
private readonly ISettings _settings;
private readonly bool _checkFingerprintImmediately;
public LockFingerprintPage(bool checkFingerprintImmediately)
: base(false, false)
{
_checkFingerprintImmediately = checkFingerprintImmediately;
_fingerprint = Resolver.Resolve<IFingerprint>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_settings = Resolver.Resolve<ISettings>();
Init();
@ -68,11 +64,6 @@ namespace Bit.App.Pages
Content = stackLayout;
}
protected override bool OnBackButtonPressed()
{
return true;
}
protected override void OnAppearing()
{
base.OnAppearing();
@ -83,16 +74,6 @@ namespace Bit.App.Pages
}
}
public async Task LogoutAsync()
{
if(!await _userDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel))
{
return;
}
MessagingCenter.Send(Application.Current, "Logout", (string)null);
}
public async Task CheckFingerprintAsync()
{
var result = await _fingerprint.AuthenticateAsync(AppResources.FingerprintDirection);

View File

@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using Acr.UserDialogs;
using Bit.App.Abstractions;
using Bit.App.Resources;
using Xamarin.Forms;
@ -11,19 +10,16 @@ using Plugin.Settings.Abstractions;
namespace Bit.App.Pages
{
public class LockPasswordPage : ExtendedContentPage
public class LockPasswordPage : BaseLockPage
{
private readonly IAuthService _authService;
private readonly ISettings _settings;
private readonly IUserDialogs _userDialogs;
private readonly ICryptoService _cryptoService;
public LockPasswordPage()
: base(false, false)
{
_authService = Resolver.Resolve<IAuthService>();
_settings = Resolver.Resolve<ISettings>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_cryptoService = Resolver.Resolve<ICryptoService>();
Init();
@ -100,11 +96,6 @@ namespace Bit.App.Pages
var task = CheckPasswordAsync();
}
protected override bool OnBackButtonPressed()
{
return true;
}
protected override void OnAppearing()
{
base.OnAppearing();
@ -130,20 +121,10 @@ namespace Bit.App.Pages
{
// TODO: keep track of invalid attempts and logout?
_userDialogs.Alert(AppResources.InvalidMasterPassword);
UserDialogs.Alert(AppResources.InvalidMasterPassword);
PasswordCell.Entry.Text = string.Empty;
PasswordCell.Entry.Focus();
}
}
private async Task LogoutAsync()
{
if(!await _userDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel))
{
return;
}
MessagingCenter.Send(Application.Current, "Logout", (string)null);
}
}
}

View File

@ -11,17 +11,14 @@ using Bit.App.Controls;
namespace Bit.App.Pages
{
public class LockPinPage : ExtendedContentPage
public class LockPinPage : BaseLockPage
{
private readonly IAuthService _authService;
private readonly IUserDialogs _userDialogs;
private readonly ISettings _settings;
public LockPinPage()
: base(false, false)
{
_authService = Resolver.Resolve<IAuthService>();
_userDialogs = Resolver.Resolve<IUserDialogs>();
_settings = Resolver.Resolve<ISettings>();
Init();
@ -79,11 +76,6 @@ namespace Bit.App.Pages
PinControl.Entry.Focus();
}
protected override bool OnBackButtonPressed()
{
return true;
}
protected override void OnAppearing()
{
base.OnAppearing();
@ -102,20 +94,10 @@ namespace Bit.App.Pages
{
// TODO: keep track of invalid attempts and logout?
_userDialogs.Alert(AppResources.InvalidPIN);
UserDialogs.Alert(AppResources.InvalidPIN);
Model.PIN = string.Empty;
PinControl.Entry.Focus();
}
}
private async Task LogoutAsync()
{
if(!await _userDialogs.ConfirmAsync(AppResources.LogoutConfirmation, null, AppResources.Yes, AppResources.Cancel))
{
return;
}
MessagingCenter.Send(Application.Current, "Logout", (string)null);
}
}
}