Java Code Examples for android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#ACTION_CLICK

The following examples show how to use android.support.v4.view.accessibility.AccessibilityNodeInfoCompat#ACTION_CLICK . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RadialTimePickerView.java    From SublimePicker with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action, Bundle arguments) {
    if (action == AccessibilityNodeInfoCompat.ACTION_CLICK) {
        final int type = getTypeFromId(virtualViewId);
        final int value = getValueFromId(virtualViewId);
        if (type == TYPE_HOUR) {
            final int hour = mIs24HourMode ? value : hour12To24(value, mAmOrPm);
            setCurrentHour(hour);
            return true;
        } else if (type == TYPE_MINUTE) {
            setCurrentMinute(value);
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: RadialTimePickerView.java    From AppCompat-Extension-Library with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
                                                Bundle arguments) {
    if (action == AccessibilityNodeInfoCompat.ACTION_CLICK) {
        final int type = getTypeFromId(virtualViewId);
        final int value = getValueFromId(virtualViewId);
        if (type == TYPE_HOUR) {
            final int hour = mIs24HourMode ? value : hour12To24(value, mAmOrPm);
            setCurrentHour(hour);
            return true;
        } else if (type == TYPE_MINUTE) {
            setCurrentMinute(value);
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: KeyboardAccessibilityNodeProvider.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
/**
 * Performs the specified accessibility action for the given key.
 *
 * @param key The on which to perform the action.
 * @param action The action to perform.
 * @return The result of performing the action, or false if the action is not supported.
 */
boolean performActionForKey(final Key key, final int action) {
    switch (action) {
    case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS:
        mAccessibilityFocusedView = getVirtualViewIdOf(key);
        sendAccessibilityEventForKey(
                key, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
        return true;
    case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
        mAccessibilityFocusedView = UNDEFINED;
        sendAccessibilityEventForKey(
                key, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
        return true;
    case AccessibilityNodeInfoCompat.ACTION_CLICK:
        sendAccessibilityEventForKey(key, AccessibilityEvent.TYPE_VIEW_CLICKED);
        mDelegate.performClickOn(key);
        return true;
    case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
        sendAccessibilityEventForKey(key, AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
        mDelegate.performLongClickOn(key);
        return true;
    default:
        return false;
    }
}
 
Example 4
Source File: DragAndDropAccessibilityDelegate.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int viewId, int action, Bundle args) {
    if (action == AccessibilityNodeInfoCompat.ACTION_CLICK && viewId != INVALID_ID) {
        String confirmation = getConfirmationForIconDrop(viewId);
        mDelegate.handleAccessibleDrop(mView, getItemBounds(viewId), confirmation);
        return true;
    }
    return false;
}
 
Example 5
Source File: CompositorViewHolder.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(
        int virtualViewId, int action, Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
            return true;
    }

    return false;
}
 
Example 6
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(
        int virtualViewId, int action, Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
            return true;
    }

    return false;
}
 
Example 7
Source File: DragAndDropAccessibilityDelegate.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int viewId, int action, Bundle args) {
    if (action == AccessibilityNodeInfoCompat.ACTION_CLICK && viewId != INVALID_ID) {
        String confirmation = getConfirmationForIconDrop(viewId);
        mDelegate.handleAccessibleDrop(mView, getItemBounds(viewId), confirmation);
        return true;
    }
    return false;
}
 
Example 8
Source File: SimpleMonthView.java    From SublimePicker with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action, Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
            return onDayClicked(virtualViewId);
    }

    return false;
}
 
Example 9
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(
        int virtualViewId, int action, Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
            mVirtualViews.get(virtualViewId).handleClick(LayoutManager.time());
            return true;
    }

    return false;
}
 
Example 10
Source File: SimpleMonthView.java    From AppCompat-Extension-Library with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(int virtualViewId, int action,
                                                Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
            return onDayClicked(virtualViewId);
    }

    return false;
}
 
Example 11
Source File: ExploreByTouchHelperActivity.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
protected boolean onPerformActionForVirtualView(
        int virtualViewId, int action, Bundle arguments) {
    switch (action) {
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
            // Click handling should be consistent with
            // onTouchEvent(). This ensures that the view works the
            // same whether accessibility is turned on or off.
            return onItemClicked(virtualViewId);
    }

    return false;
}
 
