Ejemplo n.º 1
0
        public override void OnProvideAutofillVirtualStructure(ViewStructure structure, AutofillFlags flags)
        {
            // Build a ViewStructure that will get passed to the AutofillService by the framework
            // when it is time to find autofill suggestions.
            structure.SetClassName(Class.Name);
            var childrenSize = VirtualViews.Size();

            Log.Debug(LogTag, "onProvideAutofillVirtualStructure(): flags = " + flags + ", items = "
                      + childrenSize + ", extras: " + CommonUtil.BundleToString(structure.Extras));
            var index = structure.AddChildCount(childrenSize);

            // Traverse through the view hierarchy, including virtual child views. For each view, we
            // need to set the relevant autofill metadata and add it to the ViewStructure.
            for (int i = 0; i < childrenSize; i++)
            {
                Item item = VirtualViews.ValueAt(i);
                Log.Debug(LogTag, "Adding new child at index " + index + ": " + item);
                var child = structure.NewChild(index);
                child.SetAutofillId(structure.AutofillId, item.Id);
                child.SetAutofillHints(item.Hints);
                child.SetAutofillType(item.Type);
                child.SetDataIsSensitive(!item.Sanitized);
                child.Text = item.Text;
                child.SetAutofillValue(AutofillValue.ForText(item.Text));
                child.SetFocused(item.Focused);
                child.SetId(item.Id, Context.PackageName, null, item.Line.IdEntry);
                child.SetClassName(item.getClassName());
                index++;
            }
        }