added back FromAutofillService functionality

This commit is contained in:
Kyle Spearrin 2017-02-03 23:21:40 -05:00
parent 31b2eeb293
commit 46bb8d2cb5
3 changed files with 19 additions and 3 deletions

View file

@ -52,6 +52,8 @@ namespace Bit.Android
public override void OnAccessibilityEvent(AccessibilityEvent e) public override void OnAccessibilityEvent(AccessibilityEvent e)
{ {
Enabled = true;
var eventType = e.EventType; var eventType = e.EventType;
var packageName = e.PackageName; var packageName = e.PackageName;

View file

@ -98,6 +98,7 @@ namespace Bit.Android
private void ReturnCredentials(VaultListPageModel.Login login) private void ReturnCredentials(VaultListPageModel.Login login)
{ {
App.App.FromAutofillService = true;
Intent data = new Intent(); Intent data = new Intent();
if(login == null) if(login == null)
{ {
@ -154,8 +155,12 @@ namespace Bit.Android
protected override void OnResume() protected override void OnResume()
{ {
Console.WriteLine("A OnResume");
base.OnResume(); base.OnResume();
Console.WriteLine("A OnResume");
// workaround for app compat bug
// ref https://bugzilla.xamarin.com/show_bug.cgi?id=36907
Task.Delay(10).Wait();
} }
public void RateApp() public void RateApp()

View file

@ -33,6 +33,8 @@ namespace Bit.App
private readonly ILocalizeService _localizeService; private readonly ILocalizeService _localizeService;
private CancellationTokenSource _setMainPageCancellationTokenSource = null; private CancellationTokenSource _setMainPageCancellationTokenSource = null;
public static bool FromAutofillService { get; set; } = false;
public App( public App(
string uri, string uri,
IAuthService authService, IAuthService authService,
@ -61,6 +63,7 @@ namespace Bit.App
SetCulture(); SetCulture();
SetStyles(); SetStyles();
FromAutofillService = !string.IsNullOrWhiteSpace(_uri);
if(authService.IsAuthenticated && _uri != null) if(authService.IsAuthenticated && _uri != null)
{ {
MainPage = new ExtendedNavigationPage(new VaultAutofillListLoginsPage(_uri)); MainPage = new ExtendedNavigationPage(new VaultAutofillListLoginsPage(_uri));
@ -111,11 +114,12 @@ namespace Bit.App
Debug.WriteLine("OnStart"); Debug.WriteLine("OnStart");
} }
protected async override void OnSleep() protected override void OnSleep()
{ {
// Handle when your app sleeps // Handle when your app sleeps
Debug.WriteLine("OnSleep"); Debug.WriteLine("OnSleep");
_setMainPageCancellationTokenSource = SetMainPageFromAutofill(_setMainPageCancellationTokenSource, 500);
if(Device.OS == TargetPlatform.Android && !TopPageIsLock()) if(Device.OS == TargetPlatform.Android && !TopPageIsLock())
{ {
_settings.AddOrUpdateValue(Constants.LastActivityDate, DateTime.UtcNow); _settings.AddOrUpdateValue(Constants.LastActivityDate, DateTime.UtcNow);
@ -153,6 +157,10 @@ namespace Bit.App
} }
previousCts?.Cancel(); previousCts?.Cancel();
if(!FromAutofillService || string.IsNullOrWhiteSpace(_uri))
{
return null;
}
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
Task.Run(async () => Task.Run(async () =>
@ -169,6 +177,7 @@ namespace Bit.App
}); });
_uri = null; _uri = null;
FromAutofillService = false;
}, cts.Token); }, cts.Token);
return cts; return cts;