Example 12
Source File: AccessibilityNodeInfoWrapper.java    From stetho with MIT License 4 votes vote down vote up
@Nullable
public static String getActions(View view) {
  AccessibilityNodeInfoCompat node = createNodeInfoFromView(view);
  try {
    final StringBuilder actionLabels = new StringBuilder();
    final String separator = ", ";

    for (AccessibilityActionCompat action : node.getActionList()) {
      if (actionLabels.length() > 0) {
        actionLabels.append(separator);
      }
      switch (action.getId()) {
        case AccessibilityNodeInfoCompat.ACTION_FOCUS:
          actionLabels.append("focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLEAR_FOCUS:
          actionLabels.append("clear-focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SELECT:
          actionLabels.append("select");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION:
          actionLabels.append("clear-selection");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLICK:
          actionLabels.append("click");
          break;
        case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
          actionLabels.append("long-click");
          break;
        case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS:
          actionLabels.append("accessibility-focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
          actionLabels.append("clear-accessibility-focus");
          break;
        case AccessibilityNodeInfoCompat.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
          actionLabels.append("next-at-movement-granularity");
          break;
        case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
          actionLabels.append("previous-at-movement-granularity");
          break;
        case AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT:
          actionLabels.append("next-html-element");
          break;
        case AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT:
          actionLabels.append("previous-html-element");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD:
          actionLabels.append("scroll-forward");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD:
          actionLabels.append("scroll-backward");
          break;
        case AccessibilityNodeInfoCompat.ACTION_CUT:
          actionLabels.append("cut");
          break;
        case AccessibilityNodeInfoCompat.ACTION_COPY:
          actionLabels.append("copy");
          break;
        case AccessibilityNodeInfoCompat.ACTION_PASTE:
          actionLabels.append("paste");
          break;
        case AccessibilityNodeInfoCompat.ACTION_SET_SELECTION:
          actionLabels.append("set-selection");
          break;
        default:
          CharSequence label = action.getLabel();
          if (label != null) {
            actionLabels.append(label);
          } else {
            actionLabels.append("unknown");
          }
          break;
      }
    }

    return actionLabels.length() > 0 ? actionLabels.toString() : null;
  } finally {
    node.recycle();
  }
}
 
Example 13
Source File: SublimeTimePicker.java    From SublimePicker with Apache License 2.0 4 votes vote down vote up
public ClickActionDelegate(Context context, int resId) {
    CharSequence label = context.getString(resId);
    mClickAction = new AccessibilityNodeInfoCompat.AccessibilityActionCompat(AccessibilityNodeInfoCompat.ACTION_CLICK,
            label);
}
 
Example 14
Source File: AppCompatTimePickerDelegate.java    From AppCompat-Extension-Library with Apache License 2.0 4 votes vote down vote up
public ClickActionDelegate(Context context, int resId) {
    mClickAction = new AccessibilityActionCompat(
            AccessibilityNodeInfoCompat.ACTION_CLICK, context.getString(resId));
}
 
Example 15
Source File: AbsHListView.java    From Klyph with MIT License 4 votes vote down vote up
@Override
public boolean performAccessibilityAction( View host, int action, Bundle arguments ) {
	if ( super.performAccessibilityAction( host, action, arguments ) ) {
		return true;
	}

	final int position = getPositionForView( host );
	final ListAdapter adapter = getAdapter();

	if ( ( position == INVALID_POSITION ) || ( adapter == null ) ) {
		// Cannot perform actions on invalid items.
		return false;
	}

	if ( !isEnabled() || !adapter.isEnabled( position ) ) {
		// Cannot perform actions on disabled items.
		return false;
	}

	final long id = getItemIdAtPosition( position );

	switch ( action ) {
		case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION: {
			if ( getSelectedItemPosition() == position ) {
				setSelection( INVALID_POSITION );
				return true;
			}
		}
			return false;
		case AccessibilityNodeInfoCompat.ACTION_SELECT: {
			if ( getSelectedItemPosition() != position ) {
				setSelection( position );
				return true;
			}
		}
			return false;
		case AccessibilityNodeInfoCompat.ACTION_CLICK: {
			if ( isClickable() ) {
				return performItemClick( host, position, id );
			}
		}
			return false;
		case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK: {
			if ( isLongClickable() ) {
				return performLongPress( host, position, id );
			}
		}
			return false;
	}

	return false;
}