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

The following examples show how to use android.view.accessibility.AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED . 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: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public void setMonitorEventTypesAll() {
    Ln.d("SERVICE: setMonitorEventTypesAll");

    int mask = AccessibilityEvent.TYPE_WINDOWS_CHANGED
            | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_SCROLLED;

    String packagename = mCore.getCurrentPackageName();

    if (packagename == null || mDb.isShowInfoOnTap(packagename)) {
        Ln.d("SERVICE: setMonitorEventTypesAll adding TYPE_VIEW_CLICKED");
        mask |= AccessibilityEvent.TYPE_VIEW_CLICKED;
    }
    if (packagename == null || mDb.isShowInfoOnLongTap(packagename) || mDb.isToggleEncryptButtonOnLongTap(packagename)) {
        Ln.d("SERVICE: setMonitorEventTypesAll adding TYPE_VIEW_LONG_CLICKED");
        mask |= AccessibilityEvent.TYPE_VIEW_LONG_CLICKED;
    }

    boolean includeNotImportantViews = packagename == null ? true : mDb.isIncludeNonImportantViews(packagename);

    setMonitorEventTypes(mask, includeNotImportantViews, true);


}
 
Example 2
Source File: WechatService.java    From WechatHook-Dusan with Apache License 2.0 6 votes vote down vote up
private void handleEvent(AccessibilityEvent event) {
    final int eventType = event.getEventType();
    String className = event.getClassName().toString();

    //通知栏事件
    if (eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
        handleNotificationEvent(event);//64
    } else if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        if (WechatUI.UI_LUANCHER.equals(className)) {
            enterNearby(service);
            startTime = System.currentTimeMillis();
        }
    } else if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
        mockNearByFriends(event);
        backHome(className);
    } else if (eventType == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
        //CommonUtil.init().sendText(service);
    } else if (AccessibilityEvent.TYPE_VIEW_SCROLLED == eventType) {//4096
        timeOutAndQuit();
    }
}
 
Example 3
Source File: TreeDebugNavigationMode.java    From brailleback with Apache License 2.0 6 votes vote down vote up
@Override
public void onObserveAccessibilityEvent(AccessibilityEvent event) {
    AccessibilityNodeInfo source = event.getSource();
    if (source == null) {
        return;
    }
    boolean isNewWindow = false;
    if (mCurrentNode == null ||
            mCurrentNode.getWindowId() != source.getWindowId()) {
        isNewWindow = true;
    }
    int t = event.getEventType();
    boolean isInterestingEventType = false;
    if (t == AccessibilityEvent.TYPE_VIEW_SELECTED
            || t == AccessibilityEvent.TYPE_VIEW_FOCUSED
            || t == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            || t != AccessibilityEvent.TYPE_VIEW_HOVER_ENTER) {
        isInterestingEventType = true;
    }
    if (isNewWindow || isInterestingEventType) {
        setPendingNode(source);
    }
}
 
Example 4
Source File: AutofillManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public int getRelevantEventTypes(int relevantEventTypes) {
    return relevantEventTypes | AccessibilityEvent.TYPE_VIEW_FOCUSED
            | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_CLICKED
            | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
}
 
