org.chromium.ui.DropdownItem Java Examples

The following examples show how to use org.chromium.ui.DropdownItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutofillPopup.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example #2
Source File: AutofillKeyboardAccessoryBridge.java    From delion with Apache License 2.0 3 votes vote down vote up
/**
 * @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);
}
 
Example #3
Source File: AutofillPopupBridge.java    From delion with Apache License 2.0 3 votes vote down vote up
/**
 * @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);
}
 
Example #4
Source File: AutofillKeyboardAccessoryBridge.java    From AndroidChromium with Apache License 2.0 3 votes vote down vote up
/**
 * @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);
}
 
Example #5
Source File: AutofillPopupBridge.java    From AndroidChromium with Apache License 2.0 3 votes vote down vote up
/**
 * @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);
}
 
Example #6
Source File: AutofillKeyboardAccessoryBridge.java    From 365browser with Apache License 2.0 3 votes vote down vote up
/**
 * @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 */);
}
 
Example #7
Source File: AutofillPopupBridge.java    From 365browser with Apache License 2.0 3 votes vote down vote up
/**
 * @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);
}