public FilledAutofillField(ViewNode viewNode)
        {
            _autofillHints = AutofillHelper.FilterForSupportedHints(viewNode.GetAutofillHints());
            var autofillValue = viewNode.AutofillValue;

            if (autofillValue != null)
            {
                if (autofillValue.IsList)
                {
                    var autofillOptions = viewNode.GetAutofillOptions();
                    int index           = autofillValue.ListValue;
                    if (autofillOptions != null && autofillOptions.Length > 0)
                    {
                        TextValue = autofillOptions[index];
                    }
                }
                else if (autofillValue.IsDate)
                {
                    DateValue = autofillValue.DateValue;
                }
                else if (autofillValue.IsText)
                {
                    // Using toString of AutofillValue.getTextValue in order to save it to
                    // SharedPreferences.
                    TextValue = autofillValue.TextValue;
                }
            }
        }
        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);
        }
 public AutofillFieldMetadata(ViewNode view)
 {
     _autofillOptions = view.GetAutofillOptions();
     Id            = view.Id;
     AutofillId    = view.AutofillId;
     AutofillType  = (AutofillType)(int)view.AutofillType;
     InputType     = (InputTypes)(int)view.InputType;
     IsFocused     = view.IsFocused;
     AutofillHints = AutofillHelper.FilterForSupportedHints(view.GetAutofillHints())?.ToList() ?? new List <string>();
 }