public void Autofill(CipherView cipher)
        {
            var activity = (MainActivity)CrossCurrentActivity.Current.Activity;

            if (activity == null)
            {
                return;
            }
            if (activity.Intent.GetBooleanExtra("autofillFramework", false))
            {
                if (cipher == null)
                {
                    activity.SetResult(Result.Canceled);
                    activity.Finish();
                    return;
                }
                var structure = activity.Intent.GetParcelableExtra(
                    AutofillManager.ExtraAssistStructure) as AssistStructure;
                if (structure == null)
                {
                    activity.SetResult(Result.Canceled);
                    activity.Finish();
                    return;
                }
                var parser = new Parser(structure, activity.ApplicationContext);
                parser.Parse();
                if ((!parser.FieldCollection?.Fields?.Any() ?? true) || string.IsNullOrWhiteSpace(parser.Uri))
                {
                    activity.SetResult(Result.Canceled);
                    activity.Finish();
                    return;
                }
                var task        = CopyTotpAsync(cipher);
                var dataset     = AutofillHelpers.BuildDataset(activity, parser.FieldCollection, new FilledItem(cipher));
                var replyIntent = new Intent();
                replyIntent.PutExtra(AutofillManager.ExtraAuthenticationResult, dataset);
                activity.SetResult(Result.Ok, replyIntent);
                activity.Finish();
                var eventTask = _eventServiceFunc().CollectAsync(EventType.Cipher_ClientAutofilled, cipher.Id);
            }
            else
            {
                var data = new Intent();
                if (cipher == null)
                {
                    data.PutExtra("canceled", "true");
                }
                else
                {
                    var task = CopyTotpAsync(cipher);
                    data.PutExtra("uri", cipher.Login.Uri);
                    data.PutExtra("username", cipher.Login.Username);
                    data.PutExtra("password", cipher.Login.Password);
                }
                if (activity.Parent == null)
                {
                    activity.SetResult(Result.Ok, data);
                }
                else
                {
                    activity.Parent.SetResult(Result.Ok, data);
                }
                activity.Finish();
                _messagingService.Send("finishMainActivity");
                if (cipher != null)
                {
                    var eventTask = _eventServiceFunc().CollectAsync(EventType.Cipher_ClientAutofilled, cipher.Id);
                }
            }
        }
        public void Autofill(VaultListPageModel.Cipher cipher)
        {
            var activity = (MainActivity)CurrentContext;

            if (activity.Intent.GetBooleanExtra("autofillFramework", false))
            {
                if (cipher == null)
                {
                    activity.SetResult(Result.Canceled);
                    activity.Finish();
                    return;
                }

                var structure = activity.Intent.GetParcelableExtra(
                    AutofillManager.ExtraAssistStructure) as AssistStructure;
                if (structure == null)
                {
                    activity.SetResult(Result.Canceled);
                    activity.Finish();
                    return;
                }

                var parser = new Parser(structure);
                parser.Parse();
                if (!parser.FieldCollection.Fields.Any() || string.IsNullOrWhiteSpace(parser.Uri))
                {
                    activity.SetResult(Result.Canceled);
                    activity.Finish();
                    return;
                }

                var dataset = AutofillHelpers.BuildDataset(activity, parser.FieldCollection,
                                                           new FilledItem(cipher.CipherModel));
                var replyIntent = new Intent();
                replyIntent.PutExtra(AutofillManager.ExtraAuthenticationResult, dataset);
                activity.SetResult(Result.Ok, replyIntent);
                activity.Finish();
            }
            else
            {
                var data = new Intent();
                if (cipher == null)
                {
                    data.PutExtra("canceled", "true");
                }
                else
                {
                    var settings        = Resolver.Resolve <ISettings>();
                    var autoCopyEnabled = !settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false);
                    if (Helpers.CanAccessPremium() && autoCopyEnabled && cipher.LoginTotp?.Value != null)
                    {
                        CopyToClipboard(App.Utilities.Crypto.Totp(cipher.LoginTotp.Value));
                    }

                    data.PutExtra("uri", cipher.LoginUri);
                    data.PutExtra("username", cipher.LoginUsername);
                    data.PutExtra("password", cipher.LoginPassword?.Value ?? null);
                }

                if (activity.Parent == null)
                {
                    activity.SetResult(Result.Ok, data);
                }
                else
                {
                    activity.Parent.SetResult(Result.Ok, data);
                }

                activity.Finish();
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "FinishMainActivity");
            }
        }