List of usage examples for android.view.accessibility AccessibilityWindowInfo TYPE_INPUT_METHOD
int TYPE_INPUT_METHOD
To view the source code for android.view.accessibility AccessibilityWindowInfo TYPE_INPUT_METHOD.
Click Source Link
From source file:com.android.screenspeak.eventprocessor.ProcessorPhoneticLetters.java
private boolean isKeyboardEvent(AccessibilityEvent event) { if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { return false; }/*from w ww . j av a 2 s . c om*/ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { // 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(); WindowManager manager = new WindowManager(); manager.setWindows(mService.getWindows()); return manager.getWindowType(windowId) == AccessibilityWindowInfo.TYPE_INPUT_METHOD; } else { // For old platforms, we can't check the window type directly, so just // manually check the classname. return event.getClassName().equals("com.android.inputmethod.keyboard.Key"); } }
From source file:com.android.utils.WindowManager.java
public boolean isInputWindowOnScreen() { if (mWindows == null) { return false; }/*from w w w .j a va 2 s . c o m*/ for (AccessibilityWindowInfo window : mWindows) { if (window != null && window.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) { return true; } } return false; }
From source file:com.android.screenspeak.eventprocessor.ProcessorVolumeStream.java
private AccessibilityNodeInfoCompat findInputFocus() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { List<AccessibilityWindowInfo> awis = mService.getWindows(); for (AccessibilityWindowInfo awi : awis) { if (awi.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) continue; AccessibilityNodeInfo info = awi.getRoot(); if (info == null) continue; AccessibilityNodeInfoCompat root = new AccessibilityNodeInfoCompat(awi.getRoot()); AccessibilityNodeInfoCompat focus = root.findFocus(AccessibilityNodeInfo.FOCUS_INPUT); if (focus != null) { if (!root.equals(focus)) root.recycle();// w ww. ja v a 2s. com return focus; } else { root.recycle(); } } return null; } else { AccessibilityNodeInfo info = mService.getRootInActiveWindow(); if (info == null) return null; AccessibilityNodeInfoCompat root = new AccessibilityNodeInfoCompat(info); AccessibilityNodeInfoCompat focus = root.findFocus(AccessibilityNodeInfoCompat.FOCUS_INPUT); if (focus != null && !focus.equals(root)) root.recycle(); return focus; } }
From source file:com.android.talkback.eventprocessor.ProcessorVolumeStream.java
private boolean attemptNavigation(int button) { AccessibilityNodeInfoCompat node = mCursorController.getCursorOrInputCursor(); // Clear focus if it is on an IME if (node != null) { if (API_LEVEL_SUPPORTS_WINDOW_NAVIGATION) { for (AccessibilityWindowInfo awi : mService.getWindows()) { if (awi.getId() == node.getWindowId()) { if (awi.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) { node.recycle();/*from www. j av a 2 s . c o m*/ node = null; } break; } } } } // If we cleared the focus before it is on an IME, try to get the current node again. if (node == null) { node = mCursorController.getCursorOrInputCursor(); } if (node == null) return false; try { if (Role.getRole(node) == Role.ROLE_SEEK_CONTROL) { navigateSlider(button, node); return true; } // In general, do not allow volume key navigation when the a11y focus is placed but // it is not on the edit field that the keyboard is currently editing. // // Example 1: // EditText1 has input focus and EditText2 has accessibility focus. // getCursorOrInputCursor() will return EditText2 based on its priority order. // EditText2.isFocused() = false, so we should not allow volume keys to control text. // // Example 2: // EditText1 in Window1 has input focus. EditText2 in Window2 has input focus as well. // If Window1 is input-focused but Window2 has the accessibility focus, don't allow // the volume keys to control the text. boolean nodeWindowFocused; if (API_LEVEL_SUPPORTS_WINDOW_NAVIGATION) { nodeWindowFocused = node.getWindow() != null && node.getWindow().isFocused(); } else { nodeWindowFocused = true; } if (node.isFocused() && nodeWindowFocused && AccessibilityNodeInfoUtils.isEditable(node)) { navigateEditText(button, node); return true; } return false; } finally { AccessibilityNodeInfoUtils.recycleNodes(node); } }
From source file:com.android.screenspeak.eventprocessor.ProcessorVolumeStream.java
private boolean attemptNavigation(int button) { AccessibilityNodeInfoCompat node = mCursorController.getCursor(); // Clear focus if it is on an IME if (node != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { for (AccessibilityWindowInfo awi : mService.getWindows()) { if (awi.getId() == node.getWindowId()) { if (awi.getType() == AccessibilityWindowInfo.TYPE_INPUT_METHOD) { node.recycle();//from w ww . ja v a2 s . c o m node = null; } break; } } } } if (node == null) { node = findInputFocus(); } if (node == null) return false; try { if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(node, SeekBar.class)) { navigateSlider(button); return true; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (((AccessibilityNodeInfo) node.getInfo()).isEditable()) { navigateEditText(button, node); return true; } } else { if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(node, EditText.class) || AccessibilityNodeInfoUtils.nodeMatchesClassByName(node, "com.google.android.search.searchplate.SimpleSearchText")) { navigateEditText(button, node); return true; } } return false; } finally { AccessibilityNodeInfoUtils.recycleNodes(node); } }