public Line(string idEntryPrefix, AutofillType autofillType, string label, string[] hints, string text, bool sanitized) { mAutofillType = autofillType; mLabelItem = new Item(this, ++sNextId, idEntryPrefix + "Label", null, AutofillType.None, label, false, true); mFieldTextItem = new Item(this, ++sNextId, idEntryPrefix + "Field", hints, autofillType, text, true, sanitized); }
public Item(Line line, int id, string[] hints, AutofillType type, string text, bool editable, bool sanitized) { Line = line; Id = id; Text = text; Editable = editable; Sanitized = sanitized; Hints = hints; Type = type; }
public Item(Line line, int id, string idEntry, string[] hints, AutofillType type, string text, bool editable, bool sanitized) { this.line = line; this.id = id; this.idEntry = idEntry; this.text = text; this.editable = editable; this.sanitized = sanitized; this.hints = hints; this.type = type; }
public AutofillFieldMetadata(AssistStructure.ViewNode view) { mAutofillId = view.AutofillId; mAutofillType = view.AutofillType; mAutofillOptions = view.GetAutofillOptions(); mFocused = view.IsFocused; var hints = AutofillHints.FilterForSupportedHints(view.GetAutofillHints()); if (hints != null) { AutofillHints.ConvertToStoredHintNames(hints); SetHints(hints); } }
/** * Adds a new line (containining a label and an input field) to the view. * * @param idEntryPrefix id prefix used to identify the line - label node will be suffixed * with {@code Label} and editable node with {@code Field}. * @param autofillType {@link View#getAutofillType() autofill type} of the field. * @param label text used in the label. * @param text initial text used in the input field. * @param sensitive whether the input is considered sensitive. * @param autofillHints list of autofill hints. * @return the new line. */ public Line AddLine(string idEntryPrefix, AutofillType autofillType, string label, string text, bool sensitive, params string[] autofillHints) { Preconditions.CheckArgument(autofillType == AutofillType.Text || autofillType == AutofillType.Date, "Unsupported type: " + autofillType); Line line = new Line(idEntryPrefix, autofillType, label, autofillHints, text, !sensitive); mVirtualViewGroups.Add(line); int id = line.mFieldTextItem.id; mLines.Put(id, line); mVirtualViews.Put(line.mLabelItem.id, line.mLabelItem); mVirtualViews.Put(id, line.mFieldTextItem); mPartitionsByAutofillId.Put(id, this); return(line); }
public static bool IsValidTypeForHints(string[] hints, AutofillType type) { if (hints != null) { foreach (var hint in hints) { if (hint != null && sValidHints.ContainsKey(hint)) { var valid = sValidHints[hint].IsValidType(type); if (valid) { return(true); } } } } return(false); }
public static string GetTypeAsString(AutofillType type) { switch (type) { case AutofillType.Text: return("TYPE_TEXT"); case AutofillType.List: return("TYPE_LIST"); case AutofillType.None: return("TYPE_NONE"); case AutofillType.Toggle: return("TYPE_TOGGLE"); case AutofillType.Date: return("TYPE_DATE"); } return("UNKNOWN_TYPE"); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.multiple_partitions_activity); mCustomVirtualView = FindViewById <ScrollableCustomVirtualView>(Resource.Id.custom_view); mCredentialsPartition = mCustomVirtualView.AddPartition(GetString(Resource.String.partition_credentials)); mCredentialsPartition.AddLine("username", AutofillType.Text, GetString(Resource.String.username_label), " ", false, View.AutofillHintUsername); mCredentialsPartition.AddLine("password", AutofillType.Text, GetString(Resource.String.password_label), " ", true, View.AutofillHintPassword); AutofillType ccExpirationType = AutofillType.Date; // TODO: add a checkbox to switch between text / date instead Intent intent = Intent; if (intent != null) { var newType = intent.GetIntExtra("dateType", -1); if (newType != -1) { ccExpirationType = (AutofillType)newType; var typeMessage = GetString(Resource.String.message_credit_card_expiration_type, CommonUtil.GetTypeAsString(ccExpirationType)); // TODO: display type in a header or proper status widget Toast.MakeText(ApplicationContext, typeMessage, ToastLength.Long).Show(); } } mCcPartition = mCustomVirtualView.AddPartition(GetString(Resource.String.partition_credit_card)); mCcPartition.AddLine("ccNumber", AutofillType.Text, GetString(Resource.String.credit_card_number_label), " ", true, View.AutofillHintCreditCardNumber); mCcPartition.AddLine("ccDay", AutofillType.Text, GetString(Resource.String.credit_card_expiration_day_label), " ", true, View.AutofillHintCreditCardExpirationDay); mCcPartition.AddLine("ccMonth", ccExpirationType, GetString(Resource.String.credit_card_expiration_month_label), " ", true, View.AutofillHintCreditCardExpirationMonth); mCcPartition.AddLine("ccYear", AutofillType.Text, GetString(Resource.String.credit_card_expiration_year_label), " ", true, View.AutofillHintCreditCardExpirationYear); mCcPartition.AddLine("ccDate", ccExpirationType, GetString(Resource.String.credit_card_expiration_date_label), " ", true, View.AutofillHintCreditCardExpirationDate); mCcPartition.AddLine("ccSecurityCode", AutofillType.Text, GetString(Resource.String.credit_card_security_code_label), " ", true, View.AutofillHintCreditCardSecurityCode); FindViewById(Resource.Id.clear).Click += delegate { ResetFields(); mCustomVirtualView.ResetPositions(); mAutofillManager.Cancel(); }; mAutofillManager = (AutofillManager)GetSystemService(Class.FromType(typeof(AutofillManager))); }
/** * Sometimes, data for a hint should only be stored as a certain AutofillValue type. For * example, it is recommended that data representing a Credit Card Expiration date, annotated * with the hint {@link android.view.View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE}, should * only be stored as {@link android.view.View.AUTOFILL_TYPE_DATE}. */ public bool IsValidType(AutofillType type) { return(mValidTypes.Contains(type)); }