Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD

List of usage examples for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD.

Prototype

int ACTION_SCROLL_FORWARD

To view the source code for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD.

Click Source Link

Document

Action to scroll the node content forward.

Usage

From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java

ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, AccessibilityNodeInfo fromInfo) {
    // Bookkeeping
    this.id = id;
    this.parentId = (parent != null) ? parent.getId() : null;

    // API 18+ properties
    this.resourceName = AT_18 ? fromInfo.getViewIdResourceName() : null;
    this.editable = AT_18 ? fromInfo.isEditable() : null;

    // API 16+ properties
    this.visibleToUser = AT_16 ? fromInfo.isVisibleToUser() : null;

    // Base properties
    this.className = fromInfo.getClassName();
    this.packageName = fromInfo.getPackageName();
    this.accessibilityClassName = fromInfo.getClassName();
    this.contentDescription = SpannableString.valueOf(fromInfo.getContentDescription());
    this.text = SpannableString.valueOf(fromInfo.getText());
    this.importantForAccessibility = true;
    this.clickable = fromInfo.isClickable();
    this.longClickable = fromInfo.isLongClickable();
    this.focusable = fromInfo.isFocusable();
    this.scrollable = fromInfo.isScrollable();
    this.canScrollForward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0);
    this.canScrollBackward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0);
    this.checkable = fromInfo.isCheckable();
    this.checked = fromInfo.isChecked();
    this.hasTouchDelegate = false; /* Touch delegates are not considered by AccessibilityServices */
    android.graphics.Rect tempRect = new android.graphics.Rect();
    fromInfo.getBoundsInScreen(tempRect);
    this.boundsInScreen = new Rect(tempRect);
    this.nonclippedHeight = null; /* AccessibilityServices cannot discover nonclipped dimensions */
    this.nonclippedWidth = null; /* AccessibilityServices cannot discover nonclipped dimensions */
    this.textSize = null;
    this.textColor = null;
    this.backgroundDrawableColor = null;
    this.typefaceStyle = null;
    this.enabled = fromInfo.isEnabled();
}

From source file:com.android.datetimepicker.time.RadialPickerLayout.java

private void installAccessibilityDelegate() {
    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() {
        /**//from  www .jav a  2 s .co  m
         * Necessary for accessibility, to ensure we support "scrolling" forward and backward
         * in the circle.
         */
        @Override
        public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
            super.onInitializeAccessibilityNodeInfo(host, info);
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
    });
}

From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java

private boolean onPanRightOverflowInternal(DisplayManager.Content content) {
    AccessibilityNodeInfoCompat currentNode = getFocusedNode(true);
    try {/* w  ww.  jav  a 2s  .  c o m*/
        if (currentNode != null && WebInterfaceUtils.hasWebContent(currentNode)
                && WebInterfaceUtils.performNavigationAtGranularityAction(currentNode, DIRECTION_FORWARD,
                        AccessibilityNodeInfoCompat.MOVEMENT_GRANULARITY_LINE)) {
            return true;
        }

        // Check if we need to scroll.
        if (autoScrollItem(currentNode, AccessibilityNodeInfo.ACTION_SCROLL_FORWARD)) {
            return true;
        }
    } finally {
        AccessibilityNodeInfoUtils.recycleNodes(currentNode);
    }
    AccessibilityNodeInfoRef target = findNodeForPanRight(content);
    if (AccessibilityNodeInfoRef.isNull(target)) {
        return false;
    }
    try {
        return target.get().performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
    } finally {
        target.recycle();
    }
}

From source file:com.googlecode.eyesfree.brailleback.TreeDebugNavigationMode.java

