示例#1
0
        public static Dataset BuildDataset(Context context, FieldCollection fields, FilledItem filledItem,
                                           InlinePresentationSpec inlinePresentationSpec = null)
        {
            var overlayPresentation = BuildOverlayPresentation(
                filledItem.Name,
                filledItem.Subtitle,
                filledItem.Icon,
                context);

            var inlinePresentation = BuildInlinePresentation(
                inlinePresentationSpec,
                filledItem.Name,
                filledItem.Subtitle,
                filledItem.Icon,
                null,
                context);

            var datasetBuilder = new Dataset.Builder(overlayPresentation);

            if (inlinePresentation != null)
            {
                datasetBuilder.SetInlinePresentation(inlinePresentation);
            }
            if (filledItem.ApplyToFields(fields, datasetBuilder))
            {
                return(datasetBuilder.Build());
            }
            return(null);
        }
示例#2
0
 public static void AddInlinePresentation(Context context, InlinePresentationSpec inlinePresentationSpec, string datasetName, Dataset.Builder datasetBuilder, int iconId)
 {
     if (inlinePresentationSpec != null)
     {
         var inlinePresentation = BuildInlinePresentation(inlinePresentationSpec, datasetName, "", iconId, null, context);
         datasetBuilder.SetInlinePresentation(inlinePresentation);
     }
 }
示例#3
0
        public static Dataset BuildVaultDataset(Context context, FieldCollection fields, string uri, bool locked,
                                                IList <InlinePresentationSpec> inlinePresentationSpecs = null)
        {
            var intent = new Intent(context, typeof(MainActivity));

            intent.PutExtra("autofillFramework", true);
            if (fields.FillableForLogin)
            {
                intent.PutExtra("autofillFrameworkFillType", (int)CipherType.Login);
            }
            else if (fields.FillableForCard)
            {
                intent.PutExtra("autofillFrameworkFillType", (int)CipherType.Card);
            }
            else if (fields.FillableForIdentity)
            {
                intent.PutExtra("autofillFrameworkFillType", (int)CipherType.Identity);
            }
            else
            {
                return(null);
            }
            intent.PutExtra("autofillFrameworkUri", uri);
            var pendingIntent = PendingIntent.GetActivity(context, ++_pendingIntentId, intent,
                                                          PendingIntentFlags.CancelCurrent);

            var overlayPresentation = BuildOverlayPresentation(
                AppResources.AutofillWithBitwarden,
                locked ? AppResources.VaultIsLocked : AppResources.GoToMyVault,
                Resource.Drawable.icon,
                context);

            var inlinePresentation = BuildInlinePresentation(
                inlinePresentationSpecs?.Last(),
                AppResources.Bitwarden,
                locked ? AppResources.VaultIsLocked : AppResources.MyVault,
                Resource.Drawable.icon,
                pendingIntent,
                context);

            var datasetBuilder = new Dataset.Builder(overlayPresentation);

            if (inlinePresentation != null)
            {
                datasetBuilder.SetInlinePresentation(inlinePresentation);
            }
            datasetBuilder.SetAuthentication(pendingIntent?.IntentSender);

            // Dataset must have a value set. We will reset this in the main activity when the real item is chosen.
            foreach (var autofillId in fields.AutofillIds)
            {
                datasetBuilder.SetValue(autofillId, AutofillValue.ForText("PLACEHOLDER"));
            }
            return(datasetBuilder.Build());
        }