mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-29 12:45:20 +01:00
Enhancement to login field detection for Android autofill (#2561)
This commit is contained in:
parent
04e30c2146
commit
1332ef7b43
@ -12,7 +12,7 @@ namespace Bit.Droid.Autofill
|
|||||||
private List<Field> _passwordFields = null;
|
private List<Field> _passwordFields = null;
|
||||||
private List<Field> _usernameFields = null;
|
private List<Field> _usernameFields = null;
|
||||||
private HashSet<string> _ignoreSearchTerms = new HashSet<string> { "search", "find", "recipient", "edit" };
|
private HashSet<string> _ignoreSearchTerms = new HashSet<string> { "search", "find", "recipient", "edit" };
|
||||||
private HashSet<string> _usernameTerms = new HashSet<string> { "email", "phone", "username"};
|
private HashSet<string> _usernameTerms = new HashSet<string> { "email", "phone", "username" };
|
||||||
private HashSet<string> _passwordTerms = new HashSet<string> { "password", "pswd" };
|
private HashSet<string> _passwordTerms = new HashSet<string> { "password", "pswd" };
|
||||||
|
|
||||||
public List<AutofillId> AutofillIds { get; private set; } = new List<AutofillId>();
|
public List<AutofillId> AutofillIds { get; private set; } = new List<AutofillId>();
|
||||||
@ -54,16 +54,15 @@ namespace Bit.Droid.Autofill
|
|||||||
if (HintToFieldsMap.ContainsKey(View.AutofillHintPassword))
|
if (HintToFieldsMap.ContainsKey(View.AutofillHintPassword))
|
||||||
{
|
{
|
||||||
_passwordFields.AddRange(HintToFieldsMap[View.AutofillHintPassword]);
|
_passwordFields.AddRange(HintToFieldsMap[View.AutofillHintPassword]);
|
||||||
|
return _passwordFields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_passwordFields = Fields.Where(f => FieldIsPassword(f)).ToList();
|
_passwordFields = Fields.Where(f => FieldIsPassword(f)).ToList();
|
||||||
if (!_passwordFields.Any())
|
if (!_passwordFields.Any())
|
||||||
{
|
{
|
||||||
_passwordFields = Fields.Where(f => FieldHasPasswordTerms(f)).ToList();
|
_passwordFields = Fields.Where(f => FieldHasPasswordTerms(f)).ToList();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return _passwordFields;
|
return _passwordFields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,9 +86,12 @@ namespace Bit.Droid.Autofill
|
|||||||
{
|
{
|
||||||
_usernameFields.AddRange(HintToFieldsMap[View.AutofillHintUsername]);
|
_usernameFields.AddRange(HintToFieldsMap[View.AutofillHintUsername]);
|
||||||
}
|
}
|
||||||
}
|
if (_usernameFields.Any())
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
return _usernameFields;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var passwordField in PasswordFields)
|
foreach (var passwordField in PasswordFields)
|
||||||
{
|
{
|
||||||
var usernameField = Fields.TakeWhile(f => f.AutofillId != passwordField.AutofillId)
|
var usernameField = Fields.TakeWhile(f => f.AutofillId != passwordField.AutofillId)
|
||||||
@ -104,7 +106,6 @@ namespace Bit.Droid.Autofill
|
|||||||
{
|
{
|
||||||
_usernameFields = Fields.Where(f => FieldIsUsername(f)).ToList();
|
_usernameFields = Fields.Where(f => FieldIsUsername(f)).ToList();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return _usernameFields;
|
return _usernameFields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user