List of usage examples for android.view.accessibility AccessibilityEvent getSource
public AccessibilityNodeInfo getSource()
From source file:com.android.screenspeak.eventprocessor.ProcessorScrollPosition.java
/** * Given an {@link AccessibilityEvent}, speaks a scroll position. * * @param event The source event./*w w w . j a v a2 s . co m*/ */ private void handleScrollFeedback(AccessibilityEvent event) { final CharSequence text = getDescriptionForScrollEvent(event); if (TextUtils.isEmpty(text)) { return; } // don't pronounce non-visible nodes AccessibilityNodeInfo node = event.getSource(); if (node != null && !node.isVisibleToUser()) { return; } // Use QUEUE mode so that we don't interrupt more important messages. mSpeechController.speak(text, SpeechController.QUEUE_MODE_QUEUE, 0, mSpeechParams); }
From source file:com.googlecode.eyesfree.brailleback.BrailleBackService.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { LogUtils.log(this, Log.VERBOSE, "Event: %s", event.toString()); LogUtils.log(this, Log.VERBOSE, "Node: %s", event.getSource()); if (mIMEHelper != null) { mIMEHelper.onAccessibilityEvent(event); }/*from w ww . j a va2 s. c o m*/ if (mModeSwitcher != null) { mModeSwitcher.onObserveAccessibilityEvent(event); mModeSwitcher.onAccessibilityEvent(event); } if (mLabelManager != null) { mLabelManager.onAccessibilityEvent(event); } }
From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java
@Override public void onObserveAccessibilityEvent(AccessibilityEvent event) { AccessibilityNodeInfo source = event.getSource(); if (source == null) { return;/* w w w.ja v a2s . 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.android.talkback.eventprocessor.ProcessorScreen.java
private int getWindowId(AccessibilityEvent event) { AccessibilityNodeInfo node = event.getSource(); if (node == null) { return WINDOW_ID_NONE; }// w w w. j a va 2 s . c om int windowId = node.getWindowId(); node.recycle(); return windowId; }
From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java
@Override public void afterEventReceived(AccessibilityEvent event) { if (mMatched) { return;/* w ww . j a v a 2 s .com*/ } if (event.getEventType() == mMatchEventType) { if (mMatchNode == null) { mMatched = true; } else { AccessibilityNodeInfoCompat eventNode = new AccessibilityNodeInfoCompat(event.getSource()); mMatched = mMatchNode.equals(eventNode); } } }
From source file:com.android.screenspeak.eventprocessor.ProcessorPhoneticLetters.java
private boolean isKeyboardEvent(AccessibilityEvent event) { if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { return false; }//w w w. j ava 2s.c o 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.android.talkback.eventprocessor.ProcessorScreen.java
private int getWindowType(AccessibilityEvent event) { if (event == null) { return WINDOW_TYPE_NONE; }/*from w ww . j a v a 2 s .co m*/ AccessibilityNodeInfo nodeInfo = event.getSource(); if (nodeInfo == null) { return WINDOW_TYPE_NONE; } AccessibilityNodeInfoCompat nodeInfoCompat = new AccessibilityNodeInfoCompat(nodeInfo); AccessibilityWindowInfoCompat windowInfoCompat = nodeInfoCompat.getWindow(); if (windowInfoCompat == null) { nodeInfoCompat.recycle(); return WINDOW_TYPE_NONE; } int windowType = windowInfoCompat.getType(); windowInfoCompat.recycle(); nodeInfoCompat.recycle(); return windowType; }
From source file:com.googlecode.eyesfree.testing.BaseAccessibilityInstrumentationTestCase.java
/** * Finds an {@link android.view.accessibility.AccessibilityNodeInfo} by View id in the active window. * The search is performed from the root node. * * @param viewId The id of a View.//from w w w . j ava2s. c o m * @return An {@link android.view.accessibility.AccessibilityNodeInfo} if found, null otherwise. */ protected final AccessibilityNodeInfo findAccessibilityNodeInfoByViewIdInActiveWindow(int viewId) { startRecordingEvents(); final View view = getViewForId(viewId); assertNotNull("Obtain view from activity", view); final AccessibilityEvent event = AccessibilityEvent.obtain(); event.setEnabled(false); event.setEventType(NODE_INFO_EVENT_TYPE); event.setParcelableData(SYNC_PARCELABLE); event.setSource(view); // Sending the event through the manager sets the event time and // may clear the source node. Only certain event types can be // dispatched (see the framework's AccessibilityManagerService // canDispatchAccessibilityEvent() method). mManager.sendAccessibilityEvent(event); final AccessibilityEvent syncedEvent = stopRecordingEventsAfter(mNodeInfoEventFilter); assertNotNull("Synchronized event queue", syncedEvent); final AccessibilityNodeInfo sourceNode = syncedEvent.getSource(); assertNotNull("Obtained source node from event", sourceNode); return sourceNode; }
From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java
private AccessibilityNodeInfoCompat getNodeFromEvent(AccessibilityEvent event) { AccessibilityNodeInfo node = event.getSource(); if (node != null) { return new AccessibilityNodeInfoCompat(node); } else {/* w w w . j av a2s. co m*/ return null; } }
From source file:com.linroid.pushapp.service.ApkAutoInstallService.java
private void onProcessAccessibilityEvent(AccessibilityEvent event) { if (event.getSource() == null) { return;/*from w w w . j a va 2 s . com*/ } String packageName = event.getPackageName().toString(); String className = event.getClassName().toString(); String sourceText = event.getSource().getText() == null ? BuildConfig.VERSION_NAME : event.getSource().getText().toString().trim(); if (packageName.equals(CLASS_NAME_PACKAGE_INSTALLER) || packageName.equals(CLASS_NAME_GOOGLE_PACKAGE_INSTALLER)) { if (isApplicationInstallEvent(event, className, sourceText)) { // onApplicationInstall(event); } else if (hasAccessibilityNodeInfoByText(event, getString(R.string.str_accessibility_install_blocked))) { // onApplicationInstall(event, false); } else if (isApplicationInstalledEvent(event, className, sourceText)) { // ? onApplicationInstalled(event); } else if (isApplicationInstallFailedEvent(event, className, sourceText)) { // onInstallFail(event); } else if (className.equalsIgnoreCase(CLASS_NAME_APP_ALERT_DIALOG)) { // ?? processAlertDialogEvent(event, className, sourceText); } else if (isApplicationUninstallEvent(event, className, sourceText)) { // ? onApplicationUninstall(event); } else if (isApplicationUninstalledEvent(event, className, sourceText)) { // ?? onApplicationUninstalled(event); } } else if (packageName.equals(CLASS_NAME_LENOVO_SAFECENTER)) { processLenovoEvent(event, className, sourceText); } }