private CharSequence formatNode(AccessibilityNodeInfo node) {
    StringBuilder sb = new StringBuilder();
    sb.append(node.getWindowId());// w  ww  .j a va2s  . c o m
    if (node.getClassName() != null) {
        appendSimpleName(sb, node.getClassName());
    } else {
        sb.append("??");
    }
    if (!node.isVisibleToUser()) {
        sb.append(":invisible");
    }
    if (node.getText() != null) {
        sb.append(":");
        sb.append(node.getText());
    }
    if (node.getContentDescription() != null) {
        sb.append(":");
        sb.append(node.getContentDescription());
    }
    int actions = node.getActions();
    if (actions != 0) {
        sb.append(":");
        if ((actions & AccessibilityNodeInfo.ACTION_FOCUS) != 0) {
            sb.append("F");
        }
        if ((actions & AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS) != 0) {
            sb.append("A");
        }
        if ((actions & AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS) != 0) {
            sb.append("a");
        }
        if ((actions & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0) {
            sb.append("-");
        }
        if ((actions & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0) {
            sb.append("+");
        }
    }
    if (node.isCheckable()) {
        sb.append(":");
        if (node.isChecked()) {
            sb.append("(X)");
        } else {
            sb.append("( )");
        }
    }
    if (node.isFocusable()) {
        sb.append(":focusable");
    }
    if (node.isFocused()) {
        sb.append(":focused");
    }
    if (node.isSelected()) {
        sb.append(":selected");
    }
    if (node.isClickable()) {
        sb.append(":clickable");
    }
    if (node.isLongClickable()) {
        sb.append(":longClickable");
    }
    if (node.isAccessibilityFocused()) {
        sb.append(":accessibilityFocused");
    }
    if (!node.isEnabled()) {
        sb.append(":disabled");
    }
    return sb.toString();
}

From source file:com.google.android.marvin.mytalkback.ProcessorFocusAndSingleTap.java

private void handleViewScrolled(AccessibilityEvent event, AccessibilityRecordCompat record) {
    mLastViewScrolledEvent = event.getEventTime();

    final AccessibilityNodeInfoCompat source = record.getSource();
    if (source == null) {
        LogUtils.log(this, Log.ERROR, "Drop scroll with no source node");
        return;/* ww w  . j av a  2 s .  com*/
    }

    // Only move focus if we've already seen the source.
    if (source.equals(mLastScrollSource)) {
        final boolean isMovingForward = (mLastScrollAction == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD)
                || (event.getFromIndex() > mLastScrollFromIndex) || (event.getToIndex() > mLastScrollToIndex);
        final boolean wasScrollAction = (mLastScrollAction != 0);
        mHandler.followScrollDelayed(source, isMovingForward, wasScrollAction);

        // Performing a scroll action results in smooth scrolling, which may
        // send multiple events spaced at least 100ms apart.
        mHandler.clearScrollActionDelayed();
    } else {
        setScrollActionImmediately(0);
    }

    if (mLastScrollSource != null) {
        mLastScrollSource.recycle();
    }

    mLastScrollSource = source;
    mLastScrollFromIndex = record.getFromIndex();
    mLastScrollToIndex = record.getToIndex();
}

From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java

private int getScrollActionDirection(int scrollAction) {
    if (scrollAction == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) {
        return MOVING_FORWARDS;
    }//www.  j  a va 2 s .  com

    if (scrollAction == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
        return MOVING_BACKWARDS;
    }

    return MOVING_UNDEFINED_DIRECTION;
}

From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java

private boolean navigateItem(int direction) {
    AccessibilityNodeInfoCompat currentNode = getFocusedNode(true);
    try {//from  w w w.j  a  v  a  2  s  .  c o m
        if (currentNode != null && WebInterfaceUtils.hasWebContent(currentNode)
                && WebInterfaceUtils.performNavigationByDOMObject(currentNode, direction)) {
            return true;
        }
        // Check if we need to scroll.
        int scrollDirection = (direction == DIRECTION_FORWARD) ? AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
                : AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
        if (autoScrollItem(currentNode, scrollDirection)) {
            return true;
        }
        return moveFocus(currentNode, direction);
    } finally {
        AccessibilityNodeInfoUtils.recycleNodes(currentNode);
    }
}

From source file:com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.java

/**
 * When scroll forward/backward events are received, announce the newly scrolled-to month.
 *///  ww w.  java2  s  . co m
@SuppressLint("NewApi")
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (action != AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
            && action != AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
        return super.performAccessibilityAction(action, arguments);
    }

    // Figure out what month is showing.
    int firstVisiblePosition = getPagerPosition();
    int month = firstVisiblePosition % 12;
    int year = firstVisiblePosition / 12 + mController.getMinYear();
    CalendarDay day = new CalendarDay(year, month, 1);

    // Scroll either forward or backward one month.
    if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) {
        day.month++;
        if (day.month == 12) {
            day.month = 0;
            day.year++;
        }
    } else if (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) {
        View firstVisibleView = getChildAt(0);
        // If the view is fully visible, jump one month back. Otherwise, we'll just jump
        // to the first day of first visible month.
        if (firstVisibleView != null && firstVisibleView.getTop() >= -1) {
            // There's an off-by-one somewhere, so the top of the first visible item will
            // actually be -1 when it's at the exact top.
            day.month--;
            if (day.month == -1) {
                day.month = 11;
                day.year--;
            }
        }
    }

    // Go to that month.
    Utils.tryAccessibilityAnnounce(this, getMonthAndYearString(day));
    goTo(day, true, false, true);
    return true;
}

