Java Code Examples for android.view.accessibility.AccessibilityNodeInfo#ACTION_CLICK

The following examples show how to use android.view.accessibility.AccessibilityNodeInfo#ACTION_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: RadialTimePickerView.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    if (action == AccessibilityNodeInfo.ACTION_CLICK) {
        final int type = getTypeFromId(virtualViewId);
        final int value = getValueFromId(virtualViewId);
        if (type == TYPE_HOUR) {
            final int hour = mIs24HourMode ? value : hour12To24(value, mAmOrPm);
            setCurrentHour(hour);
            return true;
        } else if (type == TYPE_MINUTE) {
            setCurrentMinute(value);
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: RadialTimePickerView.java    From DateTimePicker with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    if (action == AccessibilityNodeInfo.ACTION_CLICK) {
        final int type = getTypeFromId(virtualViewId);
        final int value = getValueFromId(virtualViewId);
        if (type == TYPE_HOUR) {
            final int hour = mIs24HourMode ? value : hour12To24(value, mAmOrPm);
            setCurrentHour(hour);
            return true;
        } else if (type == TYPE_MINUTE) {
            setCurrentMinute(value);
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: MonthView.java    From StyleableDateTimePicker with MIT License 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 4
Source File: MonthView.java    From MaterialDateRangePicker with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 5
Source File: MonthView.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
                                                Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 6
Source File: MonthView.java    From AlarmOn with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 7
Source File: MonthView.java    From cathode with Apache License 2.0 5 votes vote down vote up
@Override protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
    Bundle arguments) {
  switch (action) {
    case AccessibilityNodeInfo.ACTION_CLICK:
      onDayClick(virtualViewId);
      return true;
  }

  return false;
}
 
Example 8
Source File: JellyBeanAccessibilityInjector.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean supportsAccessibilityAction(int action) {
    if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY ||
            action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY ||
            action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT ||
            action == AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT ||
            action == AccessibilityNodeInfo.ACTION_CLICK) {
        return true;
    }

    return false;
}
 
Example 9
Source File: JellyBeanAccessibilityInjector.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean supportsAccessibilityAction(int action) {
    if (action == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY ||
            action == AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY ||
            action == AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT ||
            action == AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT ||
            action == AccessibilityNodeInfo.ACTION_CLICK) {
        return true;
    }

    return false;
}
 
Example 10
Source File: TamicInstallService.java    From Autoinstall with Apache License 2.0 5 votes vote down vote up
/**
 *  performClickAction
 * @param aAccessibilityNodeInfo  aAccessibilityNodeInfo
 * @return
 */
private boolean performClickAction(AccessibilityNodeInfo aAccessibilityNodeInfo) {
    int targetAction = AccessibilityNodeInfo.ACTION_CLICK;
    if ((aAccessibilityNodeInfo != null)  && aAccessibilityNodeInfo.isEnabled() && aAccessibilityNodeInfo.isClickable()
            && aAccessibilityNodeInfo.performAction(targetAction)) {
        return true;
    }

    return false;
}
 
Example 11
Source File: MonthView.java    From BottomSheetPickers with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 12
Source File: MonthView.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
                                                Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 13
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see AccessibilityNodeProvider#performAction(int, int, Bundle)
 */
protected boolean performAction(int virtualViewId, int action, Bundle arguments) {
    if (!mAccessibilityManager.isEnabled() || mNativeObj == 0) {
        return false;
    }

    switch (action) {
        case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS:
            if (mAccessibilityFocusId == virtualViewId) {
                return true;
            }

            mAccessibilityFocusId = virtualViewId;
            sendAccessibilityEvent(mAccessibilityFocusId,
                    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
            return true;
        case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
            if (mAccessibilityFocusId == virtualViewId) {
                mAccessibilityFocusId = View.NO_ID;
            }
            return true;
        case AccessibilityNodeInfo.ACTION_CLICK:
            nativeClick(mNativeObj, virtualViewId);
            break;
        case AccessibilityNodeInfo.ACTION_FOCUS:
            nativeFocus(mNativeObj, virtualViewId);
            break;
        case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS:
            nativeBlur(mNativeObj);
            break;
        default:
            break;
    }
    return false;
}
 
Example 14
Source File: DialpadKeyButton.java    From android-dialer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
  if (action == AccessibilityNodeInfo.ACTION_CLICK) {
    simulateClickForAccessibility();
    return true;
  }

  return super.performAccessibilityAction(action, arguments);
}
 
Example 15
Source File: MonthView.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
        Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfo.ACTION_CLICK:
            onDayClick(virtualViewId);
            return true;
    }

    return false;
}
 
