List of usage examples for android.view.accessibility AccessibilityEvent getEventType
public @EventType int getEventType()
From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED == event.getEventType())) { return;//from w w w. ja v a 2 s . c o m } Log.d(Constants.TAG, "TYPE_WINDOW_CONTENT_CHANGED"); // This AccessibilityNodeInfo represents the view that fired the // AccessibilityEvent. The following code will use it to traverse the // view hierarchy, using this node as a starting point. // // NOTE: Every method that returns an AccessibilityNodeInfo may return null, // because the explored window is in another process and the // corresponding View might be gone by the time your request reaches the // view hierarchy. // AccessibilityNodeInfo source = event.getSource(); // TODO: start with "com.google.android.gm:id/conversation" ? AccessibilityNodeInfo source = getRootInActiveWindow(); if (source == null) { return; } closeOverlay(); ArrayList<AccessibilityNodeInfo> pgpNodes = new ArrayList<>(); findPgpNodeInfo(source, pgpNodes); for (final AccessibilityNodeInfo node : pgpNodes) { Log.d(Constants.TAG, "node=" + node); drawOverlay(node, new View.OnClickListener() { @Override public void onClick(View v) { decryptWithOpenKeychain(node); } }); } }
From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java
@Override public void afterEventReceived(AccessibilityEvent event) { if (mMatched) { return;//from w w w .j ava2 s.c o m } 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.talkback.formatter.CheckableClickedFormatter.java
@Override public boolean accept(AccessibilityEvent event, TalkBackService context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return false; int type = event.getEventType(); if (type == AccessibilityEvent.TYPE_VIEW_CLICKED) { mClickedNode = null;//from www . j a v a 2 s.c om mClickedTime = -1; if (event.isChecked()) { return true; } AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); AccessibilityNodeInfoCompat source = record.getSource(); if (source != null) { if (source.isCheckable()) { return true; } // it is bug in settings application that does not include clicked state on node // so we need to restore it later from TYPE_WINDOW_CONTENT_CHANGED event if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mClickedNode = source; mClickedTime = System.currentTimeMillis(); } } return false; } if (type == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return false; if (mClickedTime == -1 || mClickedNode == null) return false; long now = System.currentTimeMillis(); if ((mClickedTime + 1000) < now) { mClickedTime = -1; if (mClickedNode != null) { mClickedNode.recycle(); mClickedNode = null; } return false; } AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); AccessibilityNodeInfoCompat source = record.getSource(); return findClickedCheckableNode(source); } return false; }
From source file:com.android.screenspeak.eventprocessor.AccessibilityEventProcessor.java
/** * Manages touch exploration state./* w w w . j av a 2 s. c om*/ * * @param event The current event. */ private void maintainExplorationState(AccessibilityEvent event) { final int eventType = event.getEventType(); if (eventType == AccessibilityEventCompat.TYPE_TOUCH_EXPLORATION_GESTURE_START) { mIsUserTouchExploring = true; } else if (eventType == AccessibilityEventCompat.TYPE_TOUCH_EXPLORATION_GESTURE_END) { mIsUserTouchExploring = false; } else if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { mLastWindowStateChanged = SystemClock.uptimeMillis(); } }
From source file:net.grayswander.rotationmanager.RotationManagerService.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event == null) { debug("Null event"); return;/* w w w . j a va 2 s.c om*/ } if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { String package_name; String class_name; try { package_name = event.getPackageName().toString(); class_name = event.getClassName().toString(); } catch (Exception e) { debug("Unable to get component"); return; } ComponentName componentName = new ComponentName(package_name, class_name); Log.d("Service", "Package: " + componentName.getPackageName() + " Class: " + componentName.getClassName()); ActivityInfo activityInfo = tryGetActivity(componentName); boolean isActivity = activityInfo != null; if (!isActivity) { debug("Received event with NULL activity."); return; } debug("Received app " + package_name); if (package_name.equals(this.currentPackage)) { debug("App has not been changed"); return; } debug("App has been changed"); boolean is_rotation_enabled = this.getAutoOrientationEnabled(); debug("Rotation: " + is_rotation_enabled); if (!appStartedFullScreen) { Log.d("Service", "Saving rotation settings, as fullscreen hack is inactive"); if (is_rotation_enabled != this.lastSetRotation) { debug("Setting rotation " + is_rotation_enabled + " for " + this.currentPackage); this.configuration.setRotationSetting(this.currentPackage, is_rotation_enabled); } } else { Log.d("Service", "Not saving rotation settings, as fullscreen hack is active"); } this.appStartedFullScreen = false; if (this.configuration.isForFullscreenWatcher(package_name)) { this.startFullscreenWatcher(); } else { if (this.configuration.isForFullscreenWatcher(this.currentPackage)) { this.stopFullscreenWatcher(); } } this.currentPackage = package_name; boolean app_rotation_setting = this.getAppRotationSetting(componentName); debug("Got rotation " + app_rotation_setting + " for " + package_name); if (is_rotation_enabled != app_rotation_setting) { debug("Setting rotation " + app_rotation_setting); this.setAutoOrientationEnabled(app_rotation_setting); } } }
From source file:com.android.talkback.eventprocessor.ProcessorAccessibilityHints.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!areHintsEnabled()) { return;/*w ww . ja va 2 s .co m*/ } // Clear hints that were generated before a click or in an old window configuration. final int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_VIEW_CLICKED || eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED) { cancelA11yHint(); return; } if (eventType == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { EventState eventState = EventState.getInstance(); if (eventState.checkAndClearRecentEvent(EventState.EVENT_SKIP_HINT_AFTER_GRANULARITY_MOVE)) { return; } if (eventState.checkAndClearRecentEvent(EventState.EVENT_SKIP_HINT_AFTER_CURSOR_CONTROL)) { return; } AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); AccessibilityNodeInfoCompat source = record.getSource(); if (source != null) { postA11yHintRunnable(source); // DO NOT RECYCLE. postA11yHintRunnable will save the node. } } }
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();//from w ww . j a v a2 s . c om 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.googlecode.eyesfree.brailleback.IMENavigationMode.java
@Override public void onObserveAccessibilityEvent(AccessibilityEvent event) { if ((event.getEventType() & UPDATE_STATE_EVENT_MASK) != 0) { updateState();/* w ww.j ava 2 s . c om*/ } mNext.onObserveAccessibilityEvent(event); }
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 ava 2 s. c om*/ 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.KeyboardSearchManager.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!mNodeSearch.isActive()) { return;// w w w .ja v a 2s. co m } switch (event.getEventType()) { case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: cancelSearch(); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: if (mNodeSearch.hasMatch()) { mNodeSearch.reEvaluateSearch(); } break; default: break; } }