/// <summary> /// Wraps autofill data in a LoginCredential Dataset object which can then be sent back to the /// client View. /// </summary> /// <returns>The dataset.</returns> /// <param name="context">Context.</param> /// <param name="autofillFields">Autofill fields.</param> /// <param name="filledAutofillFieldCollection">Filled autofill field collection.</param> public static Dataset NewDataset(Context context, AutofillFieldMetadataCollection autofillFields, FilledAutofillFieldCollection filledAutofillFieldCollection, IAutofillIntentBuilder intentBuilder, Android.Widget.Inline.InlinePresentationSpec inlinePresentationSpec) { var datasetName = filledAutofillFieldCollection.DatasetName ?? "[noname]"; var datasetBuilder = new Dataset.Builder(NewRemoteViews(context.PackageName, datasetName, intentBuilder.AppIconResource)); datasetBuilder.SetId(datasetName); var setValueAtLeastOnce = filledAutofillFieldCollection.ApplyToFields(autofillFields, datasetBuilder); AddInlinePresentation(context, inlinePresentationSpec, datasetName, datasetBuilder, intentBuilder.AppIconResource); if (setValueAtLeastOnce) { return(datasetBuilder.Build()); } else { Kp2aLog.Log("Failed to set at least one value. #fields=" + autofillFields.GetAutofillIds().Length + " " + autofillFields.FocusedAutofillCanonicalHints); } return(null); }
/// <summary> /// Wraps autofill data in a LoginCredential Dataset object which can then be sent back to the /// client View. /// </summary> /// <returns>The dataset.</returns> /// <param name="context">Context.</param> /// <param name="autofillFields">Autofill fields.</param> /// <param name="filledAutofillFieldCollection">Filled autofill field collection.</param> public static Dataset NewDataset(Context context, AutofillFieldMetadataCollection autofillFields, FilledAutofillFieldCollection filledAutofillFieldCollection, IAutofillIntentBuilder intentBuilder) { var datasetName = filledAutofillFieldCollection.DatasetName; if (datasetName != null) { var datasetBuilder = new Dataset.Builder(NewRemoteViews(context.PackageName, datasetName, intentBuilder.AppIconResource)); datasetBuilder.SetId(datasetName); var setValueAtLeastOnce = filledAutofillFieldCollection.ApplyToFields(autofillFields, datasetBuilder); if (setValueAtLeastOnce) { return(datasetBuilder.Build()); } } return(null); }
/// <summary> /// Wraps autofill data in a Response object (essentially a series of Datasets) which can then /// be sent back to the client View. /// </summary> /// <returns>The response.</returns> /// <param name="context">Context.</param> /// <param name="datasetAuth">If set to <c>true</c> dataset auth.</param> /// <param name="autofillFields">Autofill fields.</param> /// <param name="clientFormDataMap">Client form data map.</param> /// <param name="intentBuilder"></param> public static FillResponse NewResponse(Context context, bool datasetAuth, AutofillFieldMetadataCollection autofillFields, Dictionary <string, FilledAutofillFieldCollection> clientFormDataMap, IAutofillIntentBuilder intentBuilder) { var responseBuilder = new FillResponse.Builder(); if (clientFormDataMap != null) { var datasetNames = clientFormDataMap.Keys; foreach (var datasetName in datasetNames) { var filledAutofillFieldCollection = clientFormDataMap[datasetName]; if (filledAutofillFieldCollection != null) { var dataset = NewDataset(context, autofillFields, filledAutofillFieldCollection, intentBuilder); if (dataset != null) { responseBuilder.AddDataset(dataset); } } } } if (autofillFields.SaveType != 0) { //TODO implement save var autofillIds = autofillFields.GetAutofillIds(); responseBuilder.SetSaveInfo (new SaveInfo.Builder(autofillFields.SaveType, autofillIds).Build()); return(responseBuilder.Build()); } else { Log.Debug(CommonUtil.Tag, "These fields are not meant to be saved by autofill."); return(null); } }