Java Code Examples for androidx.core.view.accessibility.AccessibilityEventCompat#TYPE_VIEW_ACCESSIBILITY_FOCUSED

The following examples show how to use androidx.core.view.accessibility.AccessibilityEventCompat#TYPE_VIEW_ACCESSIBILITY_FOCUSED . 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: AccessibilityHintsManager.java    From talkback with Apache License 2.0 5 votes vote down vote up
/** Posts a hint about node. The hint will be spoken after the next utterance is completed. */
public void postHintForNode(AccessibilityEvent event, AccessibilityNodeInfoCompat node) {
  cancelA11yHint();

  // Store info about event that caused pending hint.
  mPendingHintSource = node;
  // The hint for a node is usually posted when the node is getting accessibility focus, thus
  // the default value for the hint event type should be TYPE_VIEW_ACCESSIBILITY_FOCUSED.
  mPendingHintEventType =
      (event != null)
          ? event.getEventType()
          : AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
  postA11yHintRunnable();
}
 
Example 2
Source File: ScrollFeedbackManager.java    From talkback with Apache License 2.0 5 votes vote down vote up
private boolean shouldIgnoreEvent(AccessibilityEvent event) {
  switch (event.getEventType()) {
    case AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
    case AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
      return true;
    case AccessibilityEventCompat.TYPE_WINDOW_CONTENT_CHANGED:
    case AccessibilityEventCompat.TYPE_VIEW_SCROLLED:
      return shouldIgnoreWindowContentChangedOrViewScrolledEvent(event);
    default:
      return false;
  }
}
 
Example 3
Source File: SwitchAccessHighlightFeedbackController.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onFocusHint(
    int eventType,
    AccessibilityNodeInfoCompat accessibilityNodeInfoCompat,
    boolean hintForcedFeedbackAudioPlaybackActive,
    boolean hintForcedFeedbackMicrophoneActive) {
  // Make sure that AccessibilityNodeInfoCompats that correspond to OverlayActionNodes have their
  // original event type, TYPE_VIEW_ACCESSIBILITY_FOCUSED. This ensures that the hint is spoken.
  //
  // When an OverlayActionNode is selected, we change the type of the accompanying event from
  // TYPE_VIEW_ACCESSIBILITY_FOCUSED to TYPE_VIEW_FOCUSED. This ensures that the hint for the
  // OverlayActionNode is not canceled because of window state changes. Here, we need to
  // convert the event type back to its original type, TYPE_VIEW_ACCESSIBILITY_FOCUSED.
  if (accessibilityNodeInfoCompat != null
      && OverlayActionNode.class.getName().equals(accessibilityNodeInfoCompat.getClassName())
      && eventType == TYPE_VIEW_FOCUSED) {
    eventType = AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
  }

  @HintEventInterpretation.HintType
  int hintEventType =
      (eventType == TYPE_VIEW_FOCUSED)
          ? HintEventInterpretation.HINT_TYPE_INPUT_FOCUS
          : HintEventInterpretation.HINT_TYPE_ACCESSIBILITY_FOCUS;
  HintEventInterpretation hintInterp = new HintEventInterpretation(hintEventType);
  hintInterp.setForceFeedbackAudioPlaybackActive(hintForcedFeedbackAudioPlaybackActive);
  hintInterp.setForceFeedbackMicropphoneActive(hintForcedFeedbackMicrophoneActive);
  EventInterpretation eventInterp = new EventInterpretation(Compositor.EVENT_SPEAK_HINT);
  eventInterp.setHint(hintInterp);
  eventInterp.setHasMultipleSwitchAccessActions(currentNodeHasMultipleActions);

  // Send event to compositor to speak feedback.
  compositor.handleEvent(accessibilityNodeInfoCompat, EVENT_ID_UNTRACKED, eventInterp);
  isLastSpeech = true;
}