private List <Dataset> BuildEntryDatasets(string query, string queryDomain, string queryPackage, AutofillId[] autofillIds, StructureParser parser,
                                                  DisplayWarning warning)
        {
            List <Dataset> result = new List <Dataset>();

            Kp2aLog.Log("AF: BuildEntryDatasets");
            var suggestedEntries = GetSuggestedEntries(query).ToDictionary(e => e.DatasetName, e => e);

            Kp2aLog.Log("AF: BuildEntryDatasets found " + suggestedEntries.Count + " entries");
            foreach (var filledAutofillFieldCollection in suggestedEntries.Values)
            {
                if (filledAutofillFieldCollection == null)
                {
                    continue;
                }

                if (warning == DisplayWarning.None)
                {
                    FilledAutofillFieldCollection partitionData =
                        AutofillHintsHelper.FilterForPartition(filledAutofillFieldCollection, parser.AutofillFields.FocusedAutofillCanonicalHints);

                    Kp2aLog.Log("AF: Add dataset");

                    result.Add(AutofillHelper.NewDataset(this, parser.AutofillFields, partitionData, IntentBuilder));
                }
                else
                {
                    //return an "auth" dataset (actually for just warning the user in case domain/package dont match)
                    var sender =
                        IntentBuilder.GetAuthIntentSenderForWarning(this, query, queryDomain, queryPackage, warning);
                    var datasetName = filledAutofillFieldCollection.DatasetName;
                    if (datasetName == null)
                    {
                        Kp2aLog.Log("AF: dataset name is null");
                        continue;
                    }

                    RemoteViews presentation =
                        AutofillHelper.NewRemoteViews(PackageName, datasetName, AppNames.LauncherIcon);

                    var datasetBuilder = new Dataset.Builder(presentation);
                    datasetBuilder.SetAuthentication(sender);
                    //need to add placeholders so we can directly fill after ChooseActivity
                    foreach (var autofillId in autofillIds)
                    {
                        datasetBuilder.SetValue(autofillId, AutofillValue.ForText("PLACEHOLDER"));
                    }
                    Kp2aLog.Log("AF: Add auth dataset");
                    result.Add(datasetBuilder.Build());
                }
            }

            return(result);
        }
Esempio n. 2
0
        public AutofillFieldMetadata(AssistStructure.ViewNode view, string[] autofillHints)
        {
            AutofillId      = view.AutofillId;
            AutofillType    = view.AutofillType;
            AutofillOptions = view.GetAutofillOptions();
            Focused         = view.IsFocused;
            var supportedHints = AutofillHintsHelper.FilterForSupportedHints(autofillHints);
            var canonicalHints = AutofillHintsHelper.ConvertToCanonicalHints(supportedHints);

            SetHints(canonicalHints.ToArray());
        }
Esempio n. 3
0
        public static FilledAutofillFieldCollection FilterForPartition(FilledAutofillFieldCollection filledAutofillFieldCollection, List <string> autofillFieldsFocusedAutofillCanonicalHints)
        {
            //only apply partition data if we have FocusedAutofillCanonicalHints. This may be empty on buggy Firefox.
            if (autofillFieldsFocusedAutofillCanonicalHints.Any())
            {
                int partitionIndex = AutofillHintsHelper.GetPartitionIndex(autofillFieldsFocusedAutofillCanonicalHints.FirstOrDefault());
                return(AutofillHintsHelper.FilterForPartition(filledAutofillFieldCollection, partitionIndex));
            }

            return(filledAutofillFieldCollection);
        }
Esempio n. 4
0
        private Dataset AddEntryDataset(string query, StructureParser parser)
        {
            var filledAutofillFieldCollection = GetSuggestedEntry(query);

            if (filledAutofillFieldCollection == null)
            {
                return(null);
            }
            int partitionIndex = AutofillHintsHelper.GetPartitionIndex(parser.AutofillFields.FocusedAutofillCanonicalHints.FirstOrDefault());
            FilledAutofillFieldCollection partitionData = AutofillHintsHelper.FilterForPartition(filledAutofillFieldCollection, partitionIndex);

            return(AutofillHelper.NewDataset(this, parser.AutofillFields, partitionData, IntentBuilder));
        }
        protected void OnSuccess(FilledAutofillFieldCollection clientFormDataMap, bool isManual)
        {
            var             intent    = Intent;
            AssistStructure structure = (AssistStructure)intent.GetParcelableExtra(AutofillManager.ExtraAssistStructure);
            StructureParser parser    = new StructureParser(this, structure);

            parser.ParseForFill(isManual);
            AutofillFieldMetadataCollection autofillFields = parser.AutofillFields;
            int partitionIndex = AutofillHintsHelper.GetPartitionIndex(autofillFields.FocusedAutofillCanonicalHints.FirstOrDefault());
            FilledAutofillFieldCollection partitionData = AutofillHintsHelper.FilterForPartition(clientFormDataMap, partitionIndex);

            ReplyIntent = new Intent();
            SetDatasetIntent(AutofillHelper.NewDataset(this, autofillFields, partitionData, IntentBuilder));
        }
        protected void OnSuccess(FilledAutofillFieldCollection clientFormDataMap, bool isManual)
        {
            var             intent    = Intent;
            AssistStructure structure = (AssistStructure)intent.GetParcelableExtra(AutofillManager.ExtraAssistStructure);
            StructureParser parser    = new StructureParser(this, structure);

            parser.ParseForFill(isManual);
            AutofillFieldMetadataCollection autofillFields = parser.AutofillFields;
            var partitionData = AutofillHintsHelper.FilterForPartition(clientFormDataMap, parser.AutofillFields.FocusedAutofillCanonicalHints);



            ReplyIntent = new Intent();
            SetDatasetIntent(AutofillHelper.NewDataset(this, autofillFields, partitionData, IntentBuilder, null /*TODO can we get the inlinePresentationSpec here?*/));
            SetResult(Result.Ok, ReplyIntent);
        }
Esempio n. 7
0
        private Dataset BuildEntryDataset(string query, string queryDomain, string queryPackage, AutofillId[] autofillIds, StructureParser parser,
                                          DisplayWarning warning)
        {
            var filledAutofillFieldCollection = GetSuggestedEntry(query);

            if (filledAutofillFieldCollection == null)
            {
                return(null);
            }

            if (warning == DisplayWarning.None)
            {
                //can return an actual dataset
                int partitionIndex = AutofillHintsHelper.GetPartitionIndex(parser.AutofillFields.FocusedAutofillCanonicalHints.FirstOrDefault());
                FilledAutofillFieldCollection partitionData = AutofillHintsHelper.FilterForPartition(filledAutofillFieldCollection, partitionIndex);

                return(AutofillHelper.NewDataset(this, parser.AutofillFields, partitionData, IntentBuilder));
            }
            else
            {
                //return an "auth" dataset (actually for just warning the user in case domain/package dont match)
                var sender      = IntentBuilder.GetAuthIntentSenderForWarning(this, query, queryDomain, queryPackage, warning);
                var datasetName = filledAutofillFieldCollection.DatasetName;
                if (datasetName == null)
                {
                    return(null);
                }

                RemoteViews presentation = AutofillHelper.NewRemoteViews(PackageName, datasetName, AppNames.LauncherIcon);

                var datasetBuilder = new Dataset.Builder(presentation);
                datasetBuilder.SetAuthentication(sender);
                //need to add placeholders so we can directly fill after ChooseActivity
                foreach (var autofillId in autofillIds)
                {
                    datasetBuilder.SetValue(autofillId, AutofillValue.ForText("PLACEHOLDER"));
                }

                return(datasetBuilder.Build());
            }
        }