From ff9f49416a3c48fe5d504ffcb111ccf6ed26d38a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 16 Apr 2018 11:01:32 -0400 Subject: [PATCH] track with node id + hash code --- src/Android/Autofill/Field.cs | 2 ++ src/Android/Autofill/FieldCollection.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Android/Autofill/Field.cs b/src/Android/Autofill/Field.cs index 8e2bb6815..36d18de20 100644 --- a/src/Android/Autofill/Field.cs +++ b/src/Android/Autofill/Field.cs @@ -16,6 +16,7 @@ namespace Bit.Android.Autofill public Field(ViewNode node) { Id = node.Id; + TrackingId = $"{node.Id}_{node.GetHashCode()}"; IdEntry = node.IdEntry; AutofillId = node.AutofillId; AutofillType = node.AutofillType; @@ -68,6 +69,7 @@ namespace Bit.Android.Autofill } public string Hint { get; set; } public int Id { get; private set; } + public string TrackingId { get; private set; } public string IdEntry { get; set; } public AutofillId AutofillId { get; private set; } public AutofillType AutofillType { get; private set; } diff --git a/src/Android/Autofill/FieldCollection.cs b/src/Android/Autofill/FieldCollection.cs index 789699cf7..e734b4cda 100644 --- a/src/Android/Autofill/FieldCollection.cs +++ b/src/Android/Autofill/FieldCollection.cs @@ -33,6 +33,7 @@ namespace Bit.Android.Autofill } public HashSet Hints { get; private set; } = new HashSet(); public HashSet FocusedHints { get; private set; } = new HashSet(); + public HashSet FieldTrackingIds { get; private set; } = new HashSet(); public List Fields { get; private set; } = new List(); public IDictionary> HintToFieldsMap { get; private set; } = new Dictionary>(); @@ -120,13 +121,14 @@ namespace Bit.Android.Autofill public void Add(Field field) { - if(Fields.Contains(field)) + if(field == null || FieldTrackingIds.Contains(field.TrackingId)) { return; } _passwordFields = _usernameFields = null; + FieldTrackingIds.Add(field.TrackingId); Fields.Add(field); AutofillIds.Add(field.AutofillId);