mirror of
https://github.com/bitwarden/mobile
synced 2025-12-25 12:43:39 +00:00
cleanup on autofill
This commit is contained in:
@@ -299,6 +299,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutofillActivity.cs" />
|
||||
<Compile Include="AutofillCredentials.cs" />
|
||||
<Compile Include="Controls\CustomSearchBarRenderer.cs" />
|
||||
<Compile Include="Controls\CustomButtonRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedButtonRenderer.cs" />
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
@@ -18,7 +13,8 @@ namespace Bit.Android
|
||||
public class AutofillActivity : Activity
|
||||
{
|
||||
private string _lastQueriedUri;
|
||||
public static Credentials LastCredentials;
|
||||
|
||||
public static AutofillCredentials LastCredentials { get; set; }
|
||||
|
||||
protected override void OnCreate(Bundle bundle)
|
||||
{
|
||||
@@ -40,25 +36,22 @@ namespace Bit.Android
|
||||
var username = data.GetStringExtra("username");
|
||||
var password = data.GetStringExtra("password");
|
||||
|
||||
LastCredentials = new Credentials
|
||||
LastCredentials = new AutofillCredentials
|
||||
{
|
||||
User = username,
|
||||
Username = username,
|
||||
Password = password,
|
||||
Uri = _lastQueriedUri
|
||||
Uri = uri,
|
||||
LastUri = _lastQueriedUri
|
||||
};
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
LastCredentials = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Finish();
|
||||
}
|
||||
}
|
||||
|
||||
public class Credentials
|
||||
{
|
||||
public string User;
|
||||
public string Password;
|
||||
public string Uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
src/Android/AutofillCredentials.cs
Normal file
10
src/Android/AutofillCredentials.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Bit.Android
|
||||
{
|
||||
public class AutofillCredentials
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Uri { get; set; }
|
||||
public string LastUri { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace Bit.Android
|
||||
var allEditTexts = GetNodeOrChildren(root, n => EditText(n));
|
||||
var usernameEditText = allEditTexts.TakeWhile(n => !n.Password).LastOrDefault();
|
||||
|
||||
if(AutofillActivity.LastCredentials != null && SameUri(AutofillActivity.LastCredentials.Uri, uri))
|
||||
if(AutofillActivity.LastCredentials != null && SameUri(AutofillActivity.LastCredentials.LastUri, uri))
|
||||
{
|
||||
FillCredentials(usernameEditText, avialablePasswordNodes);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace Bit.Android
|
||||
|
||||
private void FillCredentials(AccessibilityNodeInfo usernameNode, IEnumerable<AccessibilityNodeInfo> passwordNodes)
|
||||
{
|
||||
FillEditText(usernameNode, AutofillActivity.LastCredentials.User);
|
||||
FillEditText(usernameNode, AutofillActivity.LastCredentials.Username);
|
||||
foreach(var pNode in passwordNodes)
|
||||
{
|
||||
FillEditText(pNode, AutofillActivity.LastCredentials.Password);
|
||||
@@ -209,4 +209,4 @@ namespace Bit.Android
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user