Example 5
Source File: NearbyAs.java    From WechatHook-Dusan with Apache License 2.0 5 votes vote down vote up
public synchronized void startNearby(AccessibilityEvent event, WechatService service, Context context) {
    if (this.context==null) {
        this.context = context;
    }
    int eventType = event.getEventType();
    String className = event.getClassName().toString();
    nodeInfo = CommonUtil.init().checkRootWindow(service);
    if (nodeInfo == null) return;
    ////判断什么时候向下滑动
    if (WechatUI.UI_NEARBY_FRIENDS.equals(className)
            ||WechatUI.CLASS_NAME_LIST_VIEW.equals(className)){
        if (handleMoveEvent()) return;
    }

    AccessibilityNodeInfo node_listview = AccessibilityHelper.findNodeInfosById(nodeInfo, WechatUI.ID_NEARBY_LIST_VIEW);
    if (node_listview!=null||AccessibilityEvent.TYPE_VIEW_SCROLLED==eventType) {
        handle_nearby_friends(service);
        getThumbHeight();
    }

    AccessibilityNodeInfo node_username = AccessibilityHelper.findNodeInfosById(nodeInfo, WechatUI.ID_USER_NAME);
    if (node_username!=null) {
        //if (isActionShort()) return;
        handle_contact_info(service);
    }

    AccessibilityNodeInfo node_editview = AccessibilityHelper.findNodeInfosById(nodeInfo, WechatUI.ID_SEND_HELLO_EDIT_VIEW);
    if (node_editview!=null||AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED==eventType) {
        handle_sayhi_edit(service);
    }
}
 
Example 6
Source File: TextEntryProvider.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
public void handleAccessibilityEvent(AccessibilityEvent event, AccessibilityNodeInfo rootNode){

        switch (event.getEventType()) {
            case AccessibilityEvent.TYPE_VIEW_FOCUSED:
                onViewFocused(event, rootNode);
                break;
            case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
                onViewTextChanged(event);
                break;
            default:
                break;
        }

    }
 
Example 7
Source File: DigitsEditText.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
        // Since we're replacing the text every time we add or remove a
        // character, only read the difference. (issue 5337550)
        final int added = event.getAddedCount();
        final int removed = event.getRemovedCount();
        final int length = event.getBeforeText().length();
        if (added > removed) {
            event.setRemovedCount(0);
            event.setAddedCount(1);
            event.setFromIndex(length);
        } else if (removed > added) {
            event.setRemovedCount(1);
            event.setAddedCount(0);
            event.setFromIndex(length - 1);
        } else {
            return;
        }
    } else if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
        // The parent EditText class lets tts read "edit box" when this View
        // has a focus, which
        // confuses users on app launch (issue 5275935).
        return;
    }
    super.sendAccessibilityEventUnchecked(event);
}
 
Example 8
Source File: UrlBar.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
    if (mDisableTextAccessibilityEvents) {
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
                || event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
            return;
        }
    }
    super.sendAccessibilityEventUnchecked(event);
}
 
Example 9
Source File: UrlBar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
    if (mDisableTextAccessibilityEvents) {
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
                || event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
            return;
        }
    }
    super.sendAccessibilityEventUnchecked(event);
}
 
Example 10
Source File: TextEventInterpreter.java    From talkback with Apache License 2.0 5 votes vote down vote up
/** Extract a text event interpretation data from event. May return null. */
public @Nullable TextEventInterpretation interpret(AccessibilityEvent event) {
  // Interpret more specific event type.
  @Compositor.Event int eventType = event.getEventType();
  TextEventInterpretation interpretation;
  boolean isTextEvent = false;
  switch (eventType) {
    case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
      interpretation = interpretTextChange(event);
      isTextEvent = true;
      break;

    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
    case AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
      interpretation = interpretSelectionChange(event);
      isTextEvent = true;
      break;

    default:
      return null;
  }

  // Display interpretation, seal interpretation.
  interpretation.setReadOnly();
  if (isTextEvent) {
    LogUtils.i(TAG, "interpretation: %s", interpretation);
  }
  return interpretation;
}
 
Example 11
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
public static int[] getAllEventTypes() {
  return new int[] {
    AccessibilityEvent.TYPE_ANNOUNCEMENT,
    AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_END,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_START,
    AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_START,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED,
    AccessibilityEvent.TYPE_VIEW_CLICKED,
    AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED,
    AccessibilityEvent.TYPE_VIEW_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
    AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
    AccessibilityEvent.TYPE_VIEW_LONG_CLICKED,
    AccessibilityEvent.TYPE_VIEW_SCROLLED,
    AccessibilityEvent.TYPE_VIEW_SELECTED,
    AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
    AccessibilityEvent.TYPE_WINDOWS_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
  };
}
 
