Java Code Examples for android.view.textclassifier.TextClassifier#TYPE_UNKNOWN

The following examples show how to use android.view.textclassifier.TextClassifier#TYPE_UNKNOWN . 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: SmartSelectionEventTracker.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a "selection modified" event.
 * Use when a TextClassifier modifies the selection.
 *
 * @param start  the start word (inclusive) index of the selection
 * @param end  the end word (exclusive) index of the selection
 * @param selection  the TextSelection object returned by the TextClassifier for the
 *      specified selection
 */
public static SelectionEvent selectionModified(
        int start, int end, @NonNull TextSelection selection) {
    final boolean smartSelection = getSourceClassifier(selection.getId())
            .equals(TextClassifier.DEFAULT_LOG_TAG);
    final int eventType;
    if (smartSelection) {
        eventType = end - start > 1
                ? EventType.SMART_SELECTION_MULTI
                : EventType.SMART_SELECTION_SINGLE;

    } else {
        eventType = EventType.AUTO_SELECTION;
    }
    final String entityType = selection.getEntityCount() > 0
            ? selection.getEntity(0)
            : TextClassifier.TYPE_UNKNOWN;
    final String versionTag = getVersionInfo(selection.getId());
    return new SelectionEvent(start, end, eventType, entityType, versionTag);
}
 
Example 2
Source File: SmartSelectionEventTracker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a "selection modified" event.
 * Use when the user modifies the selection and the selection's entity type is known.
 *
 * @param start  the start word (inclusive) index of the selection
 * @param end  the end word (exclusive) index of the selection
 * @param classification  the TextClassification object returned by the TextClassifier that
 *      classified the selected text
 */
public static SelectionEvent selectionModified(
        int start, int end, @NonNull TextClassification classification) {
    final String entityType = classification.getEntityCount() > 0
            ? classification.getEntity(0)
            : TextClassifier.TYPE_UNKNOWN;
    final String versionTag = getVersionInfo(classification.getId());
    return new SelectionEvent(
            start, end, EventType.SELECTION_MODIFIED, entityType, versionTag);
}
 
Example 3
Source File: SmartSelectionEventTracker.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a "selection started" event.
 *
 * @param start  the word index of the selected word
 */
public static SelectionEvent selectionStarted(int start) {
    return new SelectionEvent(
            start, start + 1, EventType.SELECTION_STARTED,
            TextClassifier.TYPE_UNKNOWN, NO_VERSION_TAG);
}
 
Example 4
Source File: SmartSelectionEventTracker.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Creates an event specifying an action taken on a selection.
 * Use when the user clicks on an action to act on the selected text and the selection's
 * entity type is known.
 *
 * @param start  the start word (inclusive) index of the selection
 * @param end  the end word (exclusive) index of the selection
 * @param actionType  the action that was performed on the selection
 * @param classification  the TextClassification object returned by the TextClassifier that
 *      classified the selected text
 */
public static SelectionEvent selectionAction(
        int start, int end, @ActionType int actionType,
        @NonNull TextClassification classification) {
    final String entityType = classification.getEntityCount() > 0
            ? classification.getEntity(0)
            : TextClassifier.TYPE_UNKNOWN;
    final String versionTag = getVersionInfo(classification.getId());
    return new SelectionEvent(start, end, actionType, entityType, versionTag);
}
 
Example 5
Source File: SmartSelectionEventTracker.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a "selection modified" event.
 * Use when the user modifies the selection.
 *
 * @param start  the start word (inclusive) index of the selection
 * @param end  the end word (exclusive) index of the selection
 */
public static SelectionEvent selectionModified(int start, int end) {
    return new SelectionEvent(
            start, end, EventType.SELECTION_MODIFIED,
            TextClassifier.TYPE_UNKNOWN, NO_VERSION_TAG);
}
 
Example 6
Source File: SmartSelectionEventTracker.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an event specifying an action taken on a selection.
 * Use when the user clicks on an action to act on the selected text.
 *
 * @param start  the start word (inclusive) index of the selection
 * @param end  the end word (exclusive) index of the selection
 * @param actionType  the action that was performed on the selection
 */
public static SelectionEvent selectionAction(
        int start, int end, @ActionType int actionType) {
    return new SelectionEvent(
            start, end, actionType, TextClassifier.TYPE_UNKNOWN, NO_VERSION_TAG);
}