コード例 #1
0
 /// <summary>
 /// Adds a filledAutofillField to the collection, indexed by all of its hints.
 /// </summary>
 /// <returns>The add.</returns>
 /// <param name="filledAutofillField">Filled autofill field.</param>
 public void Add(FilledAutofillField filledAutofillField)
 {
     foreach (string hint in filledAutofillField.AutofillHints)
     {
         if (AutofillHintsHelper.IsSupportedHint(hint))
         {
             HintMap.Add(hint, filledAutofillField);
         }
         else
         {
             CommonUtil.loge($"Invalid hint: {hint}");
         }
     }
 }
コード例 #2
0
ファイル: FilledAutofillField.cs プロジェクト: 77rusa/README
        public FilledAutofillField(AssistStructure.ViewNode viewNode, string[] hints)
        {
            string[]      rawHints = AutofillHintsHelper.FilterForSupportedHints(hints);
            List <string> hintList = new List <string>();

            string nextHint = null;

            for (int i = 0; i < rawHints.Length; i++)
            {
                string hint = rawHints[i];
                if (i < rawHints.Length - 1)
                {
                    nextHint = rawHints[i + 1];
                }
                // First convert the compound W3C autofill hints
                if (W3cHints.isW3cSectionPrefix(hint) && i < rawHints.Length - 1)
                {
                    hint = rawHints[++i];
                    CommonUtil.logd($"Hint is a W3C section prefix; using {hint} instead");
                    if (i < rawHints.Length - 1)
                    {
                        nextHint = rawHints[i + 1];
                    }
                }
                if (W3cHints.isW3cTypePrefix(hint) && nextHint != null && W3cHints.isW3cTypeHint(nextHint))
                {
                    hint = nextHint;
                    i++;
                    CommonUtil.logd($"Hint is a W3C type prefix; using {hint} instead");
                }
                if (W3cHints.isW3cAddressType(hint) && nextHint != null)
                {
                    hint = nextHint;
                    i++;
                    CommonUtil.logd($"Hint is a W3C address prefix; using  {hint} instead");
                }

                // Then check if the "actual" hint is supported.
                if (AutofillHintsHelper.IsSupportedHint(hint))
                {
                    hintList.Add(hint);
                }
                else
                {
                    CommonUtil.loge($"Invalid hint: {rawHints[i]}");
                }
            }
            AutofillHints = AutofillHintsHelper.ConvertToCanonicalHints(hintList.ToArray()).ToArray();

            AutofillValue autofillValue = viewNode.AutofillValue;

            if (autofillValue != null)
            {
                if (autofillValue.IsList)
                {
                    string[] 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)
                {
                    TextValue = autofillValue.TextValue;
                }
            }
        }