List of usage examples for android.support.v4.view.accessibility AccessibilityNodeInfoCompat obtain
public static AccessibilityNodeInfoCompat obtain(AccessibilityNodeInfoCompat info)
From source file:Main.java
/** * Returns the root node of the tree containing {@code node}. *//*from w w w . jav a 2 s .c om*/ public static AccessibilityNodeInfoCompat getRoot(AccessibilityNodeInfoCompat node) { if (node == null) { return null; } AccessibilityNodeInfoCompat current = null; AccessibilityNodeInfoCompat parent = AccessibilityNodeInfoCompat.obtain(node); do { current = parent; parent = current.getParent(); } while (parent != null); return current; }
From source file:com.googlecode.eyesfree.utils.TreeDebug.java
/** * Logs the tree using the input node as the root. *///w w w . ja v a 2 s . co m public static void logNodeTree(AccessibilityNodeInfoCompat node) { if (node == null) { return; } HashSet<AccessibilityNodeInfoCompat> seen = new HashSet<AccessibilityNodeInfoCompat>(); logNodeTree(AccessibilityNodeInfoCompat.obtain(node), "", seen); for (AccessibilityNodeInfoCompat n : seen) { n.recycle(); } }
From source file:com.android.utils.TreeDebug.java
/** * Logs the tree using the input node as the root. *//* ww w. j a va 2s.c o m*/ public static void logNodeTree(AccessibilityNodeInfoCompat node) { if (node == null) { return; } HashSet<AccessibilityNodeInfoCompat> seen = new HashSet<>(); logNodeTree(AccessibilityNodeInfoCompat.obtain(node), "", seen); for (AccessibilityNodeInfoCompat n : seen) { n.recycle(); } }
From source file:com.google.android.marvin.mytalkback.formatter.ProgressBarFormatter.java
public static void updateRecentlyExplored(AccessibilityNodeInfoCompat node) { if (sRecentlyExplored != null) { sRecentlyExplored.recycle();/*from ww w. j a v a 2 s.com*/ } if (node != null) { sRecentlyExplored = AccessibilityNodeInfoCompat.obtain(node); } else { sRecentlyExplored = null; } }
From source file:com.googlecode.eyesfree.brailleback.DisplaySpans.java
/** * Marks the whole of {@code spannable} as containing the content * coming from {@code node}. A copy of {@code node} is stored. * * @see #recycleSpans//from www . j a v a 2s . c o m */ public static void setAccessibilityNode(Spannable spannable, AccessibilityNodeInfoCompat node) { spannable.setSpan(AccessibilityNodeInfoCompat.obtain(node), 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }
From source file:com.android.screenspeak.SavedNode.java
public void saveNodeState(AccessibilityNodeInfoCompat node, CursorGranularity granularity) { if (node == null) { return;//from www . j a v a 2 s .c o m } mNode = AccessibilityNodeInfoCompat.obtain(node); mGranularity = granularity; mSelection = findSelectionForNode(node); }
From source file:com.android.utils.traversal.SimpleTraversalStrategy.java
@Override public AccessibilityNodeInfoCompat focusInitial(AccessibilityNodeInfoCompat root, @SearchDirection int direction) { if (root == null) { return null; }/* w ww . j a v a 2 s .c om*/ if (direction == SEARCH_FOCUS_FORWARD) { return AccessibilityNodeInfoCompat.obtain(root); } else if (direction == SEARCH_FOCUS_BACKWARD) { AccessibilityNodeInfoRef ref = AccessibilityNodeInfoRef.obtain(root); if (ref.lastDescendant()) { return ref.get(); } else { ref.recycle(); return null; } } return null; }
From source file:com.android.utils.traversal.OrderedTraversalStrategy.java
public OrderedTraversalStrategy(AccessibilityNodeInfoCompat rootNode) { if (rootNode != null) { mRootNode = AccessibilityNodeInfoCompat.obtain(rootNode); }// www. j a v a 2s . co m mSpeakingNodesCache = new HashMap<>(); mController = new OrderedTraversalController(); mController.setSpeakNodesCache(mSpeakingNodesCache); mController.initOrder(mRootNode, false); }
From source file:com.google.android.marvin.mytalkback.menurules.RuleEditText.java
@Override public List<RadialMenuItem> getMenuItemsForNode(TalkBackService service, AccessibilityNodeInfoCompat node) { final AccessibilityNodeInfoCompat nodeCopy = AccessibilityNodeInfoCompat.obtain(node); final CursorController cursorController = service.getCursorController(); final List<RadialMenuItem> items = new LinkedList<RadialMenuItem>(); // This action has inconsistencies with EditText nodes that have // contentDescription attributes. if (TextUtils.isEmpty(nodeCopy.getContentDescription())) { if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY)) { final RadialMenuItem moveToBeginning = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_move_to_beginning, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_move_to_beginning)); items.add(moveToBeginning);// ww w .j av a 2s . co m } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY)) { final RadialMenuItem moveToEnd = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_move_to_end, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_move_to_end)); items.add(moveToEnd); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_CUT)) { final RadialMenuItem cut = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_cut, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_cut)); items.add(cut); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_COPY)) { final RadialMenuItem copy = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_copy, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_copy)); items.add(copy); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_PASTE)) { final RadialMenuItem paste = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_paste, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_paste)); items.add(paste); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_SET_SELECTION)) { final RadialMenuItem select = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_select_all, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_select_all)); items.add(select); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // Text selection APIs are available in API 18+ // TODO(caseyburkhardt) Use a checkable menu item once supported. final RadialMenuItem selectionMode; if (cursorController.isSelectionModeActive()) { selectionMode = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_end_selection_mode, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_end_selection_mode)); } else { selectionMode = new RadialMenuItem(service, RadialMenu.NONE, R.id.edittext_breakout_start_selection_mode, RadialMenu.NONE, service.getString(R.string.title_edittext_breakout_start_selection_mode)); } items.add(selectionMode); } } for (MenuItem item : items) { item.setOnMenuItemClickListener(new EditTextMenuItemClickListener(service, nodeCopy)); } return items; }
From source file:com.android.screenspeak.menurules.RuleEditText.java
@Override public List<ContextMenuItem> getMenuItemsForNode(ScreenSpeakService service, ContextMenuItemBuilder menuItemBuilder, AccessibilityNodeInfoCompat node) { final AccessibilityNodeInfoCompat nodeCopy = AccessibilityNodeInfoCompat.obtain(node); final CursorController cursorController = service.getCursorController(); final List<ContextMenuItem> items = new LinkedList<>(); // This action has inconsistencies with EditText nodes that have // contentDescription attributes. if (TextUtils.isEmpty(nodeCopy.getContentDescription())) { if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY)) { ContextMenuItem moveToBeginning = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_move_to_beginning, Menu.NONE, service.getString(R.string.title_edittext_breakout_move_to_beginning)); items.add(moveToBeginning);//from ww w .j a v a 2 s. c om } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY)) { ContextMenuItem moveToEnd = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_move_to_end, Menu.NONE, service.getString(R.string.title_edittext_breakout_move_to_end)); items.add(moveToEnd); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_CUT)) { ContextMenuItem cut = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_cut, Menu.NONE, service.getString(android.R.string.cut)); items.add(cut); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_COPY)) { ContextMenuItem copy = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_copy, Menu.NONE, service.getString(android.R.string.copy)); items.add(copy); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_PASTE)) { ContextMenuItem paste = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_paste, Menu.NONE, service.getString(android.R.string.paste)); items.add(paste); } if (AccessibilityNodeInfoUtils.supportsAnyAction(nodeCopy, AccessibilityNodeInfoCompat.ACTION_SET_SELECTION)) { ContextMenuItem select = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_select_all, Menu.NONE, service.getString(android.R.string.selectAll)); items.add(select); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // Text selection APIs are available in API 18+ // TODO(CB) Use a checkable menu item once supported. final ContextMenuItem selectionMode; if (cursorController.isSelectionModeActive()) { selectionMode = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_end_selection_mode, Menu.NONE, service.getString(R.string.title_edittext_breakout_end_selection_mode)); } else { selectionMode = menuItemBuilder.createMenuItem(service, Menu.NONE, R.id.edittext_breakout_start_selection_mode, Menu.NONE, service.getString(R.string.title_edittext_breakout_start_selection_mode)); } items.add(selectionMode); } } for (ContextMenuItem item : items) { item.setOnMenuItemClickListener(new EditTextMenuItemClickListener(service, nodeCopy)); } return items; }