Example 12
Source File: AutocompleteEditText.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
    if (mIgnoreTextChangeFromAutocomplete) {
        if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED
                || event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
            return;
        }
    }
    super.sendAccessibilityEventUnchecked(event);
}
 
Example 13
Source File: AutofillManager.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public AccessibilityEvent onAccessibilityEvent(AccessibilityEvent event,
        boolean accessibilityEnabled, int relevantEventTypes) {
    final int type = event.getEventType();
    if (sVerbose) {
        // NOTE: this is waaay spammy, but that's life.
        Log.v(TAG, "onAccessibilityEvent(" + AccessibilityEvent.eventTypeToString(type)
                + "): virtualId="
                + AccessibilityNodeInfo.getVirtualDescendantId(event.getSourceNodeId())
                + ", client=" + getClient());
    }
    switch (type) {
        case AccessibilityEvent.TYPE_VIEW_FOCUSED: {
            synchronized (mLock) {
                if (mFocusedWindowId == event.getWindowId()
                        && mFocusedNodeId == event.getSourceNodeId()) {
                    return event;
                }
                if (mFocusedWindowId != AccessibilityWindowInfo.UNDEFINED_WINDOW_ID
                        && mFocusedNodeId != AccessibilityNodeInfo.UNDEFINED_NODE_ID) {
                    notifyViewExited(mFocusedWindowId, mFocusedNodeId);
                    mFocusedWindowId = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
                    mFocusedNodeId = AccessibilityNodeInfo.UNDEFINED_NODE_ID;
                    mFocusedBounds.set(0, 0, 0, 0);
                }
                final int windowId = event.getWindowId();
                final long nodeId = event.getSourceNodeId();
                if (notifyViewEntered(windowId, nodeId, mFocusedBounds)) {
                    mFocusedWindowId = windowId;
                    mFocusedNodeId = nodeId;
                }
            }
        } break;

        case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: {
            synchronized (mLock) {
                if (mFocusedWindowId == event.getWindowId()
                        && mFocusedNodeId == event.getSourceNodeId()) {
                    notifyValueChanged(event.getWindowId(), event.getSourceNodeId());
                }
            }
        } break;

        case AccessibilityEvent.TYPE_VIEW_CLICKED: {
            synchronized (mLock) {
                notifyViewClicked(event.getWindowId(), event.getSourceNodeId());
            }
        } break;

        case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: {
            final AutofillClient client = getClient();
            if (client != null) {
                synchronized (mLock) {
                    if (client.autofillClientIsFillUiShowing()) {
                        notifyViewEntered(mFocusedWindowId, mFocusedNodeId, mFocusedBounds);
                    }
                    updateTrackedViewsLocked();
                }
            }
        } break;
    }

    return accessibilityEnabled ? event : null;
}
 
Example 14
Source File: AccessibilityUtils.java    From DevUtils with Apache License 2.0 4 votes vote down vote up
/**
 * 打印 AccessibilityEvent 信息日志
 * @param event {@link AccessibilityEvent}
 * @param tag   日志 TAG
 */
