mirror of
https://github.com/bitwarden/mobile
synced 2025-12-25 12:43:39 +00:00
autofill intent fixes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user