Java源码示例:org.chromium.ui.DropdownItem

示例1
/**
 * Filters the Autofill suggestions to the ones that we support and shows the popup.
 * @param suggestions Autofill suggestion data.
 * @param isRtl @code true if right-to-left text.
 * @param backgroundColor popup background color, or {@code Color.TRANSPARENT} if unspecified.
 * @param dividerColor color for divider between popup items, or {@code Color.TRANSPARENT} if
 * unspecified.
 * @param isBoldLabel true if suggestion label's type face is {@code Typeface.BOLD}, false if
 * suggestion label's type face is {@code Typeface.NORMAL}.
 * @param dropdownItemHeight height of each dropdown item in dimension independent pixel units,
 * 0 if unspecified.
 * @param margin Margin for icon, label and between icon and label in dimension independent
 * pixel units, 0 if not specified.
 */
@SuppressLint("InlinedApi")
public void filterAndShow(AutofillSuggestion[] suggestions, boolean isRtl,
        int backgroundColor, int dividerColor, int dropdownItemHeight, int margin) {
    mSuggestions = new ArrayList<AutofillSuggestion>(Arrays.asList(suggestions));
    // Remove the AutofillSuggestions with IDs that are not supported by Android
    ArrayList<DropdownItem> cleanedData = new ArrayList<DropdownItem>();
    HashSet<Integer> separators = new HashSet<Integer>();
    for (int i = 0; i < suggestions.length; i++) {
        int itemId = suggestions[i].getSuggestionId();
        if (itemId == ITEM_ID_SEPARATOR_ENTRY) {
            separators.add(cleanedData.size());
        } else {
            cleanedData.add(suggestions[i]);
        }
    }

    setAdapter(new DropdownAdapter(mContext, cleanedData, separators,
            backgroundColor == Color.TRANSPARENT ? null : backgroundColor,
            dividerColor == Color.TRANSPARENT ? null : dividerColor,
            dropdownItemHeight == 0 ? null : dropdownItemHeight,
            margin == 0 ? null : margin));
    setRtl(isRtl);
    show();
    getListView().setOnItemLongClickListener(this);
    getListView().setAccessibilityDelegate(new AccessibilityDelegate() {
        @Override
        public boolean onRequestSendAccessibilityEvent(
                ViewGroup host, View child, AccessibilityEvent event) {
            getListView().removeCallbacks(mClearAccessibilityFocusRunnable);
            if (event.getEventType()
                    == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED) {
                getListView().postDelayed(
                        mClearAccessibilityFocusRunnable, CLEAR_ACCESSIBILITY_FOCUS_DELAY_MS);
            }
            return super.onRequestSendAccessibilityEvent(host, child, event);
        }
    });
}
 
示例2
/**
 * @param array AutofillSuggestion array that should get a new suggestion added.
 * @param index Index in the array where to place a new suggestion.
 * @param label Suggested text. The text that's going to be filled in the focused field, with a
 *              few exceptions:
 *              <ul>
 *                  <li>Credit card numbers are elided, e.g. "Visa ****-1234."</li>
 *                  <li>The text "CLEAR FORM" will clear the filled in text.</li>
 *                  <li>Empty text can be used to display only icons, e.g. for credit card scan
 *                      or editing autofill settings.</li>
 *              </ul>
 * @param sublabel Hint for the suggested text. The text that's going to be filled in the
 *                 unfocused fields of the form. If {@see label} is empty, then this must be
 *                 empty too.
 * @param iconId The resource ID for the icon associated with the suggestion, or 0 for no icon.
 * @param suggestionId Identifier for the suggestion type.
 */
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
        String label, String sublabel, int iconId, int suggestionId, boolean deletable) {
    int drawableId = iconId == 0 ? DropdownItem.NO_ICON : ResourceId.mapToDrawableId(iconId);
    array[index] =
            new AutofillSuggestion(label, sublabel, drawableId, suggestionId, deletable, false);
}
 
示例3
/**
 * @param array AutofillSuggestion array that should get a new suggestion added.
 * @param index Index in the array where to place a new suggestion.
 * @param label First line of the suggestion.
 * @param sublabel Second line of the suggestion.
 * @param iconId The resource ID for the icon associated with the suggestion, or 0 for no icon.
 * @param suggestionId Identifier for the suggestion type.
 * @param deletable Whether this item is deletable.
 * @param isLabelMultiline Whether the label should be should over multiple lines.
 */
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
        String label, String sublabel, int iconId, int suggestionId, boolean deletable,
        boolean isLabelMultiline) {
    int drawableId = iconId == 0 ? DropdownItem.NO_ICON : ResourceId.mapToDrawableId(iconId);
    array[index] = new AutofillSuggestion(
            label, sublabel, drawableId, suggestionId, deletable, isLabelMultiline);
}
 
