From 079fb341207cfb388b3a67e4c89c748e7a524286 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 18 Feb 2017 10:50:27 -0500 Subject: [PATCH] pass nodes as reference --- src/Android/AutofillService.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index 5e10cc9c5..4dfcfc0d2 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -78,7 +78,7 @@ namespace Bit.Android } var passwordNodes = GetWindowNodes(root, e, n => n.Password); - if(passwordNodes.Any()) + if(passwordNodes.Count > 0) { var uri = GetUri(root); if(uri != null && !uri.Contains(BitwardenWebsite)) @@ -238,24 +238,28 @@ namespace Bit.Android editTextNode.PerformAction(global::Android.Views.Accessibility.Action.SetText, bundle); } - private IEnumerable GetWindowNodes(AccessibilityNodeInfo n, - AccessibilityEvent e, Func condition) + private List GetWindowNodes(AccessibilityNodeInfo n, + AccessibilityEvent e, Func condition, List nodes = null) { + if(nodes == null) + { + nodes = new List(); + } + if(n != null) { 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++) { - foreach(var node in GetWindowNodes(n.GetChild(i), e, condition)) - { - yield return node; - } + nodes.AddRange(GetWindowNodes(n.GetChild(i), e, condition, nodes)); } } + + return nodes; } public class Browser