added hint detection to username/password fields

This commit is contained in:
Kyle Spearrin 2017-11-17 23:38:09 -05:00
parent 955fc97cb2
commit 84ea28adfa

View file

@ -3,6 +3,7 @@ using Android.Service.Autofill;
using Android.Views.Autofill; using Android.Views.Autofill;
using System.Linq; using System.Linq;
using Android.Text; using Android.Text;
using Android.Views;
namespace Bit.Android.Autofill namespace Bit.Android.Autofill
{ {
@ -32,11 +33,18 @@ namespace Bit.Android.Autofill
return _passwordFields; return _passwordFields;
} }
if(Hints.Any())
{
_passwordFields = Fields.Where(f => f.Hints.Contains(View.AutofillHintPassword)).ToList();
}
else
{
_passwordFields = Fields.Where(f => f.InputType.HasFlag(InputTypes.TextVariationPassword)).ToList(); _passwordFields = Fields.Where(f => f.InputType.HasFlag(InputTypes.TextVariationPassword)).ToList();
if(!_passwordFields.Any()) if(!_passwordFields.Any())
{ {
_passwordFields = Fields.Where(f => f.IdEntry?.ToLower().Contains("password") ?? false).ToList(); _passwordFields = Fields.Where(f => f.IdEntry?.ToLower().Contains("password") ?? false).ToList();
} }
}
return _passwordFields; return _passwordFields;
} }
@ -51,6 +59,14 @@ namespace Bit.Android.Autofill
return _usernameFields; return _usernameFields;
} }
if(Hints.Any())
{
_usernameFields = Fields
.Where(f => f.Hints.Any(fh => fh == View.AutofillHintEmailAddress || fh == View.AutofillHintUsername))
.ToList();
}
else
{
_usernameFields = new List<Field>(); _usernameFields = new List<Field>();
foreach(var passwordField in PasswordFields) foreach(var passwordField in PasswordFields)
{ {
@ -60,6 +76,8 @@ namespace Bit.Android.Autofill
_usernameFields.Add(usernameField); _usernameFields.Add(usernameField);
} }
} }
}
return _usernameFields; return _usernameFields;
} }
} }