Exemplo n.º 1
0
        /// <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>
        /// <param name="datasetAuth">If set to <c>true</c> dataset auth.</param>
        public static Dataset NewDataset(Context context,
                                         AutofillFieldMetadataCollection autofillFields, FilledAutofillFieldCollection filledAutofillFieldCollection, bool datasetAuth)
        {
            var datasetName = filledAutofillFieldCollection.DatasetName;

            if (datasetName != null)
            {
                Dataset.Builder datasetBuilder;
                if (datasetAuth)
                {
                    datasetBuilder = new Dataset.Builder
                                         (NewRemoteViews(context.PackageName, datasetName,
                                                         Resource.Drawable.ic_lock_black_24dp));
                    IntentSender sender = AuthActivity.GetAuthIntentSenderForDataset(context, datasetName);
                    datasetBuilder.SetAuthentication(sender);
                }
                else
                {
                    datasetBuilder = new Dataset.Builder
                                         (NewRemoteViews(context.PackageName, datasetName,
                                                         Resource.Drawable.ic_person_black_24dp));
                }
                var setValueAtLeastOnce = filledAutofillFieldCollection.ApplyToFields(autofillFields, datasetBuilder);
                if (setValueAtLeastOnce)
                {
                    return(datasetBuilder.Build());
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public void StartIntentSender<TCallBack>(IntentSender intent, int requestCode, Action<TCallBack> callback)
            where TCallBack: class
        {
            if (requestCode == RequestCode.ResolveHint)
            {
                phoneNumberCallback = (Action<string>) callback;
            }

            StartIntentSenderForResult(intent, requestCode, null, 0, 0, 0);
        }
        public FillResponse BuildResponse(IntentSender sender, RemoteViews remoteViews)
        {
            FillResponse.Builder responseBuilder = new FillResponse.Builder();
            int saveType = mClientViewMetadata.mSaveType;

            AutofillId[] autofillIds = mClientViewMetadata.mFocusedIds;
            if (autofillIds != null && autofillIds.Length > 0)
            {
                SaveInfo saveInfo = new SaveInfo.Builder((SaveDataType)saveType, autofillIds).Build();
                responseBuilder.SetSaveInfo(saveInfo);
                responseBuilder.SetAuthentication(autofillIds, sender, remoteViews);
                return(responseBuilder.Build());
            }
            return(null);
        }
Exemplo n.º 4
0
 public static void startIntentSender(Activity activity, IntentSender intentSender, Intent intent)
 {
     //if (startIntentSender != null) {
     //     final Object[] args = new Object[5];
     //     args[0] = intentSender;
     //     args[1] = intent;
     //     args[2] = Integer.valueOf(0);
     //     args[3] = Integer.valueOf(0);
     //     args[4] = Integer.valueOf(0);
     //     try {
     //         startIntentSender.invoke(activity, args);
     //     } catch (Exception e) {
     //         Log.e(Compatibility.class.getSimpleName(), "startIntentSender", e);
     //     }
     //}
 }
        /**
         * Wraps autofill data in a Response object (essentially a series of Datasets) which can then
         * be sent back to the client View.
         */
        public FillResponse BuildResponse(Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                          List <DatasetWithFilledAutofillFields> datasets, bool datasetAuth)
        {
            FillResponse.Builder responseBuilder = new FillResponse.Builder();
            if (datasets != null)
            {
                foreach (var datasetWithFilledAutofillFields in datasets)
                {
                    if (datasetWithFilledAutofillFields != null)
                    {
                        Dataset dataset;
                        String  datasetName = datasetWithFilledAutofillFields.autofillDataset.GetDatasetName();
                        if (datasetAuth)
                        {
                            IntentSender intentSender = AuthActivity.GetAuthIntentSenderForDataset(
                                mContext, datasetName);
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews, intentSender);
                        }
                        else
                        {
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithNoAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews);
                        }
                        if (dataset != null)
                        {
                            responseBuilder.AddDataset(dataset);
                        }
                    }
                }
            }
            int saveType = 0;

            AutofillId[] autofillIds = mClientViewMetadata.mFocusedIds;
            if (autofillIds != null && autofillIds.Length > 0)
            {
                SaveInfo saveInfo = new SaveInfo.Builder((SaveDataType)saveType, autofillIds).Build();
                responseBuilder.SetSaveInfo(saveInfo);
                return(responseBuilder.Build());
            }
            return(null);
        }
        public void OnConnected(Bundle connectionHint)
        {
            Log.Info(TAG, "API client connected.");
            IntentSender intentSender = DriveClass.DriveApi
                                        .NewOpenFileActivityBuilder()
                                        //.SetMimeType(new string[] { "text/pdf" })
                                        .Build(_googleApiClient);

            try
            {
                StartIntentSenderForResult(intentSender, REQUEST_CODE_OPENER, null, 0, 0, 0);
            }
            catch (IntentSender.SendIntentException e)
            {
                Log.Warn(TAG, "Unable to send intent", e);
            }
        }
        /**
         * Wraps autofill data in a {@link Dataset} object with an IntentSender, which can then be
         * sent back to the client.
         */
        public Dataset BuildDataset(Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                    DatasetWithFilledAutofillFields datasetWithFilledAutofillFields,
                                    RemoteViews remoteViews, IntentSender intentSender)
        {
            Dataset.Builder datasetBuilder = new Dataset.Builder(remoteViews);
            if (intentSender != null)
            {
                datasetBuilder.SetAuthentication(intentSender);
            }
            bool setAtLeastOneValue = BindDataset(fieldTypesByAutofillHint,
                                                  datasetWithFilledAutofillFields, datasetBuilder);

            if (!setAtLeastOneValue)
            {
                return(null);
            }
            return(datasetBuilder.Build());
        }
Exemplo n.º 8
0
        private List <Dataset> BuildEntryDatasets(string query, string queryDomain, string queryPackage, AutofillId[] autofillIds, StructureParser parser,
                                                  DisplayWarning warning, IList <InlinePresentationSpec> inlinePresentationSpecs)
        {
            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");
            int count = 0;

            foreach (var filledAutofillFieldCollection in suggestedEntries.Values)
            {
                if (filledAutofillFieldCollection == null)
                {
                    continue;
                }

                var inlinePresentationSpec = AutofillHelper.ExtractSpec(inlinePresentationSpecs, count);

                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,
                                                         inlinePresentationSpec));
                }
                else
                {
                    //return an "auth" dataset (actually for just warning the user in case domain/package dont match)
                    IntentSender 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);

                    AutofillHelper.AddInlinePresentation(this, inlinePresentationSpec, datasetName, datasetBuilder, AppNames.LauncherIcon);

                    //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());
                }
                count++;
            }

            return(result);
        }
Exemplo n.º 9
0
 public override void freeStorage(long freeStorageSize, IntentSender pi)
 {
     throw new NotImplementedException();
 }