From source file:com.googlecode.eyesfree.brailleback.DefaultNavigationMode.java

@Override
public boolean onMappedInputEvent(BrailleInputEvent event, DisplayManager.Content content) {
    switch (event.getCommand()) {
    case BrailleInputEvent.CMD_NAV_ITEM_PREVIOUS:
        return itemPrevious();
    case BrailleInputEvent.CMD_NAV_ITEM_NEXT:
        return itemNext();
    case BrailleInputEvent.CMD_NAV_LINE_PREVIOUS:
        return linePrevious(content);
    case BrailleInputEvent.CMD_NAV_LINE_NEXT:
        return lineNext(content);
    case BrailleInputEvent.CMD_ACTIVATE_CURRENT:
        // Activate the current node, but don't fall back on the
        // root if focus is cleared.
        return mFeedbackManager.emitOnFailure(activateNode(getFocusedNode(false)),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_LONG_PRESS_CURRENT:
        // Long click the current node, but don't fall back on the
        // root if focus is cleared.
        return mFeedbackManager.emitOnFailure(longClickNode(getFocusedNode(false)),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_ROUTE: {
        AccessibilityNodeInfoCompat node = DisplaySpans.getAccessibilityNodeFromPosition(event.getArgument(),
                content.getText());//from   w  ww .  j a v a2  s . c  o  m
        return mFeedbackManager.emitOnFailure(activateNode(node, event.getArgument()),
                FeedbackManager.TYPE_COMMAND_FAILED);
    }
    case BrailleInputEvent.CMD_LONG_PRESS_ROUTE: {
        AccessibilityNodeInfoCompat node = DisplaySpans.getAccessibilityNodeFromPosition(event.getArgument(),
                content.getText());
        return mFeedbackManager.emitOnFailure(longClickNode(node), FeedbackManager.TYPE_COMMAND_FAILED);
    }
    case BrailleInputEvent.CMD_SCROLL_FORWARD:
        return mFeedbackManager.emitOnFailure(attemptScrollAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_SCROLL_BACKWARD:
        return mFeedbackManager.emitOnFailure(attemptScrollAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_NAV_TOP:
        return mFeedbackManager.emitOnFailure(attemptNavigateTop(), FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_NAV_BOTTOM:
        return mFeedbackManager.emitOnFailure(attemptNavigateBottom(), FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_SECTION_NEXT:
        return mFeedbackManager.emitOnFailure(
                navigateHTMLElementAction(DIRECTION_FORWARD, HTML_ELEMENT_MOVE_BY_SECTION),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_SECTION_PREVIOUS:
        return mFeedbackManager.emitOnFailure(
                navigateHTMLElementAction(DIRECTION_BACKWARD, HTML_ELEMENT_MOVE_BY_SECTION),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_CONTROL_NEXT:
        return mFeedbackManager.emitOnFailure(
                navigateHTMLElementAction(DIRECTION_FORWARD, HTML_ELEMENT_MOVE_BY_CONTROL),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_CONTROL_PREVIOUS:
        return mFeedbackManager.emitOnFailure(
                navigateHTMLElementAction(DIRECTION_BACKWARD, HTML_ELEMENT_MOVE_BY_CONTROL),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_LIST_NEXT:
        return mFeedbackManager.emitOnFailure(
                navigateHTMLElementAction(DIRECTION_FORWARD, HTML_ELEMENT_MOVE_BY_LIST),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_LIST_PREVIOUS:
        return mFeedbackManager.emitOnFailure(
                navigateHTMLElementAction(DIRECTION_BACKWARD, HTML_ELEMENT_MOVE_BY_LIST),
                FeedbackManager.TYPE_COMMAND_FAILED);
    case BrailleInputEvent.CMD_TOGGLE_INCREMENTAL_SEARCH:
        return handleIncrementalSearchAction();
    }
    return false;
}

From source file:com.tasomaniac.openwith.resolver.ResolverDrawerLayout.java

@Override
public boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle args) {
    if (super.onNestedPrePerformAccessibilityAction(target, action, args)) {
        return true;
    }//from   w  w  w  .  j  a  v  a2s. c om

    if (action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD && mCollapseOffset != 0) {
        smoothScrollTo(0, 0);
        return true;
    }
    return false;
}