mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
only show autofills if a fillable login form
This commit is contained in:
parent
abf75cffd9
commit
da199deed1
3 changed files with 26 additions and 17 deletions
|
@ -33,7 +33,7 @@ namespace Bit.Android.Autofill
|
|||
var parser = new Parser(structure);
|
||||
parser.Parse();
|
||||
|
||||
if(!parser.FieldCollection.Fields.Any() || string.IsNullOrWhiteSpace(parser.Uri) ||
|
||||
if(!parser.FieldCollection.FillableForLogin || string.IsNullOrWhiteSpace(parser.Uri) ||
|
||||
parser.Uri == "androidapp://com.x8bit.bitwarden" || parser.Uri == "androidapp://android")
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -61,14 +61,7 @@ namespace Bit.Android.Autofill
|
|||
|
||||
if(Type == CipherType.Login)
|
||||
{
|
||||
var passwordField = fieldCollection.Fields.FirstOrDefault(
|
||||
f => f.InputType.HasFlag(InputTypes.TextVariationPassword));
|
||||
if(passwordField == null)
|
||||
{
|
||||
passwordField = fieldCollection.Fields.FirstOrDefault(
|
||||
f => f.IdEntry?.ToLower().Contains("password") ?? false);
|
||||
}
|
||||
|
||||
var passwordField = fieldCollection.PasswordFields.FirstOrDefault();
|
||||
if(passwordField == null)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace Bit.Android.Autofill
|
|||
{
|
||||
public class FieldCollection
|
||||
{
|
||||
private List<Field> _passwordFields;
|
||||
|
||||
public HashSet<int> Ids { get; private set; } = new HashSet<int>();
|
||||
public List<AutofillId> AutofillIds { get; private set; } = new List<AutofillId>();
|
||||
public SaveDataType SaveType { get; private set; } = SaveDataType.Generic;
|
||||
|
@ -19,6 +21,27 @@ namespace Bit.Android.Autofill
|
|||
public IDictionary<string, List<Field>> HintToFieldsMap { get; private set; } =
|
||||
new Dictionary<string, List<Field>>();
|
||||
|
||||
public List<Field> PasswordFields
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_passwordFields != null)
|
||||
{
|
||||
return _passwordFields;
|
||||
}
|
||||
|
||||
_passwordFields = Fields.Where(f => f.InputType.HasFlag(InputTypes.TextVariationPassword)).ToList();
|
||||
if(!_passwordFields.Any())
|
||||
{
|
||||
_passwordFields = Fields.Where(f => f.IdEntry?.ToLower().Contains("password") ?? false).ToList();
|
||||
}
|
||||
|
||||
return _passwordFields;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FillableForLogin => PasswordFields.Any();
|
||||
|
||||
public void Add(Field field)
|
||||
{
|
||||
if(Ids.Contains(field.Id))
|
||||
|
@ -59,14 +82,7 @@ namespace Bit.Android.Autofill
|
|||
return null;
|
||||
}
|
||||
|
||||
var passwordField = Fields.FirstOrDefault(
|
||||
f => f.InputType.HasFlag(InputTypes.TextVariationPassword) && !string.IsNullOrWhiteSpace(f.TextValue));
|
||||
if(passwordField == null)
|
||||
{
|
||||
passwordField = Fields.FirstOrDefault(
|
||||
f => (f.IdEntry?.ToLower().Contains("password") ?? false) && !string.IsNullOrWhiteSpace(f.TextValue));
|
||||
}
|
||||
|
||||
var passwordField = PasswordFields.FirstOrDefault(f => !string.IsNullOrWhiteSpace(f.TextValue));
|
||||
if(passwordField == null)
|
||||
{
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue