/**
         * 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.DatasetName;

            if (datasetName != null)
            {
                Dataset.Builder datasetBuilder;
                if (datasetAuth)
                {
                    datasetBuilder = new Dataset.Builder(
                        NewRemoteViews(context.PackageName, datasetName, "username", Resource.Drawable.fa_lock));
                    //IntentSender sender = AuthActivity.getAuthIntentSenderForDataset(context, datasetName);
                    //datasetBuilder.SetAuthentication(sender);
                }
                else
                {
                    datasetBuilder = new Dataset.Builder(
                        NewRemoteViews(context.PackageName, datasetName, "username", Resource.Drawable.user));
                }

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

            return(null);
        }
        public override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal,
                                           FillCallback callback)
        {
            var structure = request.FillContexts?.LastOrDefault()?.Structure;

            if (structure == null)
            {
                return;
            }

            var clientState = request.ClientState;

            var parser = new StructureParser(structure);

            parser.ParseForFill();

            // build response
            var responseBuilder = new FillResponse.Builder();

            var username1 = new FilledAutofillField {
                TextValue = "username1"
            };
            var password1 = new FilledAutofillField {
                TextValue = "pass1"
            };
            var login1 = new Dictionary <string, FilledAutofillField>
            {
                { View.AutofillHintUsername, username1 },
                { View.AutofillHintPassword, password1 }
            };
            var coll = new FilledAutofillFieldCollection("Login 1 Name", login1);

            var username2 = new FilledAutofillField {
                TextValue = "username2"
            };
            var password2 = new FilledAutofillField {
                TextValue = "pass2"
            };
            var login2 = new Dictionary <string, FilledAutofillField>
            {
                { View.AutofillHintUsername, username2 },
                { View.AutofillHintPassword, password2 }
            };
            var col2 = new FilledAutofillFieldCollection("Login 2 Name", login2);

            var clientFormDataMap = new Dictionary <string, FilledAutofillFieldCollection>
            {
                { "login-1-guid", coll },
                { "login-2-guid", col2 }
            };

            var response = AutofillHelper.NewResponse(this, false, parser.AutofillFields, clientFormDataMap);

            // end build response

            callback.OnSuccess(response);
        }
        /**
         * Traverse AssistStructure and add ViewNode metadata to a flat list.
         */
        private void Parse(bool forFill)
        {
            _filledAutofillFieldCollection = new FilledAutofillFieldCollection();

            for (var i = 0; i < _structure.WindowNodeCount; i++)
            {
                var node = _structure.GetWindowNodeAt(i);
                var view = node.RootViewNode;
                ParseLocked(forFill, view);
            }
        }