protected override void OnBindingContextChanged()
        {
            Icon.Source = null;

            VaultListPageModel.Cipher cipher = null;
            if (BindingContext is VaultListPageModel.Cipher item)
            {
                cipher = item;
            }
            else if (BindingContext is VaultListPageModel.GroupingOrCipher groupingOrCipherItem)
            {
                cipher = groupingOrCipherItem.Cipher;
            }

            if (cipher != null)
            {
                if (cipher.Type == Enums.CipherType.Login)
                {
                    Icon.LoadingPlaceholder = "login.png";
                }
                Icon.Source = cipher.Icon;
            }

            base.OnBindingContextChanged();
        }
 public void Autofill(VaultListPageModel.Cipher cipher)
 {
     throw new NotImplementedException();
 }
Example #3
0
 public void Autofill(VaultListPageModel.Cipher cipher)
 {
     // do nothing
 }
Example #4
0
        public static async void CipherMoreClickedAsync(Page page, VaultListPageModel.Cipher cipher, bool autofill)
        {
            var buttons = new List <string> {
                AppResources.View, AppResources.Edit
            };

            if (cipher.Type == CipherType.Login)
            {
                if (!string.IsNullOrWhiteSpace(cipher.LoginPassword.Value))
                {
                    buttons.Add(AppResources.CopyPassword);
                }
                if (!string.IsNullOrWhiteSpace(cipher.LoginUsername))
                {
                    buttons.Add(AppResources.CopyUsername);
                }
                if (!autofill && !string.IsNullOrWhiteSpace(cipher.LoginUri) && (cipher.LoginUri.StartsWith("http://") ||
                                                                                 cipher.LoginUri.StartsWith("https://")))
                {
                    buttons.Add(AppResources.GoToWebsite);
                }
            }
            else if (cipher.Type == CipherType.Card)
            {
                if (!string.IsNullOrWhiteSpace(cipher.CardNumber))
                {
                    buttons.Add(AppResources.CopyNumber);
                }
                if (!string.IsNullOrWhiteSpace(cipher.CardCode.Value))
                {
                    buttons.Add(AppResources.CopySecurityCode);
                }
            }

            var selection = await page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, buttons.ToArray());

            if (selection == AppResources.View)
            {
                var p = new VaultViewCipherPage(cipher.Type, cipher.Id);
                await page.Navigation.PushForDeviceAsync(p);
            }
            else if (selection == AppResources.Edit)
            {
                var p = new VaultEditCipherPage(cipher.Id);
                await page.Navigation.PushForDeviceAsync(p);
            }
            else if (selection == AppResources.CopyPassword)
            {
                CipherCopy(cipher.LoginPassword.Value, AppResources.Password);
            }
            else if (selection == AppResources.CopyUsername)
            {
                CipherCopy(cipher.LoginUsername, AppResources.Username);
            }
            else if (selection == AppResources.GoToWebsite)
            {
                Device.OpenUri(new Uri(cipher.LoginUri));
            }
            else if (selection == AppResources.CopyNumber)
            {
                CipherCopy(cipher.CardNumber, AppResources.Number);
            }
            else if (selection == AppResources.CopySecurityCode)
            {
                CipherCopy(cipher.CardCode.Value, AppResources.SecurityCode);
            }
        }
Example #5
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");
            }
        }