track with node id + hash code

This commit is contained in:
Kyle Spearrin 2018-04-16 11:01:32 -04:00
parent 93cae0e9cc
commit ff9f49416a
2 changed files with 5 additions and 1 deletions

View file

@ -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; }

View file

@ -33,6 +33,7 @@ namespace Bit.Android.Autofill
}
public HashSet<string> Hints { get; private set; } = new HashSet<string>();
public HashSet<string> FocusedHints { get; private set; } = new HashSet<string>();
public HashSet<string> FieldTrackingIds { get; private set; } = new HashSet<string>();
public List<Field> Fields { get; private set; } = new List<Field>();
public IDictionary<string, List<Field>> HintToFieldsMap { get; private set; } =
new Dictionary<string, List<Field>>();
@ -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);