Example usage for android.view.accessibility AccessibilityWindowInfo equals

List of usage examples for android.view.accessibility AccessibilityWindowInfo equals

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityWindowInfo equals.

Prototype

@Override
    public boolean equals(Object obj) 

Source Link

Usage

From source file:com.android.utils.WindowManager.java

private int getWindowIndex(AccessibilityWindowInfo windowInfo) {
    if (mWindows == null || windowInfo == null) {
        return WRONG_INDEX;
    }/*from   www  .j a  va  2s .co m*/

    int windowSize = mWindows.size();
    for (int i = 0; i < windowSize; i++) {
        if (windowInfo.equals(mWindows.get(i))) {
            return i;
        }
    }

    return WRONG_INDEX;
}

From source file:com.android.screenspeak.controller.CursorControllerApp.java

private boolean navigateToNextApplicationWindow(int direction) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        WindowManager windowsManager = new WindowManager();
        windowsManager.setWindows(mService.getWindows());
        if (!windowsManager.isApplicationWindowFocused()) {
            return false;
        }/*from w  ww.j av  a  2s . c om*/

        AccessibilityWindowInfo currentWindow = windowsManager.getCurrentWindow();
        if (currentWindow == null) {
            return false;
        }

        AccessibilityWindowInfo targetWindow = null;
        AccessibilityWindowInfo pivotWindow = currentWindow;
        while (!currentWindow.equals(targetWindow)) {
            switch (direction) {
            case NodeFocusFinder.SEARCH_FORWARD:
                targetWindow = windowsManager.getNextWindow(pivotWindow);
                break;
            case NodeFocusFinder.SEARCH_BACKWARD:
                targetWindow = windowsManager.getPreviousWindow(pivotWindow);
                break;
            }

            pivotWindow = targetWindow;

            if (targetWindow == null) {
                return false;
            }

            if (targetWindow.getType() != AccessibilityWindowInfo.TYPE_APPLICATION) {
                continue;
            }

            AccessibilityNodeInfo windowRoot = targetWindow.getRoot();
            if (windowRoot == null) {
                continue;
            }

            AccessibilityNodeInfoCompat compatRoot = new AccessibilityNodeInfoCompat(windowRoot);
            TraversalStrategy traversalStrategy = new OrderedTraversalStrategy(compatRoot);
            if (navigateWrapAround(compatRoot, direction, traversalStrategy)) {
                return true;
            }
        }
    }

    return false;
}

From source file:com.android.talkback.controller.CursorControllerApp.java

private boolean navigateToNextOrPreviousWindow(@TraversalStrategy.SearchDirection int direction,
        int windowTypeFilter, int focusStrategy, boolean useInputFocusAsPivot, int inputMode) {
    if (!mIsWindowNavigationAvailable) {
        return false;
    }/*w w w  .  j  av  a 2  s  . co m*/

    WindowManager windowManager = new WindowManager(mService.isScreenLayoutRTL());
    windowManager.setWindows(mService.getWindows());

    AccessibilityWindowInfo pivotWindow = windowManager.getCurrentWindow(useInputFocusAsPivot);
    if (pivotWindow == null || !matchWindowType(pivotWindow, windowTypeFilter)) {
        return false;
    }

    AccessibilityWindowInfo targetWindow = pivotWindow;
    while (true) {
        @TraversalStrategy.SearchDirection
        int logicalDirection = TraversalStrategyUtils.getLogicalDirection(direction,
                mService.isScreenLayoutRTL());
        if (logicalDirection == TraversalStrategy.SEARCH_FOCUS_FORWARD) {
            targetWindow = windowManager.getNextWindow(targetWindow);
        } else if (logicalDirection == TraversalStrategy.SEARCH_FOCUS_BACKWARD) {
            targetWindow = windowManager.getPreviousWindow(targetWindow);
        } else {
            throw new IllegalStateException("Unknown logical direction");
        }

        if (targetWindow == null || pivotWindow.equals(targetWindow)) {
            return false;
        }

        if (!matchWindowType(targetWindow, windowTypeFilter)) {
            continue;
        }

        AccessibilityNodeInfo windowRoot = targetWindow.getRoot();
        if (windowRoot == null) {
            continue;
        }

        AccessibilityNodeInfoCompat compatRoot = new AccessibilityNodeInfoCompat(windowRoot);

        if (focusStrategy == FOCUS_STRATEGY_RESUME_FOCUS) {
            if (resumeLastFocus(targetWindow.getId(), inputMode)) {
                return true;
            }

            // If it cannot resume last focus, try to focus the first focusable element.
            TraversalStrategy traversalStrategy = TraversalStrategyUtils.getTraversalStrategy(compatRoot,
                    TraversalStrategy.SEARCH_FOCUS_FORWARD);
            if (navigateWrapAround(compatRoot, TraversalStrategy.SEARCH_FOCUS_FORWARD, traversalStrategy,
                    inputMode)) {
                return true;
            }
        } else {
            TraversalStrategy traversalStrategy = TraversalStrategyUtils.getTraversalStrategy(compatRoot,
                    direction);
            if (navigateWrapAround(compatRoot, direction, traversalStrategy, inputMode)) {
                return true;
            }
        }
    }
}