List of usage examples for android.view.accessibility AccessibilityEvent setEnabled
public void setEnabled(boolean isEnabled)
From source file:com.android.inputmethod.accessibility.KeyboardAccessibilityNodeProvider.java
/** * Creates and populates an {@link AccessibilityEvent} for the specified key * and event type./*from w ww .j a v a2 s. c om*/ * * @param key A key on the host keyboard view. * @param eventType The event type to create. * @return A populated {@link AccessibilityEvent} for the key. * @see AccessibilityEvent */ public AccessibilityEvent createAccessibilityEvent(final Key key, final int eventType) { final int virtualViewId = getVirtualViewIdOf(key); final String keyDescription = getKeyDescription(key); final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.setPackageName(mKeyboardView.getContext().getPackageName()); event.setClassName(key.getClass().getName()); event.setContentDescription(keyDescription); event.setEnabled(true); final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); record.setSource(mKeyboardView, virtualViewId); return event; }
From source file:com.android.hareime.accessibility.AccessibilityEntityProvider.java
/** * Creates and populates an {@link AccessibilityEvent} for the specified key * and event type.//from w ww. j av a2s.c o m * * @param key A key on the host keyboard view. * @param eventType The event type to create. * @return A populated {@link AccessibilityEvent} for the key. * @see AccessibilityEvent */ public AccessibilityEvent createAccessibilityEvent(Key key, int eventType) { final int virtualViewId = generateVirtualViewIdForKey(key); final String keyDescription = getKeyDescription(key); final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.setPackageName(mKeyboardView.getContext().getPackageName()); event.setClassName(key.getClass().getName()); event.setContentDescription(keyDescription); event.setEnabled(true); final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); record.setSource(mKeyboardView, virtualViewId); return event; }
From source file:com.googlecode.eyesfree.testing.BaseAccessibilityInstrumentationTestCase.java
protected void waitForEventQueueSync() throws Throwable { startRecordingEvents();/*from w w w. j av a 2 s . c om*/ final AccessibilityEvent event = AccessibilityEvent.obtain(); event.setEnabled(false); event.setEventType(SYNC_EVENT_TYPE); event.setParcelableData(SYNC_PARCELABLE); // 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(mSyncEventFilter); assertNotNull("Synchronized event queue", syncedEvent); }
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 ww .j av a 2s. co 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.android.yijiang.kzx.widget.betterpickers.TouchExplorationHelper.java
private AccessibilityEvent getEventForItem(T item, int eventType) { final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); final int virtualDescendantId = getIdForItem(item); // Ensure the client has good defaults. event.setEnabled(true); // Allow the client to populate the event. populateEventForItem(item, event);/*ww w. jav a 2s . c om*/ if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) { throw new RuntimeException("You must add text or a content description in populateEventForItem()"); } // Don't allow the client to override these properties. event.setClassName(item.getClass().getName()); event.setPackageName(mParentView.getContext().getPackageName()); record.setSource(mParentView, virtualDescendantId); return event; }
From source file:com.android.utils.ExploreByTouchHelper.java
/** * Constructs and returns an {@link AccessibilityEvent} populated with * information about the specified item. * * @param virtualViewId The virtual view id for the item for which to * construct an event.//from w w w . j av a 2s. com * @param eventType The type of event to construct. * @return An {@link AccessibilityEvent} populated with information about * the specified item. */ private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType) { final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); // Ensure the client has good defaults. event.setEnabled(true); event.setClassName(mHost.getClass().getName() + DEFAULT_CLASS_NAME); // Allow the client to populate the event. populateEventForVirtualViewId(virtualViewId, event); if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) { throw new RuntimeException("You must add text or a content description in populateEventForItem()"); } // Don't allow the client to override these properties. event.setPackageName(mHost.getContext().getPackageName()); final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event); record.setSource(mHost, virtualViewId); return event; }
From source file:com.deange.datetimepicker.TouchExplorationHelper.java
private AccessibilityEvent getEventForItem(T item, int eventType) { final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); final int virtualDescendantId = getIdForItem(item); // Ensure the client has good defaults. event.setEnabled(true); // Allow the client to populate the event. populateEventForItem(item, event);//from www. j a v a 2s. c om if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) { throw new RuntimeException("You must add text or a content description in populateEventForItem()"); } // Don't allow the client to override these properties. event.setClassName(item.getClass().getName()); event.setPackageName(mParentView.getContext().getPackageName()); record.setSource(mParentView, virtualDescendantId); return event; }
From source file:com.googlecode.eyesfree.utils.ExploreByTouchHelper.java
/** * Constructs and returns an {@link AccessibilityEvent} populated with * information about the specified item. * * @param virtualViewId The virtual view id for the item for which to * construct an event.//www .j av a 2s . c o m * @param eventType The type of event to construct. * @return An {@link AccessibilityEvent} populated with information about * the specified item. */ private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType) { final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); // Ensure the client has good defaults. event.setEnabled(true); event.setClassName(mHost.getClass().getName() + DEFAULT_CLASS_NAME); // Allow the client to populate the event. populateEventForVirtualViewId(virtualViewId, event); if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) { throw new RuntimeException("You must add text or a content description in populateEventForItem()"); } // Don't allow the client to override these properties. event.setPackageName(mHost.getContext().getPackageName()); // Virtual view hierarchies are only supported in API 16+. final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event); record.setSource(mHost, virtualViewId); return event; }
From source file:org.mozilla.gecko.GeckoAppShell.java
public static void emitGeckoAccessibilityEvent(int eventType, String role, String text, String description, boolean enabled, boolean checked, boolean password) { AccessibilityManager accessibilityManager = (AccessibilityManager) GeckoApp.mAppContext .getSystemService(Context.ACCESSIBILITY_SERVICE); if (!accessibilityManager.isEnabled()) return;/* w ww. j a va 2 s .c o m*/ LayerController layerController = GeckoApp.mAppContext.getLayerController(); LayerView layerView = layerController.getView(); AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.setClassName(layerView.getClass().getName() + "$" + role); event.setPackageName(GeckoApp.mAppContext.getPackageName()); event.setEnabled(enabled); event.setChecked(checked); event.setPassword(password); event.setContentDescription(description); event.getText().add(text); accessibilityManager.sendAccessibilityEvent(event); }
From source file:com.actionbarsherlock.internal.widget.IcsAdapterView.java
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setScrollable(isScrollableForAccessibility()); View selectedView = getSelectedView(); if (selectedView != null) { event.setEnabled(selectedView.isEnabled()); }//ww w.j a va2s . c om event.setCurrentItemIndex(getSelectedItemPosition()); event.setFromIndex(getFirstVisiblePosition()); event.setToIndex(getLastVisiblePosition()); event.setItemCount(getCount()); }