示例4
/**
 * @param array AutofillSuggestion array that should get a new suggestion added.
 * @param index Index in the array where to place a new suggestion.
 * @param label Suggested text. The text that's going to be filled in the focused field, with a
 *              few exceptions:
 *              <ul>
 *                  <li>Credit card numbers are elided, e.g. "Visa ****-1234."</li>
 *                  <li>The text "CLEAR FORM" will clear the filled in text.</li>
 *                  <li>Empty text can be used to display only icons, e.g. for credit card scan
 *                      or editing autofill settings.</li>
 *              </ul>
 * @param sublabel Hint for the suggested text. The text that's going to be filled in the
 *                 unfocused fields of the form. If {@see label} is empty, then this must be
 *                 empty too.
 * @param iconId The resource ID for the icon associated with the suggestion, or 0 for no icon.
 * @param suggestionId Identifier for the suggestion type.
 */
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
        String label, String sublabel, int iconId, int suggestionId, boolean deletable) {
    int drawableId = iconId == 0 ? DropdownItem.NO_ICON : ResourceId.mapToDrawableId(iconId);
    array[index] =
            new AutofillSuggestion(label, sublabel, drawableId, suggestionId, deletable, false);
}
 
示例5
/**
 * @param array AutofillSuggestion array that should get a new suggestion added.
 * @param index Index in the array where to place a new suggestion.
 * @param label First line of the suggestion.
 * @param sublabel Second line of the suggestion.
 * @param iconId The resource ID for the icon associated with the suggestion, or 0 for no icon.
 * @param suggestionId Identifier for the suggestion type.
 * @param deletable Whether this item is deletable.
 * @param isLabelMultiline Whether the label should be should over multiple lines.
 */
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
        String label, String sublabel, int iconId, int suggestionId, boolean deletable,
        boolean isLabelMultiline) {
    int drawableId = iconId == 0 ? DropdownItem.NO_ICON : ResourceId.mapToDrawableId(iconId);
    array[index] = new AutofillSuggestion(
            label, sublabel, drawableId, suggestionId, deletable, isLabelMultiline);
}
 
示例6
/**
 * @param array AutofillSuggestion array that should get a new suggestion added.
 * @param index Index in the array where to place a new suggestion.
 * @param label Suggested text. The text that's going to be filled in the focused field, with a
 *              few exceptions:
 *              <ul>
 *                  <li>Credit card numbers are elided, e.g. "Visa ****-1234."</li>
 *                  <li>The text "CLEAR FORM" will clear the filled in text.</li>
 *                  <li>Empty text can be used to display only icons, e.g. for credit card scan
 *                      or editing autofill settings.</li>
 *              </ul>
 * @param sublabel Hint for the suggested text. The text that's going to be filled in the
 *                 unfocused fields of the form. If {@see label} is empty, then this must be
 *                 empty too.
 * @param iconId The resource ID for the icon associated with the suggestion, or 0 for no icon.
 * @param suggestionId Identifier for the suggestion type.
 * @param isDeletable Whether the item can be deleted by the user.
 */
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
        String label, String sublabel, int iconId, int suggestionId, boolean isDeletable) {
    int drawableId = iconId == 0 ? DropdownItem.NO_ICON : ResourceId.mapToDrawableId(iconId);
    array[index] = new AutofillSuggestion(label, sublabel, drawableId,
            false /* isIconAtStart */, suggestionId, isDeletable, false /* isMultilineLabel */,
            false /* isBoldLabel */);
}
 
示例7
/**
 * @param array AutofillSuggestion array that should get a new suggestion added.
 * @param index Index in the array where to place a new suggestion.
 * @param label First line of the suggestion.
 * @param sublabel Second line of the suggestion.
 * @param iconId The resource ID for the icon associated with the suggestion, or 0 for no icon.
 * @param isIconAtStart {@code true} if {@param iconId} is displayed before {@param label}.
 * @param suggestionId Identifier for the suggestion type.
 * @param isDeletable Whether the item can be deleted by the user.
 * @param isLabelMultiline Whether the label should be should over multiple lines.
 * @param isLabelBold true if {@param label} should be displayed in {@code Typeface.BOLD},
 * false if {@param label} should be displayed in {@code Typeface.NORMAL}.
 */
@CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
        String label, String sublabel, int iconId, boolean isIconAtStart,
        int suggestionId, boolean isDeletable, boolean isLabelMultiline, boolean isLabelBold) {
    int drawableId = iconId == 0 ? DropdownItem.NO_ICON : ResourceId.mapToDrawableId(iconId);
    array[index] = new AutofillSuggestion(label, sublabel, drawableId, isIconAtStart,
            suggestionId, isDeletable, isLabelMultiline, isLabelBold);
}