diff --git a/src/Android/Autofill/Field.cs b/src/Android/Autofill/Field.cs index 8e2bb68151..36d18de20c 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 789699cf70..e734b4cda3 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);