android.view.accessibility.AccessibilityWindowInfo#TYPE_INPUT_METHOD源码实例Demo

下面列出了android.view.accessibility.AccessibilityWindowInfo#TYPE_INPUT_METHOD 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: talkback   文件: WindowEventInterpreter.java
private static String windowTypeToString(int type) {
  switch (type) {
    case AccessibilityWindowInfo.TYPE_APPLICATION:
      return "TYPE_APPLICATION";
    case AccessibilityWindowInfo.TYPE_INPUT_METHOD:
      return "TYPE_INPUT_METHOD";
    case AccessibilityWindowInfo.TYPE_SYSTEM:
      return "TYPE_SYSTEM";
    case AccessibilityWindowInfo.TYPE_ACCESSIBILITY_OVERLAY:
      return "TYPE_ACCESSIBILITY_OVERLAY";
    case AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER:
      return "TYPE_SPLIT_SCREEN_DIVIDER";
    default:
      return "UNKNOWN";
  }
}
 
源代码2 项目: talkback   文件: ScreenState.java
/**
 * Returns title of window with given window ID.
 *
 * <p><strong>Note: </strong> This method returns null if the window has no title, or the window
 * is not visible, or the window is IME or system window.
 */
@Nullable
public CharSequence getWindowTitle(int windowId) {
  AccessibilityWindowInfo window = idToWindowInfoMap.get(windowId);
  if ((window == null)
      || (window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD)
      || (window.getType() == AccessibilityWindowInfo.TYPE_SYSTEM)
      || (window.getType() == AccessibilityWindowInfo.TYPE_SPLIT_SCREEN_DIVIDER)) {
    // Only return title for application or accessibility windows.
    return null;
  }

  CharSequence eventTitle = overriddenWindowTitles.get(windowId);
  if (!TextUtils.isEmpty(eventTitle)) {
    return eventTitle;
  }

  if (BuildVersionUtils.isAtLeastN()) {
    // AccessibilityWindowInfo.getTitle() is available since API 24.
    CharSequence infoTitle = window.getTitle();
    if (!TextUtils.isEmpty(infoTitle)) {
      return infoTitle;
    }
  }
  return null;
}
 
源代码3 项目: talkback   文件: ProcessorPhoneticLetters.java
private boolean isKeyboardEvent(AccessibilityEvent event) {
  if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
    return false;
  }

  // For platform since lollipop, check that the current window is an
  // Input Method.
  final AccessibilityNodeInfo source = event.getSource();
  if (source == null) {
    return false;
  }

  int windowId = source.getWindowId();
  source.recycle();
  WindowManager manager = new WindowManager(service);
  return manager.getWindowType(windowId) == AccessibilityWindowInfo.TYPE_INPUT_METHOD;
}
 
源代码4 项目: oversec   文件: OversecAccessibilityService.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private AccessibilityWindowInfo getWindowOfTypeIme() {
    try {
        List<AccessibilityWindowInfo> ww = getWindows();
        for (AccessibilityWindowInfo w : ww) {
            if (w.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
                return w;
            }
        }
    } catch (java.lang.SecurityException ex) {
        //This can only happen when switching users!
        Ln.e(ex, "failed to getWindows!");
    }
    return null;
}
 
源代码5 项目: quickstart-android   文件: MainActivityTest.java
private void closeKeyboard() {
  for (AccessibilityWindowInfo w : getInstrumentation().getUiAutomation().getWindows()) {
    if (w.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
      device.pressBack();
      return;
    }
  }
}
 
源代码6 项目: talkback   文件: WindowManager.java
public boolean isInputWindowOnScreen() {
  if (mWindows == null) {
    return false;
  }

  for (AccessibilityWindowInfo window : mWindows) {
    if (window != null && window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
      return true;
    }
  }

  return false;
}
 
源代码7 项目: talkback   文件: MainTreeBuilder.java
/**
 * Adds view hierarchies from several windows to the tree.
 *
 * @param windowList The windows whose hierarchies should be added to the tree
 * @param treeToBuildOn The tree to which the hierarchies from windowList should be added
 * @param shouldPlaceTreeFirst Whether the treeToBuildOn should be placed first in the tree; if it
 *     should not be placed first, it will be placed last
 * @return An updated tree that includes {@code treeToBuildOn}
 */
public TreeScanNode addWindowListToTree(
    List<SwitchAccessWindowInfo> windowList,
    TreeScanNode treeToBuildOn,
    boolean shouldPlaceTreeFirst) {
  if (windowList != null) {
    List<SwitchAccessWindowInfo> wList = new ArrayList<>(windowList);
    sortWindowListForTraversalOrder(wList);
    removeStatusBarButtonsFromWindowList(wList);
    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(service)) {
      return orderNTreeBuilder.addWindowListToTree(
          wList,
          treeToBuildOn,
          SwitchAccessPreferenceUtils.shouldScanNonActionableItems(service));
    }
    // Make sure that if the user doesn't perform an explicit selection, focus is cleared.
    TreeScanNode newTree = new ClearFocusNode();
    if (!shouldPlaceTreeFirst) {
      if (treeToBuildOn != null) {
        newTree = new TreeScanSelectionNode(treeToBuildOn, new ClearFocusNode());
      }
    } else if (treeToBuildOn == null) {
      shouldPlaceTreeFirst = false;
    }
    for (SwitchAccessWindowInfo window : wList) {
      SwitchAccessNodeCompat windowRoot = window.getRoot();
      if (windowRoot != null) {
        if (!SwitchAccessPreferenceUtils.isLinearScanningEnabled(service)
            && window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) {
          newTree =
              rowColumnTreeBuilder.addViewHierarchyToTree(
                  windowRoot,
                  newTree,
                  SwitchAccessPreferenceUtils.shouldScanNonActionableItems(service));
        } else {
          newTree =
              addViewHierarchyToTree(
                  windowRoot,
                  newTree,
                  SwitchAccessPreferenceUtils.shouldScanNonActionableItems(service));
        }
        windowRoot.recycle();
      }
    }
    if (shouldPlaceTreeFirst) {
      newTree = new TreeScanSelectionNode(treeToBuildOn, newTree);
    }
    return newTree;
  }
  return treeToBuildOn;
}
 
源代码8 项目: talkback   文件: ShowActionsMenuNode.java
/** Returns whether this node corresponds to an item on the IME. */
public boolean isImeWindowType() {
  return AccessibilityNodeInfoUtils.getWindowType(nodeCompats.get(0))
      == AccessibilityWindowInfo.TYPE_INPUT_METHOD;
}
 
源代码9 项目: talkback   文件: WindowTransitionInfo.java
private static boolean isSystemOrImeWindow(AccessibilityWindowInfo window) {
  return (window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD)
      || (window.getType() == AccessibilityWindowInfo.TYPE_SYSTEM);
}