mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-26 12:16:07 +01:00
autofill intent fixes
This commit is contained in:
parent
5bce95a686
commit
be9db2930f
@ -94,8 +94,10 @@ namespace Bit.Android
|
||||
}
|
||||
|
||||
var intent = new Intent(this, typeof(MainActivity));
|
||||
intent.PutExtra("uri", _lastQueriedUri);
|
||||
intent.PutExtra("ts", Java.Lang.JavaSystem.CurrentTimeMillis());
|
||||
if(!callingIntent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory))
|
||||
{
|
||||
intent.PutExtra("uri", _lastQueriedUri);
|
||||
}
|
||||
StartActivityForResult(intent, requestCode);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace Bit.Android
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch(e.EventType)
|
||||
{
|
||||
case EventTypes.WindowContentChanged:
|
||||
@ -77,13 +77,8 @@ namespace Bit.Android
|
||||
if(passwordNodes.Any())
|
||||
{
|
||||
var uri = GetUri(root);
|
||||
if(uri != null)
|
||||
if(uri != null && !uri.Contains(BitwardenWebsite))
|
||||
{
|
||||
if(uri.Contains(BitwardenWebsite))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(NeedToAutofill(AutofillActivity.LastCredentials, uri))
|
||||
{
|
||||
var allEditTexts = GetWindowNodes(root, e, n => EditText(n));
|
||||
@ -252,18 +247,18 @@ namespace Bit.Android
|
||||
}
|
||||
|
||||
private IEnumerable<AccessibilityNodeInfo> GetWindowNodes(AccessibilityNodeInfo n,
|
||||
AccessibilityEvent e, Func<AccessibilityNodeInfo, bool> p)
|
||||
AccessibilityEvent e, Func<AccessibilityNodeInfo, bool> condition)
|
||||
{
|
||||
if(n != null)
|
||||
{
|
||||
if(n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && p(n))
|
||||
if(n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && condition(n))
|
||||
{
|
||||
yield return n;
|
||||
}
|
||||
|
||||
for(int i = 0; i < n.ChildCount; i++)
|
||||
{
|
||||
foreach(var node in GetWindowNodes(n.GetChild(i), e, p))
|
||||
foreach(var node in GetWindowNodes(n.GetChild(i), e, condition))
|
||||
{
|
||||
yield return node;
|
||||
}
|
||||
|
@ -28,22 +28,7 @@ namespace Bit.Android
|
||||
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
string uri = null;
|
||||
if(!Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory) && Intent.HasExtra("uri") && Intent.HasExtra("ts"))
|
||||
{
|
||||
var tsDiff = Java.Lang.JavaSystem.CurrentTimeMillis() - Intent.GetLongExtra("ts", 0);
|
||||
if(tsDiff < 5000)
|
||||
{
|
||||
uri = Intent.GetStringExtra("uri");
|
||||
}
|
||||
|
||||
// Attempt to clear intent for future
|
||||
Intent.ReplaceExtras(new Bundle());
|
||||
Intent.SetAction(string.Empty);
|
||||
Intent.SetData(null);
|
||||
Intent.SetFlags(0);
|
||||
}
|
||||
|
||||
var uri = Intent.GetStringExtra("uri");
|
||||
if(!Resolver.IsSet)
|
||||
{
|
||||
MainApplication.SetIoc(Application);
|
||||
@ -134,8 +119,7 @@ namespace Bit.Android
|
||||
{
|
||||
Parent.SetResult(Result.Ok, data);
|
||||
}
|
||||
|
||||
MessagingCenter.Send(Xamarin.Forms.Application.Current, "SetMainPage");
|
||||
|
||||
Finish();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ namespace Bit.App
|
||||
private const string LastBuildKey = "LastBuild";
|
||||
|
||||
private string _uri;
|
||||
private DateTime _lastMainPageSet = DateTime.MinValue;
|
||||
private readonly IDatabaseService _databaseService;
|
||||
private readonly IConnectivity _connectivity;
|
||||
private readonly IUserDialogs _userDialogs;
|
||||
@ -93,11 +92,6 @@ namespace Bit.App
|
||||
{
|
||||
Logout(args);
|
||||
});
|
||||
|
||||
MessagingCenter.Subscribe<Application>(Current, "SetMainPage", (sender) =>
|
||||
{
|
||||
SetMainPageFromAutofill();
|
||||
});
|
||||
}
|
||||
|
||||
protected async override void OnStart()
|
||||
@ -165,15 +159,14 @@ namespace Bit.App
|
||||
{
|
||||
if(Device.OS == TargetPlatform.Android && !string.IsNullOrWhiteSpace(_uri))
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if((now - _lastMainPageSet).Seconds <= 1)
|
||||
Task.Run(() =>
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_lastMainPageSet = now;
|
||||
Device.BeginInvokeOnMainThread(() => MainPage = new MainPage());
|
||||
_uri = null;
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
Current.MainPage = new MainPage();
|
||||
_uri = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user