2016-12-23 06:37:16 +03:00
|
|
|
using Android.App;
|
|
|
|
using Android.Content;
|
|
|
|
using Android.OS;
|
|
|
|
using Android.Runtime;
|
2017-01-28 07:13:28 +03:00
|
|
|
using Android.Views;
|
2016-12-23 06:37:16 +03:00
|
|
|
|
|
|
|
namespace Bit.Android
|
|
|
|
{
|
2017-02-01 04:45:51 +03:00
|
|
|
[Activity(Theme = "@style/BitwardenTheme.Splash",
|
|
|
|
Label = "bitwarden",
|
2017-01-28 07:13:28 +03:00
|
|
|
Icon = "@drawable/icon",
|
|
|
|
WindowSoftInputMode = SoftInput.StateHidden)]
|
2016-12-23 06:37:16 +03:00
|
|
|
public class AutofillActivity : Activity
|
|
|
|
{
|
2017-01-24 07:32:52 +03:00
|
|
|
private string _lastQueriedUri;
|
2017-01-28 07:32:48 +03:00
|
|
|
|
|
|
|
public static AutofillCredentials LastCredentials { get; set; }
|
2017-01-24 07:32:52 +03:00
|
|
|
|
2016-12-23 06:37:16 +03:00
|
|
|
protected override void OnCreate(Bundle bundle)
|
|
|
|
{
|
|
|
|
base.OnCreate(bundle);
|
2017-01-31 03:26:39 +03:00
|
|
|
LaunchMainActivity(Intent, 932473);
|
|
|
|
}
|
2016-12-23 06:37:16 +03:00
|
|
|
|
2017-01-31 03:26:39 +03:00
|
|
|
protected override void OnNewIntent(Intent intent)
|
|
|
|
{
|
|
|
|
base.OnNewIntent(intent);
|
|
|
|
LaunchMainActivity(intent, 489729);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnDestroy()
|
|
|
|
{
|
|
|
|
base.OnDestroy();
|
2016-12-23 06:37:16 +03:00
|
|
|
}
|
|
|
|
|
2017-02-03 07:36:40 +03:00
|
|
|
protected override void OnResume()
|
|
|
|
{
|
|
|
|
base.OnResume();
|
|
|
|
if(!Intent.HasExtra("uri"))
|
|
|
|
{
|
|
|
|
Finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Intent.RemoveExtra("uri");
|
|
|
|
}
|
|
|
|
|
2016-12-23 06:37:16 +03:00
|
|
|
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
|
|
|
|
{
|
|
|
|
base.OnActivityResult(requestCode, resultCode, data);
|
2017-01-31 03:26:39 +03:00
|
|
|
if(data == null)
|
|
|
|
{
|
|
|
|
LastCredentials = null;
|
|
|
|
}
|
2017-02-07 03:39:07 +03:00
|
|
|
else
|
2016-12-23 06:37:16 +03:00
|
|
|
{
|
2017-02-07 03:39:07 +03:00
|
|
|
try
|
2017-01-24 07:32:52 +03:00
|
|
|
{
|
2017-02-07 03:39:07 +03:00
|
|
|
if(data.GetStringExtra("canceled") != null)
|
|
|
|
{
|
|
|
|
LastCredentials = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var uri = data.GetStringExtra("uri");
|
|
|
|
var username = data.GetStringExtra("username");
|
|
|
|
var password = data.GetStringExtra("password");
|
|
|
|
|
|
|
|
LastCredentials = new AutofillCredentials
|
|
|
|
{
|
|
|
|
Username = username,
|
|
|
|
Password = password,
|
|
|
|
Uri = uri,
|
|
|
|
LastUri = _lastQueriedUri
|
|
|
|
};
|
|
|
|
}
|
2017-01-31 03:26:39 +03:00
|
|
|
}
|
2017-02-07 03:39:07 +03:00
|
|
|
catch
|
2017-01-31 03:26:39 +03:00
|
|
|
{
|
2017-02-07 03:39:07 +03:00
|
|
|
LastCredentials = null;
|
2017-01-31 03:26:39 +03:00
|
|
|
}
|
2016-12-23 06:37:16 +03:00
|
|
|
}
|
2017-02-07 03:39:07 +03:00
|
|
|
|
|
|
|
Finish();
|
2016-12-23 06:37:16 +03:00
|
|
|
}
|
2017-01-31 03:26:39 +03:00
|
|
|
|
|
|
|
private void LaunchMainActivity(Intent callingIntent, int requestCode)
|
|
|
|
{
|
|
|
|
_lastQueriedUri = callingIntent?.GetStringExtra("uri");
|
|
|
|
if(_lastQueriedUri == null)
|
|
|
|
{
|
2017-02-03 07:36:40 +03:00
|
|
|
Finish();
|
2017-01-31 03:26:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var intent = new Intent(this, typeof(MainActivity));
|
|
|
|
intent.PutExtra("uri", _lastQueriedUri);
|
|
|
|
StartActivityForResult(intent, requestCode);
|
|
|
|
}
|
2016-12-23 06:37:16 +03:00
|
|
|
}
|
2017-01-28 07:32:48 +03:00
|
|
|
}
|