@Override protected void onPopulateEventForVirtualView(int virtualViewId, AccessibilityEvent event) { if (mVirtualViews == null || mVirtualViews.size() <= virtualViewId) { // TODO(clholgat): Remove this work around when the Android bug is fixed. // crbug.com/420177 event.setContentDescription(PLACE_HOLDER_STRING); return; } VirtualView view = mVirtualViews.get(virtualViewId); event.setContentDescription(view.getAccessibilityDescription()); event.setClassName(CompositorViewHolder.class.getName()); }
private static void populateEventFromJSON(AccessibilityEvent event, JSONObject message) { final JSONArray textArray = message.optJSONArray("text"); if (textArray != null) { for (int i = 0; i < textArray.length(); i++) event.getText().add(textArray.optString(i)); } event.setContentDescription(message.optString("description")); event.setEnabled(message.optBoolean("enabled", true)); event.setChecked(message.optBoolean("checked")); event.setPassword(message.optBoolean("password")); event.setAddedCount(message.optInt("addedCount", -1)); event.setRemovedCount(message.optInt("removedCount", -1)); event.setFromIndex(message.optInt("fromIndex", -1)); event.setItemCount(message.optInt("itemCount", -1)); event.setCurrentItemIndex(message.optInt("currentItemIndex", -1)); event.setBeforeText(message.optString("beforeText")); if (Versions.feature14Plus) { event.setToIndex(message.optInt("toIndex", -1)); event.setScrollable(message.optBoolean("scrollable")); event.setScrollX(message.optInt("scrollX", -1)); event.setScrollY(message.optInt("scrollY", -1)); } if (Versions.feature15Plus) { event.setMaxScrollX(message.optInt("maxScrollX", -1)); event.setMaxScrollY(message.optInt("maxScrollY", -1)); } }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); if (!TextUtils.isEmpty(mAccessibilityClass)) { event.setClassName(mAccessibilityClass); if (Switch.class.getName().equals(mAccessibilityClass)) { String label = getResources() .getString(!mTileState ? R.string.switch_bar_on : R.string.switch_bar_off); event.setContentDescription(label); event.setChecked(!mTileState); } } }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { if (Build.VERSION.SDK_INT >= 14) { if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { // Action mode started event.setSource(this); event.setClassName(getClass().getName()); event.setPackageName(getContext().getPackageName()); event.setContentDescription(mTitle); } else { super.onInitializeAccessibilityEvent(event); } } }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); int childCount = getChildCount(); if (childCount > 0) { TaskView backMostTask = (TaskView) getChildAt(0); TaskView frontMostTask = (TaskView) getChildAt(childCount - 1); event.setFromIndex(mStack.indexOfTask(backMostTask.getTask())); event.setToIndex(mStack.indexOfTask(frontMostTask.getTask())); event.setContentDescription(frontMostTask.getTask().activityLabel); } event.setItemCount(mStack.getTaskCount()); event.setScrollY(mStackScroller.mScroller.getCurrY()); event.setMaxScrollY(mStackScroller.progressToScrollRange(mLayoutAlgorithm.mMaxScrollP)); }
@Override protected void onPopulateEventForVirtualView(int virtualViewId, AccessibilityEvent event) { event.setContentDescription(getItemDescription(virtualViewId)); }