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

The following examples show how to use android.view.accessibility.AccessibilityEvent#TYPE_TOUCH_INTERACTION_END . 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: TouchExplorationInterpreter.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) {
  final boolean result;
  switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      result = handleTouchInteractionStartEvent(eventId);
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      // . In some case, framework sends a Hover_Enter event enter after
      // User_Interaction_end event. Defer the action for workaround.
      result = false;
      postDelayHandler.postDelayTouchEndAction(eventId);
      break;
    default:
      result = handleHoverEnterEvent(event, eventId);
      break;
  }
  if (result) {
    setInputTouchMode();
  }
}
 
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: ProcessorCursorState.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) {
  switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
      // Keep track of the accessibility focused EditText.
      overlay.hide();
      saveFocusedNode(AccessibilityEventCompat.asRecord(event));
      break;
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
      // On pre Android O devices, double-tap on screen will interpreted as touch down and up
      // action at the center of the focused node, which might set cursor to the middle of text if
      // the text is long enough. TalkBack overrides the cursor position to be the end of the
      // field to avoid the confusion of cursor movement. See  for details.
      if (SHOULD_HANDLE_TOUCH_EVENT) {
        // Reset the EditText cursor because focusing will snap it to the middle.
        resetNodeCursor(AccessibilityEventCompat.asRecord(event), eventId);
      }
      break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
      // Hide the overlay so it doesn't interfere with scrolling.
      overlay.hide();
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      if (SHOULD_HANDLE_TOUCH_EVENT) {
        // Show the overlay if the a11y-focused EditText is editing and we touch the screen.
        touchStart(event, eventId);
      }
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      if (SHOULD_HANDLE_TOUCH_EVENT) {
        // Hide the overlay when we stop touching the screen.
        touchEnd(event, eventId);
      }
      break;
    default: // fall out
  }
}
 
Example 4
Source File: ProcessorVolumeStream.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) {
  switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      touchingScreen = true;
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      touchingScreen = false;
      break;
    default: // fall out
  }
}
 
Example 5
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 6
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)";
  }
}