diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs
index fc3c308f6..50b94c23a 100644
--- a/src/Android/AutofillService.cs
+++ b/src/Android/AutofillService.cs
@@ -123,6 +123,18 @@ namespace Bit.Android
{
uri = string.Concat("http://", uri);
}
+ else if(Build.VERSION.SdkInt <= BuildVersionCodes.KitkatWatch)
+ {
+ var parts = uri.Split(new string[] { ". " }, StringSplitOptions.None);
+ if(parts.Length > 1)
+ {
+ var urlPart = parts.FirstOrDefault(p => p.StartsWith("http"));
+ if(urlPart != null)
+ {
+ uri = urlPart.Trim();
+ }
+ }
+ }
}
return uri;
diff --git a/src/Android/Resources/xml/accessibilityservice.xml b/src/Android/Resources/xml/accessibilityservice.xml
index a8a416552..1c834d21e 100644
--- a/src/Android/Resources/xml/accessibilityservice.xml
+++ b/src/Android/Resources/xml/accessibilityservice.xml
@@ -1,7 +1,7 @@
\ No newline at end of file
diff --git a/src/App/App.cs b/src/App/App.cs
index d5c469388..0d7cf2a99 100644
--- a/src/App/App.cs
+++ b/src/App/App.cs
@@ -14,6 +14,7 @@ using Acr.UserDialogs;
using XLabs.Ioc;
using System.Reflection;
using Bit.App.Resources;
+using System.Threading;
namespace Bit.App
{
@@ -30,6 +31,7 @@ namespace Bit.App
private readonly ILockService _lockService;
private readonly IGoogleAnalyticsService _googleAnalyticsService;
private readonly ILocalizeService _localizeService;
+ private CancellationTokenSource _setMainPageCancellationTokenSource = null;
public static bool FromAutofillService { get; set; } = false;
@@ -91,9 +93,9 @@ namespace Bit.App
Device.BeginInvokeOnMainThread(() => Logout(args));
});
- MessagingCenter.Subscribe(Current, "SetMainPage", async (sender) =>
+ MessagingCenter.Subscribe(Current, "SetMainPage", (sender) =>
{
- await SetMainPageFromAutofill();
+ _setMainPageCancellationTokenSource = SetMainPageFromAutofill(_setMainPageCancellationTokenSource);
});
}
@@ -112,7 +114,7 @@ namespace Bit.App
// Handle when your app sleeps
Debug.WriteLine("OnSleep");
- await SetMainPageFromAutofill(true);
+ _setMainPageCancellationTokenSource = SetMainPageFromAutofill(_setMainPageCancellationTokenSource);
if(Device.OS == TargetPlatform.Android && !TopPageIsLock())
{
_settings.AddOrUpdateValue(Constants.LastActivityDate, DateTime.UtcNow);
@@ -142,27 +144,38 @@ namespace Bit.App
}
}
- private async Task SetMainPageFromAutofill(bool skipAlreadyOnCheck = false)
+ private CancellationTokenSource SetMainPageFromAutofill(CancellationTokenSource previousCts)
{
if(Device.OS != TargetPlatform.Android)
{
- return;
+ return null;
}
- var alreadyOnMainPage = MainPage as MainPage;
- if(!skipAlreadyOnCheck && alreadyOnMainPage != null)
+ previousCts?.Cancel();
+ if(!FromAutofillService || string.IsNullOrWhiteSpace(_uri))
{
- return;
+ return null;
}
- if(FromAutofillService || !string.IsNullOrWhiteSpace(_uri))
+ var cts = new CancellationTokenSource();
+ Task.Run(async () =>
{
- // delay some so that we dont see the screen change as autofill closes
await Task.Delay(1000);
- MainPage = new MainPage();
+ if(cts.Token.IsCancellationRequested)
+ {
+ return;
+ }
+
+ Device.BeginInvokeOnMainThread(() =>
+ {
+ MainPage = new MainPage();
+ });
+
_uri = null;
FromAutofillService = false;
- }
+ }, cts.Token);
+
+ return cts;
}
private async Task IncrementalSyncAsync()
diff --git a/src/App/Pages/Vault/VaultAutofillListLoginsPage.cs b/src/App/Pages/Vault/VaultAutofillListLoginsPage.cs
index d22b65e41..23e656f21 100644
--- a/src/App/Pages/Vault/VaultAutofillListLoginsPage.cs
+++ b/src/App/Pages/Vault/VaultAutofillListLoginsPage.cs
@@ -31,7 +31,7 @@ namespace Bit.App.Pages
{
_uri = uriString;
Uri uri;
- if(!Uri.TryCreate(uriString, UriKind.RelativeOrAbsolute, out uri) ||
+ if(!Uri.TryCreate(uriString, UriKind.Absolute, out uri) ||
!DomainName.TryParse(uri.Host, out _domainName))
{
if(uriString != null && uriString.StartsWith(Constants.AndroidAppProtocol))