1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-07 09:20:04 +01:00

pass nodes as reference

This commit is contained in:
Kyle Spearrin 2017-02-18 10:50:27 -05:00
parent 17ed1cdc00
commit 079fb34120

View File

@ -78,7 +78,7 @@ namespace Bit.Android
} }
var passwordNodes = GetWindowNodes(root, e, n => n.Password); var passwordNodes = GetWindowNodes(root, e, n => n.Password);
if(passwordNodes.Any()) if(passwordNodes.Count > 0)
{ {
var uri = GetUri(root); var uri = GetUri(root);
if(uri != null && !uri.Contains(BitwardenWebsite)) if(uri != null && !uri.Contains(BitwardenWebsite))
@ -238,24 +238,28 @@ namespace Bit.Android
editTextNode.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle); editTextNode.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle);
} }
private IEnumerable<AccessibilityNodeInfo> GetWindowNodes(AccessibilityNodeInfo n, private List<AccessibilityNodeInfo> GetWindowNodes(AccessibilityNodeInfo n,
AccessibilityEvent e, Func<AccessibilityNodeInfo, bool> condition) AccessibilityEvent e, Func<AccessibilityNodeInfo, bool> condition, List<AccessibilityNodeInfo> nodes = null)
{ {
if(nodes == null)
{
nodes = new List<AccessibilityNodeInfo>();
}
if(n != null) if(n != null)
{ {
if(n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && condition(n)) if(n.WindowId == e.WindowId && !(n.ViewIdResourceName?.StartsWith(SystemUiPackage) ?? false) && condition(n))
{ {
yield return n; nodes.Add(n);
} }
for(int i = 0; i < n.ChildCount; i++) for(int i = 0; i < n.ChildCount; i++)
{ {
foreach(var node in GetWindowNodes(n.GetChild(i), e, condition)) nodes.AddRange(GetWindowNodes(n.GetChild(i), e, condition, nodes));
{
yield return node;
}
} }
} }
return nodes;
} }
public class Browser public class Browser