/**
         * Wraps autofill data in a LoginCredential  Dataset object which can then be sent back to the
         * client View.
         */
        public static Dataset NewDataset(
            Context context,
            AutofillFieldMetadataCollection autofillFields,
            FilledAutofillFieldCollection filledAutofillFieldCollection,
            bool datasetAuth)
        {
            var datasetName = filledAutofillFieldCollection.GetDatasetName();

            if (datasetName != null)
            {
                Dataset.Builder datasetBuilder;
                if (datasetAuth)
                {
                    datasetBuilder = new Dataset.Builder
                                         (NewRemoteViews(context.PackageName, datasetName, Resource.Drawable.ic_lock_black_24dp));
                    var sender = AuthActivity.GetAuthIntentSenderForDataset(context, datasetName);
                    datasetBuilder.SetAuthentication(sender);
                }
                else
                {
                    datasetBuilder = new Dataset.Builder
                                         (NewRemoteViews(context.PackageName, datasetName, Resource.Drawable.ic_person_black_24dp));
                }

                var setValueAtLeastOnce = filledAutofillFieldCollection.ApplyToFields(autofillFields, datasetBuilder);
                if (setValueAtLeastOnce)
                {
                    return(datasetBuilder.Build());
                }
            }

            return(null);
        }
        /**
         * Wraps autofill data in a Response object (essentially a series of Datasets) which can then
         * be sent back to the client View.
         */
        public FillResponse BuildResponse(Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                          List <DatasetWithFilledAutofillFields> datasets, bool datasetAuth)
        {
            FillResponse.Builder responseBuilder = new FillResponse.Builder();
            if (datasets != null)
            {
                foreach (var datasetWithFilledAutofillFields in datasets)
                {
                    if (datasetWithFilledAutofillFields != null)
                    {
                        Dataset dataset;
                        String  datasetName = datasetWithFilledAutofillFields.autofillDataset.GetDatasetName();
                        if (datasetAuth)
                        {
                            IntentSender intentSender = AuthActivity.GetAuthIntentSenderForDataset(
                                mContext, datasetName);
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews, intentSender);
                        }
                        else
                        {
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithNoAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews);
                        }
                        if (dataset != null)
                        {
                            responseBuilder.AddDataset(dataset);
                        }
                    }
                }
            }
            int saveType = 0;

            AutofillId[] autofillIds = mClientViewMetadata.mFocusedIds;
            if (autofillIds != null && autofillIds.Length > 0)
            {
                SaveInfo saveInfo = new SaveInfo.Builder((SaveDataType)saveType, autofillIds).Build();
                responseBuilder.SetSaveInfo(saveInfo);
                return(responseBuilder.Build());
            }
            return(null);
        }