Exemplo n.º 1
0
        public void Autofill(CipherView cipher)
        {
            var activity = (MainActivity)CrossCurrentActivity.Current.Activity;

            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() || 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();
            }
            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");
            }
        }
Exemplo n.º 2
0
 public async override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     await AutofillHelpers.TableRowSelectedAsync(tableView, indexPath, this,
                                                 _controller.CPViewController, _controller, "loginAddSegue");
 }
Exemplo n.º 3
0
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     AutofillHelpers.TableRowSelected(tableView, indexPath, this,
                                      _controller.CPViewController, _controller, _settings, "loginAddFromSearchSegue");
 }
Exemplo n.º 4
0
        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 isPremium       = Resolver.Resolve <ITokenService>()?.TokenPremium ?? false;
                    var settings        = Resolver.Resolve <ISettings>();
                    var autoCopyEnabled = !settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false);
                    if (isPremium && 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");
            }
        }
Exemplo n.º 5
0
 public async override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     await AutofillHelpers.TableRowSelectedAsync(tableView, indexPath, this,
                                                 _controller.CPViewController, _controller, _controller.PasswordRepromptService,
                                                 "loginAddFromSearchSegue");
 }