Java Code Examples for android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_ENTER

The following examples show how to use android.view.accessibility.AccessibilityEvent#TYPE_VIEW_HOVER_ENTER . 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: TreeDebugNavigationMode.java    From brailleback with Apache License 2.0 6 votes vote down vote up
@Override
public void onObserveAccessibilityEvent(AccessibilityEvent event) {
    AccessibilityNodeInfo source = event.getSource();
    if (source == null) {
        return;
    }
    boolean isNewWindow = false;
    if (mCurrentNode == null ||
            mCurrentNode.getWindowId() != source.getWindowId()) {
        isNewWindow = true;
    }
    int t = event.getEventType();
    boolean isInterestingEventType = false;
    if (t == AccessibilityEvent.TYPE_VIEW_SELECTED
            || t == AccessibilityEvent.TYPE_VIEW_FOCUSED
            || t == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            || t != AccessibilityEvent.TYPE_VIEW_HOVER_ENTER) {
        isInterestingEventType = true;
    }
    if (isNewWindow || isInterestingEventType) {
        setPendingNode(source);
    }
}
 
Example 2
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
public static int[] getAllEventTypes() {
  return new int[] {
    AccessibilityEvent.TYPE_ANNOUNCEMENT,
    AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_END,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_START,
    AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_START,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED,
    AccessibilityEvent.TYPE_VIEW_CLICKED,
    AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED,
    AccessibilityEvent.TYPE_VIEW_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
    AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
    AccessibilityEvent.TYPE_VIEW_LONG_CLICKED,
    AccessibilityEvent.TYPE_VIEW_SCROLLED,
    AccessibilityEvent.TYPE_VIEW_SELECTED,
    AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
    AccessibilityEvent.TYPE_WINDOWS_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
  };
}
 
Example 3
Source File: TutorialMainFragment.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) {
  if (offButton == null || parentLayout == null) {
    return;
  }

  // There are three types of areas that we're detecting: the button area, areas of the
  // activity that are a11y-focusable, and areas of the activity that are blank.
  // 1) The HoverTrackingButton keeps track of the button area.
  // 2) The HoverTrackingLinearLayout keeps track of blank activity areas.
  // 3) We use TYPE_VIEW_HOVER_ENTER to track a11y-focusable activity areas.
  // The user must begin and end the touch interaction within the Turn TalkBack Off button
  // without moving their finger into other areas of the activity in order to turn TB off.

  switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      otherViewHovered = false;
      offButton.clearTracking();
      parentLayout.clearTracking();
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      if (offButton.didHoverEnter() && !parentLayout.didHoverEnter() && !otherViewHovered) {
        if (TalkBackService.getInstance() != null) {
          TalkBackService.getInstance().disableTalkBackFromTutorial((EventId) null);
        }
      }
      break;
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
      CharSequence className = event.getClassName();
      // Hovering over the button gives an event with TUTORIAL_CLASS_NAME class.
      // But empty areas of the activity should be tracked by HoverTrackingLinearLayout.
      if (className == null || !className.equals(TUTORIAL_CLASS_NAME)) {
        otherViewHovered = true;
      }
      break;
    default: // fall out
  }
}
 
Example 4
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
public static String typeToString(int eventType) {
  switch (eventType) {
    case AccessibilityEvent.TYPE_ANNOUNCEMENT:
      return "TYPE_ANNOUNCEMENT";
    case AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT:
      return "TYPE_ASSIST_READING_CONTEXT";
    case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
      return "TYPE_GESTURE_DETECTION_END";
    case AccessibilityEvent.TYPE_GESTURE_DETECTION_START:
      return "TYPE_GESTURE_DETECTION_START";
    case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
      return "TYPE_NOTIFICATION_STATE_CHANGED";
    case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END:
      return "TYPE_TOUCH_EXPLORATION_GESTURE_END";
    case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START:
      return "TYPE_TOUCH_EXPLORATION_GESTURE_START";
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      return "TYPE_TOUCH_INTERACTION_END";
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      return "TYPE_TOUCH_INTERACTION_START";
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
      return "TYPE_VIEW_ACCESSIBILITY_FOCUSED";
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
      return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED";
    case AccessibilityEvent.TYPE_VIEW_CLICKED:
      return "TYPE_VIEW_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED:
      return "TYPE_VIEW_CONTEXT_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
      return "TYPE_VIEW_FOCUSED";
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
      return "TYPE_VIEW_HOVER_ENTER";
    case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT:
      return "TYPE_VIEW_HOVER_EXIT";
    case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED:
      return "TYPE_VIEW_LONG_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
      return "TYPE_VIEW_SCROLLED";
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
      return "TYPE_VIEW_SELECTED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
      return "TYPE_VIEW_TEXT_CHANGED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
      return "TYPE_VIEW_TEXT_SELECTION_CHANGED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
      return "TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY";
    case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
      return "TYPE_WINDOWS_CHANGED";
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
      return "TYPE_WINDOW_CONTENT_CHANGED";
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
      return "TYPE_WINDOW_STATE_CHANGED";
    default:
      return "(unhandled)";
  }
}