mirror of
https://github.com/bitwarden/android.git
synced 2024-11-01 15:45:42 +03:00
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using Android.App;
|
|
using Android.Content;
|
|
using Android.OS;
|
|
using Android.Runtime;
|
|
using Android.Views;
|
|
|
|
namespace Bit.Android
|
|
{
|
|
[Activity(Label = "bitwarden",
|
|
Icon = "@drawable/icon",
|
|
LaunchMode = global::Android.Content.PM.LaunchMode.SingleInstance,
|
|
WindowSoftInputMode = SoftInput.StateHidden)]
|
|
public class AutofillActivity : Activity
|
|
{
|
|
private string _lastQueriedUri;
|
|
|
|
public static AutofillCredentials LastCredentials { get; set; }
|
|
|
|
protected override void OnCreate(Bundle bundle)
|
|
{
|
|
base.OnCreate(bundle);
|
|
_lastQueriedUri = Intent.GetStringExtra("uri");
|
|
|
|
var intent = new Intent(this, typeof(MainActivity));
|
|
intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
|
|
intent.PutExtra("uri", _lastQueriedUri);
|
|
StartActivityForResult(intent, 123);
|
|
}
|
|
|
|
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
|
|
{
|
|
base.OnActivityResult(requestCode, resultCode, data);
|
|
|
|
try
|
|
{
|
|
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
|
|
};
|
|
}
|
|
catch
|
|
{
|
|
LastCredentials = null;
|
|
}
|
|
finally
|
|
{
|
|
Finish();
|
|
}
|
|
}
|
|
}
|
|
}
|