Java Code Examples for androidx.core.view.accessibility.AccessibilityNodeInfoCompat#ACTION_LONG_CLICK

The following examples show how to use androidx.core.view.accessibility.AccessibilityNodeInfoCompat#ACTION_LONG_CLICK . 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: KeyboardAccessibilityNodeProvider.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
/**
 * Performs the specified accessibility action for the given key.
 *
 * @param key The on which to perform the action.
 * @param action The action to perform.
 * @return The result of performing the action, or false if the action is not supported.
 */
boolean performActionForKey(final Key key, final int action) {
    switch (action) {
    case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS:
        mAccessibilityFocusedView = getVirtualViewIdOf(key);
        sendAccessibilityEventForKey(
                key, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
        return true;
    case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
        mAccessibilityFocusedView = UNDEFINED;
        sendAccessibilityEventForKey(
                key, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
        return true;
    case AccessibilityNodeInfoCompat.ACTION_CLICK:
        sendAccessibilityEventForKey(key, AccessibilityEvent.TYPE_VIEW_CLICKED);
        mDelegate.performClickOn(key);
        return true;
    case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
        sendAccessibilityEventForKey(key, AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
        mDelegate.performLongClickOn(key);
        return true;
    default:
        return false;
    }
}
 
Example 2
Source File: ActionVariables.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public boolean getBoolean(int variableId) {
  switch (variableId) {
    case ACTION_IS_CUSTOM_ACTION:
      return AccessibilityNodeInfoUtils.isCustomAction(mAction);
    case ACTION_IS_CLICK:
      return mAction.getId() == AccessibilityNodeInfoCompat.ACTION_CLICK;
    case ACTION_IS_LONG_CLICK:
      return mAction.getId() == AccessibilityNodeInfoCompat.ACTION_LONG_CLICK;
    default:
      return mParentVariables.getBoolean(variableId);
  }
}
 
Example 3
Source File: NodeActionMenuItem.java    From talkback with Apache License 2.0 5 votes vote down vote up
private static SwitchAccessMenuItemEnum.MenuItem getMenuItemForAction(SwitchAccessAction action) {
  switch (action.getId()) {
    case AccessibilityNodeInfoCompat.ACTION_CLICK:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_CLICK;
    case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_LONG_CLICK;
    case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_SCROLL_FORWARD;
    case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_SCROLL_BACKWARD;
    case AccessibilityNodeInfoCompat.ACTION_DISMISS:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_DISMISS;
    case AccessibilityNodeInfoCompat.ACTION_COLLAPSE:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_COLLAPSE;
    case AccessibilityNodeInfoCompat.ACTION_EXPAND:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_EXPAND;
    case AccessibilityNodeInfoCompat.ACTION_SET_SELECTION:
      return getMenuItemForSetSelectionAction(action);
    case AccessibilityNodeInfoCompat.ACTION_CUT:
      return getMenuItemForCutAction(action);
    case AccessibilityNodeInfoCompat.ACTION_COPY:
      return getMenuItemForCopyAction(action);
    case AccessibilityNodeInfoCompat.ACTION_PASTE:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_PASTE;
    case TextEditingUtils.ACTION_DELETE_TEXT:
      return getMenuItemForDeleteTextAction(action);
    case AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
      return getMenuItemForNextAtMovementGranularityAction(action);
    case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
      return getMenuItemForPreviousAtMovementGranularityAction(action);
    case TextEditingUtils.ACTION_UNDO:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_UNDO;
    case TextEditingUtils.ACTION_REDO:
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_REDO;
    default:
      // Other actions such as "App info", "Add to home screen" etc.
      return SwitchAccessMenuItemEnum.MenuItem.ACTION_MENU_CUSTOM_ACTION;
  }
}
 
Example 4
Source File: AccessibilityNodeInfoUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
public static String actionToString(int action) {
  switch (action) {
    case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS:
      return "ACTION_ACCESSIBILITY_FOCUS";
    case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
      return "ACTION_CLEAR_ACCESSIBILITY_FOCUS";
    case AccessibilityNodeInfoCompat.ACTION_CLEAR_FOCUS:
      return "ACTION_CLEAR_FOCUS";
    case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION:
      return "ACTION_CLEAR_SELECTION";
    case AccessibilityNodeInfoCompat.ACTION_CLICK:
      return "ACTION_CLICK";
    case AccessibilityNodeInfoCompat.ACTION_COLLAPSE:
      return "ACTION_COLLAPSE";
    case AccessibilityNodeInfoCompat.ACTION_COPY:
      return "ACTION_COPY";
    case AccessibilityNodeInfoCompat.ACTION_CUT:
      return "ACTION_CUT";
    case AccessibilityNodeInfoCompat.ACTION_DISMISS:
      return "ACTION_DISMISS";
    case AccessibilityNodeInfoCompat.ACTION_EXPAND:
      return "ACTION_EXPAND";
    case AccessibilityNodeInfoCompat.ACTION_FOCUS:
      return "ACTION_FOCUS";
    case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
      return "ACTION_LONG_CLICK";
    case AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
      return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY";
    case AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT:
      return "ACTION_NEXT_HTML_ELEMENT";
    case AccessibilityNodeInfoCompat.ACTION_PASTE:
      return "ACTION_PASTE";
    case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
      return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY";
    case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT:
      return "ACTION_PREVIOUS_HTML_ELEMENT";
    case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD:
      return "ACTION_SCROLL_BACKWARD";
    case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD:
      return "ACTION_SCROLL_FORWARD";
    case AccessibilityNodeInfoCompat.ACTION_SELECT:
      return "ACTION_SELECT";
    case AccessibilityNodeInfoCompat.ACTION_SET_SELECTION:
      return "ACTION_SET_SELECTION";
    case AccessibilityNodeInfoCompat.ACTION_SET_TEXT:
      return "ACTION_SET_TEXT";
    default:
      return "(unhandled)";
  }
}
 
Example 5
Source File: NodeActionMenuItem.java    From talkback with Apache License 2.0 4 votes vote down vote up
/** Returns an icon resource id associated with the current action. */
@Override
public int getIconResource() {
  int actionId = action.getId();
  switch (actionId) {
    case AccessibilityNodeInfoCompat.ACTION_CLICK:
      return R.drawable.ic_select;
    case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
      return R.drawable.ic_long_press;
    case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD:
      return R.drawable.ic_scroll_down;
    case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD:
      return R.drawable.ic_scroll_up;
    case AccessibilityNodeInfoCompat.ACTION_DISMISS:
      return R.drawable.ic_dismiss;
    case AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
    case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
      return R.drawable.ic_text;
    case AccessibilityNodeInfoCompat.ACTION_COLLAPSE:
      return R.drawable.ic_collapse;
    case AccessibilityNodeInfoCompat.ACTION_EXPAND:
      return R.drawable.ic_expand;
    case AccessibilityNodeInfoCompat.ACTION_SET_SELECTION:
      return R.drawable.ic_highlight_text;
    case AccessibilityNodeInfoCompat.ACTION_CUT:
      return R.drawable.ic_cut;
    case AccessibilityNodeInfoCompat.ACTION_COPY:
      return R.drawable.ic_copy;
    case AccessibilityNodeInfoCompat.ACTION_PASTE:
      return R.drawable.ic_paste;
    case TextEditingUtils.ACTION_DELETE_TEXT:
      return R.drawable.ic_delete_text;
    case TextEditingUtils.ACTION_UNDO:
      return R.drawable.ic_undo;
    case TextEditingUtils.ACTION_REDO:
      return R.drawable.ic_redo;
    default:
      // We don't know what the action is. Don't show an icon.
      return 0;
  }
}