List of usage examples for android.view.accessibility AccessibilityEvent TYPE_VIEW_ACCESSIBILITY_FOCUSED
int TYPE_VIEW_ACCESSIBILITY_FOCUSED
To view the source code for android.view.accessibility AccessibilityEvent TYPE_VIEW_ACCESSIBILITY_FOCUSED.
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.screenspeak.formatter.TouchExplorationFormatter.java
/** * Formatter that returns an utterance to announce touch exploration. *///w w w . ja v a 2s .c o m @Override public boolean format(AccessibilityEvent event, ScreenSpeakService context, Utterance utterance) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED && EventState.getInstance().hasEvent(EventState.EVENT_SKIP_FOCUS_PROCESSING_AFTER_GRANULARITY_MOVE, SKIP_GRANULARITY_MOVE_FOCUS_TIMEOUT)) { EventState.getInstance().clearEvent(EventState.EVENT_SKIP_FOCUS_PROCESSING_AFTER_GRANULARITY_MOVE); return true; } final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); final AccessibilityNodeInfoCompat sourceNode = record.getSource(); final AccessibilityNodeInfoCompat focusedNode = getFocusedNode(event.getEventType(), sourceNode); // Drop the event if the source node was non-null, but the focus // algorithm decided to drop the event by returning null. if ((sourceNode != null) && (focusedNode == null)) { AccessibilityNodeInfoUtils.recycleNodes(sourceNode); return false; } LogUtils.log(this, Log.VERBOSE, "Announcing node: %s", focusedNode); // Populate the utterance. addDescription(utterance, focusedNode, event, sourceNode); addFeedback(utterance, focusedNode); // By default, touch exploration flushes all other events. utterance.getMetadata().putInt(Utterance.KEY_METADATA_QUEUING, DEFAULT_QUEUING_MODE); // Events formatted by this class should always advance continuous // reading, if active. utterance.addSpokenFlag(FeedbackItem.FLAG_ADVANCE_CONTINUOUS_READING); AccessibilityNodeInfoUtils.recycleNodes(sourceNode, focusedNode); return true; }
From source file:com.android.talkback.tutorial.TutorialLessonFragment.java
@Override public void onStart() { super.onStart(); MenuTransformer menuTransformer = mExercise.getContextMenuTransformer(); MenuActionInterceptor menuActionInterceptor = mExercise.getContextMenuActionInterceptor(); TalkBackService service = TalkBackService.getInstance(); if (service != null) { MenuManager menuManager = service.getMenuManager(); menuManager.setMenuTransformer(menuTransformer); menuManager.setMenuActionInterceptor(menuActionInterceptor); }//from w w w . j a v a 2 s . co m // We need to post the announcements delayed in order to ensure that the view changed // event gets sent beforehand. This makes the TalkBack speech response flow more logical. Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { View view = getView(); if (view == null) { // Something terrible has happened, e.g. the fragment is gone. return; } view.announceForAccessibility(getTitle()); view.announceForAccessibility(mPage.getSubtitle()); mDescription.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } }, DELAY_BEFORE_ANNOUNCE_LESSON); mExercise.onInitialized(getActivity()); }
From source file:com.googlecode.eyesfree.brailleback.BrailleMenuNavigationMode.java
@Override public boolean onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: closeMenu();//from w w w.j a v a 2s . c om return true; } // Don't let fall through. return true; }
From source file:com.android.screenspeak.eventprocessor.ProcessorPhoneticLetters.java
private boolean isKeyboardEvent(AccessibilityEvent event) { if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { return false; }//from w w w . ja v a 2s . co m if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { // For platform since lollipop, check that the current window is an // Input Method. final AccessibilityNodeInfo source = event.getSource(); if (source == null) { return false; } int windowId = source.getWindowId(); WindowManager manager = new WindowManager(); manager.setWindows(mService.getWindows()); return manager.getWindowType(windowId) == AccessibilityWindowInfo.TYPE_INPUT_METHOD; } else { // For old platforms, we can't check the window type directly, so just // manually check the classname. return event.getClassName().equals("com.android.inputmethod.keyboard.Key"); } }
From source file:com.googlecode.eyesfree.brailleback.SearchNavigationMode.java
@Override public boolean onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: DisplayManager.Content content = formatEventToBraille(event); if (content != null) { mDisplayManager.setContent(content); }//w w w.ja v a 2 s . c o m return true; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: finishSearch(); // Let it fall through so other navigation mode can // receive the window_state_changed event. return false; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: // This will re-evaluate the search and refocus if necessary. mMatchedNode.reset(AccessibilityNodeInfoUtils.refreshNode(mMatchedNode.get())); evaluateSearch(); return true; } // Don't let fall through. return true; }
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 a va 2 s . com*/ 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.talkback.formatter.TouchExplorationFormatter.java
/** * Formatter that returns an utterance to announce touch exploration. *//* w w w. j a v a 2s . com*/ @Override public boolean format(AccessibilityEvent event, TalkBackService context, Utterance utterance) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED && EventState.getInstance() .checkAndClearRecentEvent(EventState.EVENT_SKIP_FOCUS_PROCESSING_AFTER_GRANULARITY_MOVE)) { return false; } if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED && EventState.getInstance() .checkAndClearRecentEvent(EventState.EVENT_SKIP_FOCUS_PROCESSING_AFTER_CURSOR_CONTROL)) { return false; } final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); final AccessibilityNodeInfoCompat sourceNode = record.getSource(); final AccessibilityNodeInfoCompat focusedNode = getFocusedNode(event.getEventType(), sourceNode); // Drop the event if the source node was non-null, but the focus // algorithm decided to drop the event by returning null. if ((sourceNode != null) && (focusedNode == null)) { AccessibilityNodeInfoUtils.recycleNodes(sourceNode); return false; } LogUtils.log(this, Log.VERBOSE, "Announcing node: %s", focusedNode); // Transition the collection state if necessary. mCollectionState.updateCollectionInformation(focusedNode, event); // Populate the utterance. addEarconWhenAccessibilityFocusMovesToTheDivider(utterance, focusedNode); addSpeechFeedback(utterance, focusedNode, event, sourceNode); addAuditoryHapticFeedback(utterance, focusedNode); // By default, touch exploration flushes all other events. utterance.getMetadata().putInt(Utterance.KEY_METADATA_QUEUING, DEFAULT_QUEUING_MODE); // Events formatted by this class should always advance continuous // reading, if active. utterance.addSpokenFlag(FeedbackItem.FLAG_ADVANCE_CONTINUOUS_READING); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mLastFocusedWindowId = focusedNode.getWindowId(); } AccessibilityNodeInfoUtils.recycleNodes(sourceNode, focusedNode); return true; }
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;//from w w w. j a v a 2s.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.samknows.measurement.activity.SamKnowsTestViewerActivity.java
/** Called when the activity is first created. */ @Override// w w w. ja v a2 s.c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); cxt = this; Bundle b = getIntent().getExtras(); int testID = -1; if (b != null) { testID = b.getInt("testID"); } storage = CachingStorage.getInstance(); config = storage.loadScheduleConfig(); if (config == null) { config = new ScheduleConfig(); } testList = config.manual_tests; array_spinner = new String[testList.size() + 1]; array_spinner_int = new int[testList.size() + 1]; this.setTitle(R.string.running_test); // choose which test to run setContentView(R.layout.individual_stat_test); Util.initializeFonts(this); Util.overrideFonts(this, findViewById(android.R.id.content)); try { handler = new Handler() { @Override public void handleMessage(Message msg) { TextView tv = null; JSONObject message_json; message_json = (JSONObject) msg.obj; String value; int success; int testname; int status_complete; int metric; try { String type = message_json.getString(TestResult.JSON_TYPE_ID); if (type == "completed") { result = 1; SamKnowsTestViewerActivity.this.finish(); overridePendingTransition(0, 0); } if (type == "test") { testname = message_json.getInt(TestResult.JSON_TESTNUMBER); status_complete = message_json.getInt(TestResult.JSON_STATUS_COMPLETE); value = message_json.getString(TestResult.JSON_HRRESULT); if (status_complete == 100 && message_json.has(TestResult.JSON_SUCCESS)) { success = message_json.getInt(TestResult.JSON_SUCCESS); if (success == 0) { value = getString(R.string.failed); } } switch (testname) { // active metrics case TestResult.DOWNLOAD_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel1); tv = (TextView) findViewById(R.id.download_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.download) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.UPLOAD_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel2); tv = (TextView) findViewById(R.id.upload_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.upload) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.PACKETLOSS_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel3); tv = (TextView) findViewById(R.id.packetloss_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.packet_loss) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.LATENCY_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel4); tv = (TextView) findViewById(R.id.latency_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.latency) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; case TestResult.JITTER_TEST_ID: pw = (ProgressWheel) findViewById(R.id.ProgressWheel5); tv = (TextView) findViewById(R.id.jitter_result); pw.setProgress((int) (status_complete * 3.6)); pw.setContentDescription("Status " + status_complete + "%"); if (status_complete == 100) { pw.setVisibility(View.GONE); tv.setText(value); tv.setContentDescription(getString(R.string.jitter) + " " + value); tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); } else { pw.setVisibility(View.VISIBLE); tv.setText(""); } break; } } if (type == "passivemetric") { metric = message_json.getInt("metric"); value = message_json.getString("value"); switch (metric) { // passive metrics case 1: tv = (TextView) findViewById(R.id.passivemetric1); tv.setText(value); break; case 2: tv = (TextView) findViewById(R.id.passivemetric2); tv.setText(value); break; case 3: tv = (TextView) findViewById(R.id.passivemetric3); tv.setText(value); break; case 4: tv = (TextView) findViewById(R.id.passivemetric4); tv.setText(value); break; case 5: tv = (TextView) findViewById(R.id.passivemetric5); tv.setText(value); break; case 6: tv = (TextView) findViewById(R.id.passivemetric6); tv.setText(value); break; case 7: tv = (TextView) findViewById(R.id.passivemetric7); tv.setText(value); break; case 8: tv = (TextView) findViewById(R.id.passivemetric8); tv.setText(value); break; case 9: tv = (TextView) findViewById(R.id.passivemetric9); tv.setText(value); break; case 10: tv = (TextView) findViewById(R.id.passivemetric10); tv.setText(value); break; case 11: tv = (TextView) findViewById(R.id.passivemetric11); tv.setText(value); break; case 12: tv = (TextView) findViewById(R.id.passivemetric12); tv.setText(value); break; case 13: tv = (TextView) findViewById(R.id.passivemetric13); tv.setText(value); break; case 14: tv = (TextView) findViewById(R.id.passivemetric14); tv.setText(value); break; case 15: tv = (TextView) findViewById(R.id.passivemetric15); tv.setText(value); break; case 16: tv = (TextView) findViewById(R.id.passivemetric16); tv.setText(value); break; case 17: tv = (TextView) findViewById(R.id.passivemetric17); tv.setText(value); break; case 18: tv = (TextView) findViewById(R.id.passivemetric18); tv.setText(value); break; case 19: tv = (TextView) findViewById(R.id.passivemetric19); tv.setText(value); break; case 20: tv = (TextView) findViewById(R.id.passivemetric20); tv.setText(value); break; case 21: tv = (TextView) findViewById(R.id.passivemetric21); tv.setText(value); break; case 22: tv = (TextView) findViewById(R.id.passivemetric22); tv.setText(value); break; case 23: tv = (TextView) findViewById(R.id.passivemetric23); tv.setText(value); break; case 24: tv = (TextView) findViewById(R.id.passivemetric24); tv.setText(value); break; case 25: tv = (TextView) findViewById(R.id.passivemetric25); tv.setText(value); break; case 26: tv = (TextView) findViewById(R.id.passivemetric26); tv.setText(value); break; case 27: tv = (TextView) findViewById(R.id.passivemetric27); tv.setText(value); break; case 28: tv = (TextView) findViewById(R.id.passivemetric28); tv.setText(value); break; case 29: tv = (TextView) findViewById(R.id.passivemetric29); tv.setText(value); break; case 30: tv = (TextView) findViewById(R.id.passivemetric30); tv.setText(value); break; case 31: tv = (TextView) findViewById(R.id.passivemetric31); tv.setText(value); break; case 32: tv = (TextView) findViewById(R.id.passivemetric32); tv.setText(value); break; default: // } if (!value.equals("") && tv != null) { TableLayout tl1 = (TableLayout) findViewById(R.id.passive_metrics_status); tl1.setVisibility(View.GONE); TableLayout tl = (TableLayout) tv.getParent().getParent(); tl.setVisibility(View.VISIBLE); } if (value.equals("") && tv != null) { TableLayout tl = (TableLayout) tv.getParent().getParent(); tl.setVisibility(View.GONE); } } } catch (JSONException e) { Logger.e(this, e.getMessage()); } } }; launchTest(testID); } catch (Throwable t) { Logger.e(this, "handler or test failure", t); } }