@TargetApi(21) @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(DefaultTimeBar.class.getCanonicalName()); info.setContentDescription(getProgressText()); if (duration <= 0) { return; } if (Util.SDK_INT >= 21) { info.addAction(AccessibilityAction.ACTION_SCROLL_FORWARD); info.addAction(AccessibilityAction.ACTION_SCROLL_BACKWARD); } else if (Util.SDK_INT >= 16) { info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); } }
public LauncherAccessibilityDelegate(Launcher launcher) { mLauncher = launcher; mActions.put(REMOVE, new AccessibilityAction(REMOVE, launcher.getText(R.string.remove_drop_target_label))); mActions.put(INFO, new AccessibilityAction(INFO, launcher.getText(R.string.app_info_drop_target_label))); mActions.put(UNINSTALL, new AccessibilityAction(UNINSTALL, launcher.getText(R.string.uninstall_drop_target_label))); mActions.put(ADD_TO_WORKSPACE, new AccessibilityAction(ADD_TO_WORKSPACE, launcher.getText(R.string.action_add_to_workspace))); mActions.put(MOVE, new AccessibilityAction(MOVE, launcher.getText(R.string.action_move))); mActions.put(MOVE_TO_WORKSPACE, new AccessibilityAction(MOVE_TO_WORKSPACE, launcher.getText(R.string.action_move_to_workspace))); mActions.put(RESIZE, new AccessibilityAction(RESIZE, launcher.getText(R.string.action_resize))); mActions.put(DEEP_SHORTCUTS, new AccessibilityAction(DEEP_SHORTCUTS, launcher.getText(R.string.action_deep_shortcut))); }
public LauncherAccessibilityDelegate(Launcher launcher) { mLauncher = launcher; mActions.put(REMOVE, new AccessibilityAction(REMOVE, launcher.getText(R.string.delete_target_label))); mActions.put(INFO, new AccessibilityAction(INFO, launcher.getText(R.string.info_target_label))); mActions.put(UNINSTALL, new AccessibilityAction(UNINSTALL, launcher.getText(R.string.delete_target_uninstall_label))); mActions.put(ADD_TO_WORKSPACE, new AccessibilityAction(ADD_TO_WORKSPACE, launcher.getText(R.string.action_add_to_workspace))); mActions.put(MOVE, new AccessibilityAction(MOVE, launcher.getText(R.string.action_move))); mActions.put(MOVE_TO_WORKSPACE, new AccessibilityAction(MOVE_TO_WORKSPACE, launcher.getText(R.string.action_move_to_workspace))); mActions.put(RESIZE, new AccessibilityAction(RESIZE, launcher.getText(R.string.action_resize))); }
/** * Returns the scroll action for the given {@link TraversalStrategy.SearchDirection} if the * scroll action is available on the current SDK version. Otherwise, returns 0. */ public static int convertSearchDirectionToScrollAction( @TraversalStrategy.SearchDirection int direction) { boolean supportsDirectional = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; if (direction == TraversalStrategy.SEARCH_FOCUS_FORWARD) { return AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD; } else if (direction == TraversalStrategy.SEARCH_FOCUS_BACKWARD) { return AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD; } else if (supportsDirectional) { if (direction == TraversalStrategy.SEARCH_FOCUS_LEFT) { return AccessibilityAction.ACTION_SCROLL_LEFT.getId(); } else if (direction == TraversalStrategy.SEARCH_FOCUS_RIGHT) { return AccessibilityAction.ACTION_SCROLL_RIGHT.getId(); } else if (direction == TraversalStrategy.SEARCH_FOCUS_UP) { return AccessibilityAction.ACTION_SCROLL_UP.getId(); } else if (direction == TraversalStrategy.SEARCH_FOCUS_DOWN) { return AccessibilityAction.ACTION_SCROLL_DOWN.getId(); } } return 0; }
/** * Returns the {@link TraversalStrategy.SearchDirectionOrUnknown} for the given scroll * action; {@link TraversalStrategy#SEARCH_FOCUS_UNKNOWN} is returned for a scroll action * that can't be handled (e.g. because the current API level doesn't support it). */ public static @TraversalStrategy.SearchDirectionOrUnknown int convertScrollActionToSearchDirection(int scrollAction) { boolean supportsDirectional = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; if (scrollAction == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) { return TraversalStrategy.SEARCH_FOCUS_FORWARD; } else if (scrollAction == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) { return TraversalStrategy.SEARCH_FOCUS_BACKWARD; } else if (supportsDirectional) { if (scrollAction == AccessibilityAction.ACTION_SCROLL_LEFT.getId()) { return TraversalStrategy.SEARCH_FOCUS_LEFT; } else if (scrollAction == AccessibilityAction.ACTION_SCROLL_RIGHT.getId()) { return TraversalStrategy.SEARCH_FOCUS_RIGHT; } else if (scrollAction == AccessibilityAction.ACTION_SCROLL_UP.getId()) { return TraversalStrategy.SEARCH_FOCUS_UP; } else if (scrollAction == AccessibilityAction.ACTION_SCROLL_DOWN.getId()) { return TraversalStrategy.SEARCH_FOCUS_DOWN; } } return TraversalStrategy.SEARCH_FOCUS_UNKNOWN; }
@Override @Implementation public boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (other.getClass() != AccessibilityAction.class) { return false; } return id == ((AccessibilityAction) other).getId(); }
public OverviewScreenAccessibilityDelegate(Workspace workspace) { mWorkspace = workspace; Context context = mWorkspace.getContext(); boolean isRtl = Utilities.isRtl(context.getResources()); mActions.put(MOVE_BACKWARD, new AccessibilityAction(MOVE_BACKWARD, context.getText(isRtl ? R.string.action_move_screen_right : R.string.action_move_screen_left))); mActions.put(MOVE_FORWARD, new AccessibilityAction(MOVE_FORWARD, context.getText(isRtl ? R.string.action_move_screen_left : R.string.action_move_screen_right))); }
@Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); Context context = host.getContext(); info.addAction(new AccessibilityAction(OVERVIEW, context.getText(OVERVIEW))); if (Utilities.isWallpaperAllowed(context)) { info.addAction(new AccessibilityAction(WALLPAPERS, context.getText(WALLPAPERS))); } info.addAction(new AccessibilityAction(WIDGETS, context.getText(WIDGETS))); info.addAction(new AccessibilityAction(SETTINGS, context.getText(SETTINGS))); }
private List<AccessibilityAction> getActionList() { if (mIcon == null || !(mIcon.getTag() instanceof ItemInfo)) { return Collections.EMPTY_LIST; } AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(); mDelegate.addSupportedActions(mIcon, info, true); List<AccessibilityAction> result = new ArrayList<>(info.getActionList()); info.recycle(); return result; }
public boolean show() { List<AccessibilityAction> actions = getActionList(); if (actions.isEmpty()) { return false; } PopupMenu popup = new PopupMenu(mLauncher, mIcon); popup.setOnMenuItemClickListener(this); Menu menu = popup.getMenu(); for (AccessibilityAction action : actions) { menu.add(Menu.NONE, action.getId(), Menu.NONE, action.getLabel()); } popup.show(); return true; }
public void onInitializeAccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); if (VERSION.SDK_INT >= 21) { info.addAction(AccessibilityAction.ACTION_SCROLL_BACKWARD); info.addAction(AccessibilityAction.ACTION_SCROLL_FORWARD); return; } info.addAction(4096); info.addAction(8192); }
@Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); Context context = host.getContext(); info.addAction(new AccessibilityAction(OVERVIEW, context.getText(OVERVIEW))); if (Utilities.isWallapaperAllowed(context)) { info.addAction(new AccessibilityAction(WALLPAPERS, context.getText(WALLPAPERS))); } info.addAction(new AccessibilityAction(WIDGETS, context.getText(WIDGETS))); info.addAction(new AccessibilityAction(SETTINGS, context.getText(SETTINGS))); }
/** * Perform accessibility action ACTION_SET_PROGRESS on the node * * @param value desired progress value * @return true if action performed successfully */ public static boolean setProgressValue(final AccessibilityNodeInfo node, final float value) { if (!node.getActionList().contains(AccessibilityAction.ACTION_SET_PROGRESS)) { Logger.debug("The element does not support ACTION_SET_PROGRESS action."); return false; } Logger.debug(String.format( "Trying to perform ACTION_SET_PROGRESS accessibility action with value %s", value)); final Bundle args = new Bundle(); args.putFloat(AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE, value); return node.performAction(AccessibilityAction.ACTION_SET_PROGRESS.getId(), args); }
public final void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo paramAccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(paramAccessibilityNodeInfo); if (Build.VERSION.SDK_INT >= 21) { la localla = g(); for (int i = 0; i < localla.size(); i++) { paramAccessibilityNodeInfo.addAction(new AccessibilityNodeInfo.AccessibilityAction(((Integer)localla.b[(i << 1)]).intValue(), (CharSequence)localla.b[(1 + (i << 1))])); } } }
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo paramAccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(paramAccessibilityNodeInfo); if ((this.R != 0) || (Build.VERSION.SDK_INT < 21)) {} for (;;) { return; la localla = g(); for (int i1 = 0; i1 < localla.size(); i1++) { paramAccessibilityNodeInfo.addAction(new AccessibilityNodeInfo.AccessibilityAction(((Integer)localla.b[(i1 << 1)]).intValue(), (CharSequence)localla.b[(1 + (i1 << 1))])); } } }
@Override public boolean accept(TalkBackService service, AccessibilityNodeInfoCompat node) { if (!BuildCompat.isAtLeastN()) { return false; } return AccessibilityNodeInfoUtils.supportsAction(node, AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS.getId()); }
static void setProgress(AccessibilityNodeInfoCompat node, int progress) { RangeInfoCompat rangeInfo = node.getRangeInfo(); if (rangeInfo != null && progress >= 0 && progress <= 100) { Bundle args = new Bundle(); args.putFloat(AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE, percentToReal(progress, rangeInfo.getMin(), rangeInfo.getMax())); PerformActionUtils.performAction(node, AccessibilityAction.ACTION_SET_PROGRESS.getId(), args); } }
@Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); info.addAction(new AccessibilityAction(R.id.custom_action_1, "CA1")); info.addAction(new AccessibilityAction(R.id.custom_action_2, "CA2")); }
@Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); info.addAction(new AccessibilityAction(R.id.custom_action_3, "CA3")); info.addAction(new AccessibilityAction(R.id.custom_action_4, "CA4")); }
@Implementation public void addAction(int action) { if ((action & getActionTypeMaskFromFramework()) != 0) { throw new IllegalArgumentException("Action is not a combination of the standard " + "actions: " + action); } int remainingIds = action; while (remainingIds > 0) { final int id = 1 << Integer.numberOfTrailingZeros(remainingIds); remainingIds &= ~id; AccessibilityAction convertedAction = getActionFromIdFromFrameWork(id); addAction(convertedAction); } }
@Implementation public void addAction(AccessibilityAction action) { if (action == null) { return; } if (actionsArray == null) { actionsArray = new ArrayList<>(); } actionsArray.remove(action); actionsArray.add(action); }
@Implementation public boolean removeAction(AccessibilityAction action) { if (action == null || actionsArray == null) { return false; } return actionsArray.remove(action); }
@Implementation public List<AccessibilityAction> getActionList() { if (actionsArray == null) { return Collections.emptyList(); } return actionsArray; }
public ShortcutMenuAccessibilityDelegate(Launcher launcher) { super(launcher); mActions.put(DISMISS_NOTIFICATION, new AccessibilityAction(DISMISS_NOTIFICATION, launcher.getText(R.string.action_dismiss_notification))); }
static void addAction(Object info, Object action) { ((AccessibilityNodeInfo) info).addAction((AccessibilityAction) action); }
public static boolean removeAction(Object info, Object action) { return ((AccessibilityNodeInfo) info).removeAction((AccessibilityAction) action); }