Example 16
Source File: MonthView.java    From PersianDateRangePicker with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
                                                Bundle arguments) {
  switch (action) {
    case AccessibilityNodeInfo.ACTION_CLICK:
      onDayClick(virtualViewId);
      return true;
  }

  return false;
}
 
Example 17
Source File: BrowserAccessibilityManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see AccessibilityNodeProvider#performAction(int, int, Bundle)
 */
protected boolean performAction(int virtualViewId, int action, Bundle arguments) {
    if (!mAccessibilityManager.isEnabled() || mNativeObj == 0) {
        return false;
    }

    switch (action) {
        case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS:
            if (mAccessibilityFocusId == virtualViewId) {
                return true;
            }

            mAccessibilityFocusId = virtualViewId;
            sendAccessibilityEvent(mAccessibilityFocusId,
                    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
            return true;
        case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
            if (mAccessibilityFocusId == virtualViewId) {
                mAccessibilityFocusId = View.NO_ID;
            }
            return true;
        case AccessibilityNodeInfo.ACTION_CLICK:
            nativeClick(mNativeObj, virtualViewId);
            break;
        case AccessibilityNodeInfo.ACTION_FOCUS:
            nativeFocus(mNativeObj, virtualViewId);
            break;
        case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS:
            nativeBlur(mNativeObj);
            break;
        default:
            break;
    }
    return false;
}
 
Example 18
Source File: DefaultNavigationMode.java    From brailleback with Apache License 2.0 4 votes vote down vote up
private boolean activateNode(AccessibilityNodeInfoCompat node,
        int position) {
    if (node == null) {
        return false;
    }
    AccessibilityNodeInfoRef current =
            AccessibilityNodeInfoRef.unOwned(node);
    try {
        do {
            LogUtils.log(this, Log.VERBOSE,
                    "Considering to click: %s",
                    current.get().getInfo());
            int supportedActions = current.get().getActions();
            int action = 0;
            // For edit texts, the click action doesn't currently focus
            // the view, so we special case it here.
            // TODO: Revise when that changes.
            if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(
                    mAccessibilityService, current.get(),
                    EditText.class)) {
                if ((supportedActions & AccessibilityNodeInfo.ACTION_FOCUS)
                        != 0) {
                    action = AccessibilityNodeInfo.ACTION_FOCUS;
                } else {
                    // Put accessibility focus on the field.  If it is
                    // already focused and the IME is selected, that will
                    // activate the editing.
                    action = AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS;
                }
            } else if (position >= 0 && isSelfBrailled(current.get())
                    && (supportedActions
                            & AccessibilityNodeInfo.ACTION_CLICK) != 0) {
                // Generate a fake "action". For instance, a click at
                // position 33 maps to -275000033.
                // TODO: Remove this hack when a better way to pass this
                // information exists.
                int fakeAction = ACTION_BRAILLE_CLICK_MAX - position;
                if (fakeAction < ACTION_BRAILLE_CLICK_MIN) {
                    LogUtils.log(this, Log.WARN,
                        "underflow activating node %s at position %d",
                        current.get(), position);
                    fakeAction = ACTION_BRAILLE_CLICK_MIN;
                } else if (fakeAction > ACTION_BRAILLE_CLICK_MAX) {
                    LogUtils.log(this, Log.WARN,
                        "overflow activating node %s at position %d",
                        current.get(), position);
                    fakeAction = ACTION_BRAILLE_CLICK_MAX;
                }
                if (WebInterfaceUtils.performSpecialAction(current.get(),
                            fakeAction)) {
                    return true;
                }
            } else if ((supportedActions
                            & AccessibilityNodeInfo.ACTION_CLICK) != 0) {
                action = AccessibilityNodeInfo.ACTION_CLICK;
            }
            if (action != 0 && current.get().performAction(action)) {
                return true;
            } else {
                LogUtils.log(this, Log.VERBOSE, "Action %d failed",
                        action);
            }
        } while (current.parent());
    } finally {
        current.recycle();
    }
    LogUtils.log(this, Log.VERBOSE, "Click action failed");
    return false;
}
 
