1
0
mirror of https://github.com/bitwarden/mobile.git synced 2025-01-22 21:11:27 +01:00
bitwarden-mobile/src/Android/AutofillActivity.cs

59 lines
1.7 KiB
C#
Raw Normal View History

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
namespace Bit.Android
{
[Activity(Label = "bitwarden",
Icon = "@drawable/icon",
2017-01-24 05:32:52 +01:00
LaunchMode = global::Android.Content.PM.LaunchMode.SingleInstance,
WindowSoftInputMode = SoftInput.StateHidden)]
public class AutofillActivity : Activity
{
2017-01-24 05:32:52 +01:00
private string _lastQueriedUri;
2017-01-28 05:32:48 +01:00
public static AutofillCredentials LastCredentials { get; set; }
2017-01-24 05:32:52 +01:00
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
2017-01-24 05:32:52 +01:00
_lastQueriedUri = Intent.GetStringExtra("uri");
var intent = new Intent(this, typeof(MainActivity));
2017-01-29 05:58:26 +01:00
intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
2017-01-24 05:32:52 +01:00
intent.PutExtra("uri", _lastQueriedUri);
2017-01-24 03:28:38 +01:00
StartActivityForResult(intent, 123);
}
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
try
{
2017-01-24 05:32:52 +01:00
var uri = data.GetStringExtra("uri");
var username = data.GetStringExtra("username");
var password = data.GetStringExtra("password");
2017-01-28 05:32:48 +01:00
LastCredentials = new AutofillCredentials
2017-01-24 05:32:52 +01:00
{
2017-01-28 05:32:48 +01:00
Username = username,
2017-01-24 05:32:52 +01:00
Password = password,
2017-01-28 05:32:48 +01:00
Uri = uri,
LastUri = _lastQueriedUri
2017-01-24 05:32:52 +01:00
};
}
2017-01-28 05:32:48 +01:00
catch
{
LastCredentials = null;
}
finally
{
Finish();
}
}
}
2017-01-28 05:32:48 +01:00
}