Autofill WIP

This commit is contained in:
Kyle Spearrin 2017-01-23 21:28:38 -05:00
parent 33e7ca08d8
commit 759df9bdd5
5 changed files with 53 additions and 6 deletions

View file

@ -298,6 +298,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AutofillSelectLoginActivity.cs" />
<Compile Include="AutofillActivity.cs" /> <Compile Include="AutofillActivity.cs" />
<Compile Include="Controls\CustomSearchBarRenderer.cs" /> <Compile Include="Controls\CustomSearchBarRenderer.cs" />
<Compile Include="Controls\CustomButtonRenderer.cs" /> <Compile Include="Controls\CustomButtonRenderer.cs" />

View file

@ -22,19 +22,25 @@ namespace Bit.Android
var url = Intent.GetStringExtra("url"); var url = Intent.GetStringExtra("url");
_lastQueriedUrl = url; _lastQueriedUrl = url;
//StartActivityForResult(Kp2aControl.GetQueryEntryIntent(url), 123);
Intent intent = new Intent(this, typeof(AutofillSelectLoginActivity));
intent.PutExtra("url", url);
StartActivityForResult(intent, 123);
} }
string _lastQueriedUrl; string _lastQueriedUrl;
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{ {
var url = data.GetStringExtra("url");
var username = data.GetStringExtra("username");
var password = data.GetStringExtra("password");
base.OnActivityResult(requestCode, resultCode, data); base.OnActivityResult(requestCode, resultCode, data);
try try
{ {
// TODO: lookup login LastReceivedCredentials = new Credentials { User = username, Password = password, Url = _lastQueriedUrl };
LastReceivedCredentials = new Credentials { User = "username", Password = "12345678", Url = _lastQueriedUrl };
} }
catch(Exception e) catch(Exception e)
{ {

View file

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
namespace Bit.Android
{
//[Activity(LaunchMode = global::Android.Content.PM.LaunchMode.SingleInstance)]
public class AutofillSelectLoginActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var url = Intent.GetStringExtra("url");
Intent data = new Intent();
data.PutExtra("url", url);
data.PutExtra("username", "user123");
data.PutExtra("password", "pass123");
if(Parent == null)
{
SetResult(Result.Ok, data);
}
else
{
Parent.SetResult(Result.Ok, data);
}
Finish();
}
}
}

View file

@ -25,6 +25,7 @@ namespace Bit.Android
public override void OnAccessibilityEvent(AccessibilityEvent e) public override void OnAccessibilityEvent(AccessibilityEvent e)
{ {
var eventType = e.EventType; var eventType = e.EventType;
System.Diagnostics.Debug.WriteLine(DateTime.UtcNow.ToString() + " Event Type: " + eventType);
var package = e.PackageName; var package = e.PackageName;
switch(eventType) switch(eventType)
{ {
@ -122,8 +123,9 @@ namespace Bit.Android
{ {
if(url1.StartsWith("androidapp://")) if(url1.StartsWith("androidapp://"))
return url1 == url2; return url1 == url2;
//return KeePassLib.Utility.UrlUtil.GetHost(url1) == KeePassLib.Utility.UrlUtil.GetHost(url2); // TODO: host check
return false; return url1 == url2;
//return false;
} }
private static bool IsPasswordField(AccessibilityNodeInfo n) private static bool IsPasswordField(AccessibilityNodeInfo n)

View file

@ -4,4 +4,5 @@
android:accessibilityFeedbackType="feedbackSpoken" android:accessibilityFeedbackType="feedbackSpoken"
android:accessibilityFlags="flagDefault" android:accessibilityFlags="flagDefault"
android:notificationTimeout="100" android:notificationTimeout="100"
android:canRetrieveWindowContent="true"/> android:canRetrieveWindowContent="true"
android:canRequestEnhancedWebAccessibility="true"/>