List of usage examples for android.view.accessibility AccessibilityEvent TYPE_VIEW_FOCUSED
int TYPE_VIEW_FOCUSED
To view the source code for android.view.accessibility AccessibilityEvent TYPE_VIEW_FOCUSED.
Click Source Link
From source file:com.android.talkback.formatter.FallbackFormatter.java
@Override public boolean format(AccessibilityEvent event, TalkBackService context, Utterance utterance) { final AccessibilityNodeInfo source = event.getSource(); // Drop events that have source nodes. if (source != null) { source.recycle();/*w w w. j av a2s . c o m*/ return false; } boolean hasEarcons = true; // Add earcons and patterns since the event doesn't have a source node switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: utterance.addHaptic(R.array.view_focused_or_selected_pattern); utterance.addAuditory(R.raw.focus_actionable); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: utterance.addHaptic(R.array.view_focused_or_selected_pattern); utterance.addAuditory(R.raw.focus_actionable); break; case AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER: utterance.addHaptic(R.array.view_hovered_pattern); utterance.addAuditory(R.raw.focus); break; default: hasEarcons = false; break; } final CharSequence text = AccessibilityEventUtils.getEventTextOrDescription(event); if (!TextUtils.isEmpty(text)) { utterance.addSpoken(text); } return hasEarcons || !utterance.getSpoken().isEmpty(); }
From source file:com.android.screenspeak.formatter.FallbackFormatter.java
@Override public boolean format(AccessibilityEvent event, ScreenSpeakService context, Utterance utterance) { final AccessibilityNodeInfo source = event.getSource(); // Drop events that have source nodes. if (source != null) { source.recycle();/* w w w . jav a 2s . co m*/ return false; } // Add earcons and patterns since the event doesn't have a source node switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_FOCUSED: utterance.addHaptic(R.array.view_focused_or_selected_pattern); utterance.addAuditory(R.raw.focus_actionable); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: utterance.addHaptic(R.array.view_focused_or_selected_pattern); utterance.addAuditory(R.raw.focus_actionable); break; case AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER: utterance.addHaptic(R.array.view_hovered_pattern); utterance.addAuditory(R.raw.focus); break; } final CharSequence text = AccessibilityEventUtils.getEventTextOrDescription(event); if (!TextUtils.isEmpty(text)) { utterance.addSpoken(text); } return true; }
From source file:com.android.messaging.util.AccessibilityUtil.java
public static void announceForAccessibilityCompat(final View view, @Nullable AccessibilityManager accessibilityManager, final CharSequence text) { final Context context = view.getContext().getApplicationContext(); if (accessibilityManager == null) { accessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); }//from ww w . j a v a 2 s . c om if (!accessibilityManager.isEnabled()) { return; } // Jelly Bean added support for speaking text verbatim final int eventType = OsUtil.isAtLeastJB() ? AccessibilityEvent.TYPE_ANNOUNCEMENT : AccessibilityEvent.TYPE_VIEW_FOCUSED; // Construct an accessibility event with the minimum recommended // attributes. An event without a class name or package may be dropped. final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.getText().add(text); event.setEnabled(view.isEnabled()); event.setClassName(view.getClass().getName()); event.setPackageName(context.getPackageName()); // JellyBean MR1 requires a source view to set the window ID. final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); record.setSource(view); // Sends the event directly through the accessibility manager. If we only supported SDK 14+ // we could have done: // getParent().requestSendAccessibilityEvent(this, event); accessibilityManager.sendAccessibilityEvent(event); }
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.aprz.easy_iosched.ui.widget.CustomRatingBar.java
@Override public void onClick(final View v) { mRating = (int) v.getTag(); drawRatingViews();//from ww w . ja va 2 s . c o m int eventType = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ? AccessibilityEvent.TYPE_ANNOUNCEMENT : AccessibilityEvent.TYPE_VIEW_FOCUSED; sendAccessibilityEvent(eventType); }
From source file:com.hrs.filltheform.dialog.FillTheFormDialog.java
private int getModelEventType(int accessibilityEventType) { switch (accessibilityEventType) { case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED: return FillTheFormDialogModel.EVENT_TYPE_VIEW_LONG_CLICKED; case AccessibilityEvent.TYPE_VIEW_CLICKED: return FillTheFormDialogModel.EVENT_TYPE_VIEW_CLICKED; case AccessibilityEvent.TYPE_VIEW_FOCUSED: return FillTheFormDialogModel.EVENT_TYPE_VIEW_FOCUSED; default:// w ww.j ava 2 s . c o m return FillTheFormDialogModel.EVENT_TYPE_UNKNOWN; } }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
@Override public void onObserveAccessibilityEvent(AccessibilityEvent event) { AccessibilityNodeInfo source = event.getSource(); if (source == null) { return;/*from w w w. ja v a 2 s. c o m*/ } 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); } }
From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mAccessibilityManager.isTouchExplorationEnabled()) { // Don't manage focus when touch exploration is disabled. return;// ww w . j ava2s . c o m } final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_CLICKED: // Prevent conflicts between lift-to-type and single tap. This // is only necessary when a CLICKED event occurs during a touch // interaction sequence (e.g. before an INTERACTION_END event), // but it isn't harmful to call more often. cancelSingleTap(); break; case AccessibilityEvent.TYPE_VIEW_FOCUSED: setFocusFromViewFocused(event, record); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: setFocusFromViewSelected(event, record); break; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: setFocusFromViewHoverEnter(record); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: handleWindowStateChange(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: handleWindowContentChanged(record); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: handleViewScrolled(event, record); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionStart(event); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionEnd(event); break; } }
From source file:com.google.android.marvin.talkback.ProcessorFocusAndSingleTap.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mAccessibilityManager.isTouchExplorationEnabled()) { // Don't manage focus when touch exploration is disabled. return;//w w w. ja v a 2 s . c o m } final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_CLICKED: // Prevent conflicts between lift-to-type and single tap. This // is only necessary when a CLICKED event occurs during a touch // interaction sequence (e.g. before an INTERACTION_END event), // but it isn't harmful to call more often. cancelSingleTap(); break; case AccessibilityEvent.TYPE_VIEW_FOCUSED: setFocusFromViewFocused(event, record); break; case AccessibilityEvent.TYPE_VIEW_SELECTED: setFocusFromViewSelected(event, record); break; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: final AccessibilityNodeInfoCompat touchedNode = record.getSource(); try { if ((touchedNode != null) && !setFocusFromViewHoverEnter(touchedNode) && FEATURE_FLAG_EMPTY_SPACE) { mHandler.sendEmptyTouchAreaFeedbackDelayed(touchedNode); } } finally { AccessibilityNodeInfoUtils.recycleNodes(touchedNode); } break; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: mHandler.cancelEmptyTouchAreaFeedback(); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: handleWindowStateChange(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: handleWindowContentChanged(record); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: handleViewScrolled(event, record); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionStart(event); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionEnd(event); break; } }
From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mAccessibilityManager.isTouchExplorationEnabled()) { // Don't manage focus when touch exploration is disabled. return;/* ww w . j ava 2 s . c o m*/ } final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_CLICKED: // Prevent conflicts between lift-to-type and single tap. This // is only necessary when a CLICKED event occurs during a touch // interaction sequence (e.g. before an INTERACTION_END event), // but it isn't harmful to call more often. cancelSingleTap(); break; case AccessibilityEvent.TYPE_VIEW_FOCUSED: case AccessibilityEvent.TYPE_VIEW_SELECTED: if (!mFirstWindowFocusManager.shouldProcessFocusEvent(event)) { return; } boolean isViewFocusedEvent = (AccessibilityEvent.TYPE_VIEW_FOCUSED == event.getEventType()); if (!setFocusOnView(record, isViewFocusedEvent)) { // It is possible that the only speakable child of source node is invisible // at the moment, but could be made visible when view scrolls, or window state // changes. Cache it now. And try to focus on the cached record on: // VIEW_SCROLLED, WINDOW_CONTENT_CHANGED, WINDOW_STATE_CHANGED. // The above 3 are the events that could affect view visibility. if (mCachedPotentiallyFocusableRecordQueue.size() == MAX_CACHED_FOCUSED_RECORD_QUEUE) { mCachedPotentiallyFocusableRecordQueue.remove().first.recycle(); } mCachedPotentiallyFocusableRecordQueue .add(new Pair<>(AccessibilityRecordCompat.obtain(record), event.getEventType())); } else { emptyCachedPotentialFocusQueue(); } break; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: final AccessibilityNodeInfoCompat touchedNode = record.getSource(); try { if ((touchedNode != null) && !setFocusFromViewHoverEnter(touchedNode)) { mHandler.sendEmptyTouchAreaFeedbackDelayed(touchedNode); } } finally { AccessibilityNodeInfoUtils.recycleNodes(touchedNode); } break; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: mHandler.cancelEmptyTouchAreaFeedback(); AccessibilityNodeInfo source = event.getSource(); if (source != null) { AccessibilityNodeInfoCompat compatSource = new AccessibilityNodeInfoCompat(source); mLastFocusedItem = AccessibilityNodeInfoCompat.obtain(compatSource); } break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: mFirstWindowFocusManager.registerWindowChange(event); handleWindowStateChange(event); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: handleWindowContentChanged(); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: handleViewScrolled(event, record); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_START: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionStart(); break; case AccessibilityEventCompat.TYPE_TOUCH_INTERACTION_END: // This event type only exists on API 17+ (JB MR1). handleTouchInteractionEnd(); break; } }