From 6215a7d65e389805c2a7654ebeb346c5ae48897f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 25 May 2017 23:16:48 -0400 Subject: [PATCH] on demand password node scans for autofill --- src/Android/AutofillService.cs | 32 +++++++++++++++++++ .../Services/GoogleAnalyticsService.cs | 1 - 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Android/AutofillService.cs b/src/Android/AutofillService.cs index 96d942792..4c3e5d4b7 100644 --- a/src/Android/AutofillService.cs +++ b/src/Android/AutofillService.cs @@ -82,6 +82,36 @@ namespace Bit.Android break; } + var uri = GetUri(root); + if(uri != null && !uri.Contains(BitwardenWebsite)) + { + var needToFill = NeedToAutofill(AutofillActivity.LastCredentials, uri); + if(needToFill) + { + var passwordNodes = GetWindowNodes(root, e, n => n.Password, false); + needToFill = passwordNodes.Any(); + if(needToFill) + { + var allEditTexts = GetWindowNodes(root, e, n => EditText(n), false); + var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault(); + FillCredentials(usernameEditText, passwordNodes); + + allEditTexts.Dispose(); + usernameEditText.Dispose(); + passwordNodes.Dispose(); + } + } + + if(!needToFill) + { + NotifyToAutofill(uri, notificationManager); + cancelNotification = false; + } + } + + AutofillActivity.LastCredentials = null; + + /* var passwordNodes = GetWindowNodes(root, e, n => n.Password, false); if(passwordNodes.Count > 0) { @@ -108,6 +138,8 @@ namespace Bit.Android } passwordNodes.Dispose(); + */ + if(cancelNotification) { diff --git a/src/Android/Services/GoogleAnalyticsService.cs b/src/Android/Services/GoogleAnalyticsService.cs index 06fd6bb84..da03cb5eb 100644 --- a/src/Android/Services/GoogleAnalyticsService.cs +++ b/src/Android/Services/GoogleAnalyticsService.cs @@ -12,7 +12,6 @@ namespace Bit.Android.Services private readonly GoogleAnalytics _instance; private readonly IAuthService _authService; private readonly Tracker _tracker; - private bool _setUserId = true; public GoogleAnalyticsService( Context appContext,