Example 19
Source File: SwitchAccessAction.java    From talkback with Apache License 2.0 4 votes vote down vote up
@Override
public ActionResult execute(AccessibilityService service) {
  previousSelectionStart = Math.max(0, nodeCompat.getTextSelectionStart());
  previousSelectionEnd = Math.max(0, nodeCompat.getTextSelectionEnd());
  previousTextContent = TextEditingUtils.getNonDefaultTextForNode(nodeCompat);

  switch (getId()) {
    case TextEditingUtils.ACTION_DELETE_TEXT:
      // Delete text with granularity according to args.
      return new ActionResult(TextEditingUtils.deleteTextWithGranularity(nodeCompat, args));
    case AccessibilityNodeInfo.ACTION_SET_SELECTION:
      // Select text with granularity according to args.
      return new ActionResult(TextEditingUtils.selectTextWithGranularity(nodeCompat, args));
    case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
    case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
      if ((args.getInt(ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT)
          == TextEditingUtils.ACTION_GRANULARITY_SENTENCE)) {
        MovementDirection movementDirection =
            (getId() == AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY)
                ? TextEditingUtils.MovementDirection.DIRECTION_NEXT
                : TextEditingUtils.MovementDirection.DIRECTION_PREVIOUS;
        // Sentence granularity doesn't have built-in support, so move cursor by sentence
        // granularity.
        return new ActionResult(
            TextEditingUtils.moveCursorBySentenceGranularity(nodeCompat, movementDirection));
      } else {
        // Perform the original granular movement
        return new ActionResult(
            PerformActionUtils.performAction(nodeCompat, getId(), args, null /* EventId */));
      }
    case TextEditingUtils.ACTION_UNDO:
      // Undo the previous action on this node's timeline.
      return new ActionResult(TextEditingUtils.performUndo(service, nodeCompat));
    case TextEditingUtils.ACTION_REDO:
      // Redo the next action on this node's timeline.
      return new ActionResult(TextEditingUtils.performRedo(service, nodeCompat));
    case AccessibilityNodeInfo.ACTION_SET_TEXT:
      // Set the text and restore the cursor position.
      return new ActionResult(TextEditingUtils.setText(nodeCompat, args));
    case AccessibilityNodeInfo.ACTION_COPY:
    case AccessibilityNodeInfo.ACTION_CUT:
      // For copy and cut actions, select all text as these actions only act on the currently
      // selected text.
      if ((args.getInt(ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT)
              == TextEditingUtils.ACTION_GRANULARITY_ALL)
          && !TextEditingUtils.selectTextWithGranularity(nodeCompat, args)) {
        return new ActionResult(false);
      } else {
        return new ActionResult(
            PerformActionUtils.performAction(nodeCompat, getId(), args, null /* EventId */));
      }
    case AccessibilityNodeInfo.ACTION_CLICK:
      if (nodeCompat.isClickable() && attemptToClickUrl(service)) {
        return new ActionResult(true /* isSuccessful */);
      }
      // Fall-through if there were no clickable urls.
    default:
      // Perform the original user-visible action.
      return new ActionResult(
          PerformActionUtils.performAction(nodeCompat, getId(), args, null /* EventId */));
  }
}
 
Example 20
Source File: TimePickerClockDelegate.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public ClickActionDelegate(Context context, int resId) {
    mClickAction = new AccessibilityAction(
            AccessibilityNodeInfo.ACTION_CLICK, context.getString(resId));
}