List of usage examples for android.view.accessibility AccessibilityEvent TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
int TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
To view the source code for android.view.accessibility AccessibilityEvent TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED.
Click Source Link
From source file:com.android.utils.AccessibilityEventUtils.java
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 }; }
From source file:com.android.yijiang.kzx.widget.betterpickers.TouchExplorationHelper.java
@Override public boolean performAction(int virtualViewId, int action, Bundle arguments) { if (virtualViewId == View.NO_ID) { return ViewCompat.performAccessibilityAction(mParentView, action, arguments); }/*from w ww. j ava 2 s . c om*/ final T item = getItemForId(virtualViewId); if (item == null) { return false; } boolean handled = false; switch (action) { case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS: if (mFocusedItemId != virtualViewId) { mFocusedItemId = virtualViewId; sendEventForItem(item, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); handled = true; } break; case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS: if (mFocusedItemId == virtualViewId) { mFocusedItemId = INVALID_ID; sendEventForItem(item, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED); handled = true; } break; } handled |= performActionForItem(item, action, arguments); return handled; }
From source file:com.android.screenspeak.eventprocessor.AccessibilityEventProcessor.java
public void onAccessibilityEvent(AccessibilityEvent event) { if (mTestingListener != null) { mTestingListener.onAccessibilityEvent(event); }//from ww w .j a v a2 s . c o m // Chrome clears and set a11y focus for each scroll event, it is not intended to be spoken // to the user. Remove this when chromium is fixed. int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED) { if (sGetSourceNodeIdMethod != null) { try { mLastClearedSourceId = (long) sGetSourceNodeIdMethod.invoke(event); mLastClearedWindowId = event.getWindowId(); mLastClearA11yFocus = System.currentTimeMillis(); if (mLastClearedSourceId != mLastPronouncedSourceId || mLastClearedWindowId != mLastPronouncedWindowId) { // something strange. not accessibility focused node sends clear focus event // b/22108305 mLastClearedSourceId = -1; mLastClearedWindowId = -1; mLastClearA11yFocus = 0; } } catch (Exception e) { Log.d(LOGTAG, "Exception accessing field: " + e.toString()); } } return; } if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { if (System.currentTimeMillis() - mLastClearA11yFocus < CLEAR_SET_A11Y_FOCUS_WINDOW) { if (sGetSourceNodeIdMethod != null) { try { long sourceId = (long) sGetSourceNodeIdMethod.invoke(event); int windowId = event.getWindowId(); if (sourceId == mLastClearedSourceId && windowId == mLastClearedWindowId) { return; } mLastPronouncedSourceId = sourceId; mLastPronouncedWindowId = windowId; } catch (Exception e) { Log.d(LOGTAG, "Exception accessing field: " + e.toString()); } } } } if (shouldDropEvent(event)) { return; } maintainExplorationState(event); if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED) { mService.setRootDirty(true); } processEvent(event); }
From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessor.java
/** * Returns whether the device should drop this event due to refocus issue. * Sometimes TalkBack will receive four consecutive events from one single node:. * 1. Accessibility_Focus_Cleared// w ww . ja va2 s . co m * 2. Accessibility_Focused * 3. Accessibility_Focus_Cleared * 4. Accessibility_Focused * <p/> * The cause of this issue could be: * i. Chrome clears and set a11y focus for each scroll event. * If it is an action to navigate to previous/next element and causes view scrolling. The * first two events are caused by navigation, and the last two events are caused by chrome * refocus issue. The last two events are not intended to be spoken. * If it is a scroll action. It might cause a lot of a11y_focus_cleared and a11y_focused * events. In this case all the events are not intended to be spoken. * <p/> * ii. User taps on screen to refocus on the a11y focused node. In this case event 2 and 4 * should be spoken to the user. * * @param event The current event. * @return {@code true} if the event should be dropped. */ private boolean shouldDropRefocusEvent(AccessibilityEvent event) { int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED) { if (sGetSourceNodeIdMethod != null) { try { mLastClearedSourceId = (long) sGetSourceNodeIdMethod.invoke(event); mLastClearedWindowId = event.getWindowId(); mLastClearA11yFocus = System.currentTimeMillis(); if (mLastClearedSourceId != mLastPronouncedSourceId || mLastClearedWindowId != mLastPronouncedWindowId || mProcessorFocusAndSingleTap.isFromRefocusAction(event)) { // something strange. not accessibility focused node sends clear focus event // BUG mLastClearedSourceId = -1; mLastClearedWindowId = -1; mLastClearA11yFocus = 0; } } catch (Exception e) { Log.d(LOGTAG, "Exception accessing field: " + e.toString()); } } return true; } if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { if (sGetSourceNodeIdMethod != null && !EventState.getInstance().checkAndClearRecentEvent(EventState.EVENT_NODE_REFOCUSED)) { try { long sourceId = (long) sGetSourceNodeIdMethod.invoke(event); int windowId = event.getWindowId(); // If this event is fired by the "clear and set a11y focus" issue of Chrome, // ignore and don't speak to the user, otherwise update the node and window IDs // and then process the event. if (System.currentTimeMillis() - mLastClearA11yFocus < CLEAR_SET_A11Y_FOCUS_WINDOW && sourceId == mLastClearedSourceId && windowId == mLastClearedWindowId) { return true; } else { mLastPronouncedSourceId = sourceId; mLastPronouncedWindowId = windowId; } } catch (Exception e) { Log.d(LOGTAG, "Exception accessing field: " + e.toString()); } } } return false; }
From source file:com.android.talkback.eventprocessor.ProcessorFocusAndSingleTap.java
public boolean isFromRefocusAction(AccessibilityEvent event) { long eventTime = event.getEventTime(); int eventType = event.getEventType(); if (eventType != AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED && eventType != AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED) { return false; }/*from w w w. j a va2s .c o m*/ AccessibilityNodeInfo source = event.getSource(); try { return mLastRefocusStartTime < eventTime && (mLastRefocusEndTime > eventTime || mLastRefocusEndTime < mLastRefocusStartTime) && mLastRefocusedNode != null && mLastRefocusedNode.getInfo().equals(source); } finally { if (source != null) { source.recycle(); } } }