1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-15 07:43:37 +00:00

better detection for username/passwords

This commit is contained in:
Kyle Spearrin
2017-11-17 22:47:08 -05:00
parent da199deed1
commit 2c662c428c
3 changed files with 59 additions and 18 deletions

View File

@@ -8,6 +8,7 @@ namespace Bit.Android.Autofill
{
private readonly AssistStructure _structure;
private string _uri;
private string _packageName;
public Parser(AssistStructure structure)
{
@@ -17,16 +18,36 @@ namespace Bit.Android.Autofill
public FieldCollection FieldCollection { get; private set; } = new FieldCollection();
public string Uri
{
get => _uri;
get
{
if(!string.IsNullOrWhiteSpace(_uri))
{
return _uri;
}
if(string.IsNullOrWhiteSpace(PackageName))
{
_uri = null;
}
else
{
_uri = string.Concat(Constants.AndroidAppProtocol, PackageName);
}
return _uri;
}
}
public string PackageName
{
get => _packageName;
set
{
if(string.IsNullOrWhiteSpace(value))
{
_uri = null;
return;
_packageName = _uri = null;
}
_uri = string.Concat(Constants.AndroidAppProtocol, value);
_packageName = value;
}
}
@@ -45,9 +66,9 @@ namespace Bit.Android.Autofill
var isEditText = node.ClassName == "android.widget.EditText";
if(isEditText || (hints?.Length ?? 0) > 0)
{
if(Uri == null)
if(PackageName == null)
{
Uri = node.IdPackage;
PackageName = node.IdPackage;
}
FieldCollection.Add(new Field(node));
}