public static void printAccessibilityEvent(final AccessibilityEvent event, final String tag) {
    if (event == null || !LogPrintUtils.isPrintLog()) return;

    StringBuilder builder = new StringBuilder();
    builder.append("=========================");
    builder.append(NEW_LINE_STR);

    int eventType = event.getEventType(); // 事件类型
    builder.append("packageName: " + event.getPackageName() + ""); // 响应事件的应用包名
    builder.append(NEW_LINE_STR);

    builder.append("source: " + event.getSource() + ""); // 事件源信息
    builder.append(NEW_LINE_STR);

    builder.append("source class: " + event.getClassName() + ""); // 事件源的类名, 如 android.widget.TextView
    builder.append(NEW_LINE_STR);

    builder.append("event type(int): " + eventType + "");
    builder.append(NEW_LINE_STR);

    switch (eventType) {
        case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:// 通知栏事件
            builder.append("event type: TYPE_NOTIFICATION_STATE_CHANGED");
            break;
        case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: // 窗体状态改变
            builder.append("event type: TYPE_WINDOW_STATE_CHANGED");
            break;
        case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: // View 获取到焦点
            builder.append("event type: TYPE_VIEW_ACCESSIBILITY_FOCUSED");
            break;
        case AccessibilityEvent.TYPE_GESTURE_DETECTION_START:
            builder.append("event type: TYPE_VIEW_ACCESSIBILITY_FOCUSED");
            break;
        case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
            builder.append("event type: TYPE_GESTURE_DETECTION_END");
            break;
        case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
            builder.append("event type: TYPE_WINDOW_CONTENT_CHANGED");
            break;
        case AccessibilityEvent.TYPE_VIEW_CLICKED:
            builder.append("event type: TYPE_VIEW_CLICKED");
            break;
        case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
            builder.append("event type: TYPE_VIEW_TEXT_CHANGED");
            break;
        case AccessibilityEvent.TYPE_VIEW_SCROLLED:
            builder.append("event type: TYPE_VIEW_SCROLLED");
            break;
        case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
            builder.append("event type: TYPE_VIEW_TEXT_SELECTION_CHANGED");
            break;
    }
    builder.append(NEW_LINE_STR);

    for (CharSequence txt : event.getText()) {
        // 输出当前事件包含的文本信息
        builder.append("text: " + txt);
        builder.append(NEW_LINE_STR);
    }
    builder.append("=========================");

    // 打印日志
    LogPrintUtils.dTag(tag, builder.toString());
}
 
Example 15
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 4 votes vote down vote up
public static String typeToString(int eventType) {
  switch (eventType) {
    case AccessibilityEvent.TYPE_ANNOUNCEMENT:
      return "TYPE_ANNOUNCEMENT";
    case AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT:
      return "TYPE_ASSIST_READING_CONTEXT";
    case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
      return "TYPE_GESTURE_DETECTION_END";
    case AccessibilityEvent.TYPE_GESTURE_DETECTION_START:
      return "TYPE_GESTURE_DETECTION_START";
    case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
      return "TYPE_NOTIFICATION_STATE_CHANGED";
    case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END:
      return "TYPE_TOUCH_EXPLORATION_GESTURE_END";
    case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START:
      return "TYPE_TOUCH_EXPLORATION_GESTURE_START";
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      return "TYPE_TOUCH_INTERACTION_END";
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      return "TYPE_TOUCH_INTERACTION_START";
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
      return "TYPE_VIEW_ACCESSIBILITY_FOCUSED";
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
      return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED";
    case AccessibilityEvent.TYPE_VIEW_CLICKED:
      return "TYPE_VIEW_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED:
      return "TYPE_VIEW_CONTEXT_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
      return "TYPE_VIEW_FOCUSED";
    case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
      return "TYPE_VIEW_HOVER_ENTER";
    case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT:
      return "TYPE_VIEW_HOVER_EXIT";
    case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED:
      return "TYPE_VIEW_LONG_CLICKED";
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
      return "TYPE_VIEW_SCROLLED";
    case AccessibilityEvent.TYPE_VIEW_SELECTED:
      return "TYPE_VIEW_SELECTED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
      return "TYPE_VIEW_TEXT_CHANGED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED:
      return "TYPE_VIEW_TEXT_SELECTION_CHANGED";
    case AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
      return "TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY";
    case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
      return "TYPE_WINDOWS_CHANGED";
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
      return "TYPE_WINDOW_CONTENT_CHANGED";
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
      return "TYPE_WINDOW_STATE_CHANGED";
    default:
      return "(unhandled)";
  }
}