Java Code Examples for android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION

The following examples show how to use android.view.accessibility.AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION . 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: EventVariables.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public boolean getBoolean(int variableId) {
  switch (variableId) {
    case EVENT_IS_CONTENT_DESCRIPTION_CHANGED:
      return (mEvent.getContentChangeTypes()
              & AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION)
          != 0;
    case EVENT_IS_CONTENT_UNDEFINED:
      return (mEvent.getContentChangeTypes() == AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
    case EVENT_SOURCE_IS_NULL:
      return (mSource == null);
    case EVENT_SOURCE_IS_KEYBOARD:
      return AccessibilityNodeInfoUtils.isKeyboard(mEvent, mSource);
    case EVENT_IS_WINDOW_CONTENT_CHANGED:
      return mEvent.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
    case EVENT_SOURCE_IS_LIVE_REGION:
      return (mSource != null)
          && (mSource.getLiveRegion() != View.ACCESSIBILITY_LIVE_REGION_NONE);
    default:
      return mParent.getBoolean(variableId);
  }
}
 
Example 2
Source File: UiChangeDetector.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
  if (event == null) {
    return;
  }
  int eventType = event.getEventType();
  boolean willClearFocus =
      (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED)
          || (eventType == AccessibilityEvent.TYPE_WINDOWS_CHANGED)
          || (eventType == AccessibilityEvent.TYPE_VIEW_SCROLLED);

  if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
    /* Ignore changes that don't affect the view hierarchy */
    int changeTypes = event.getContentChangeTypes();
    changeTypes &= ~AccessibilityEvent.CONTENT_CHANGE_TYPE_TEXT;
    changeTypes &= ~AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION;
    willClearFocus = (changeTypes != 0);
  }

  if (willClearFocus) {
    listener.onPossibleChangeToUi(event);
  }
}
 
Example 3
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
private static String eventToString(AccessibilityEvent ev) {
    StringBuilder builder = new StringBuilder();
    builder.append("EventType: ").append(AccessibilityEvent.eventTypeToString(ev.getEventType()));
    //builder.append("; EventTime: ").append(ev.getEventTime());
    builder.append("; PackageName: ").append(ev.getPackageName());
    builder.append("; ClassName: ").append(ev.getClassName());
    // builder.append("; MovementGranularity: ").append(ev.getMovementGranularity());
    builder.append("; Action: ").append(ev.getAction());
    builder.append("; ContentChangeTypes: ");//.append(ev.getContentChangeTypes());


    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        int cct = 0;
        cct = ev.getContentChangeTypes();
        boolean hasCONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION = ((cct & AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION) == AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION);
        boolean hasCONTENT_CHANGE_TYPE_SUBTREE = ((cct & AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) == AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE);
        boolean hasCONTENT_CHANGE_TYPE_TEXT = ((cct & AccessibilityEvent.CONTENT_CHANGE_TYPE_TEXT) == AccessibilityEvent.CONTENT_CHANGE_TYPE_TEXT);
        boolean hasCONTENT_CHANGE_TYPE_UNDEFINED = ((cct & AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED) == AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);


        if (hasCONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION) {
            builder.append(" DESCRIPTION,");
        }
        if (hasCONTENT_CHANGE_TYPE_SUBTREE) {
            builder.append(" SUBTREE,");
        }
        if (hasCONTENT_CHANGE_TYPE_TEXT) {
            builder.append(" TEXT,");
        }
        if (hasCONTENT_CHANGE_TYPE_UNDEFINED) {
            builder.append(" UNDEFINED,");
        }

        builder.append("\n");
    } else {
        builder.append("[ContentChangeType Not available on SDK " + android.os.Build.VERSION.SDK_INT);
    }

    builder.append("  Record X:");
    builder.append(recordToString(ev));
    if (true) {
        builder.append("\n");
        //builder.append("; sourceWindowId: ").append(mSourceWindowId);
        //if (mSourceNode != null) {
        //    builder.append("; mSourceNodeId: ").append(mSourceNode.getSourceNodeId());
        //}
        for (int i = 0; i < ev.getRecordCount(); i++) {
            final AccessibilityRecord record = ev.getRecord(i);
            builder.append("  Record ");
            builder.append(i);
            builder.append(":");
            builder.append(recordToString(record));

            builder.append("\n");
        }
    } else {
        builder.append("; recordCount: ").append(ev.getRecordCount());
    }
    return builder.toString();
}