List of usage examples for android.view.accessibility AccessibilityEvent getToIndex
public int getToIndex()
From source file:com.android.screenspeak.controller.TextCursorControllerApp.java
private void processTextSelectionChange(AccessibilityEvent event) { AccessibilityNodeInfo node = event.getSource(); if (node == null) { clear();//from w w w .jav a 2s.c o m return; } AccessibilityNodeInfoCompat compat = new AccessibilityNodeInfoCompat(node); if (compat.equals(mNode)) { mPreviousCursorPosition = mCurrentCursorPosition; mCurrentCursorPosition = event.getToIndex(); } else { clear(); mNode = compat; mCurrentCursorPosition = event.getToIndex(); } }
From source file:com.android.screenspeak.SavedNode.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_WINDOWS_CHANGED: clearCache();//from www .j a v a 2 s.c o m break; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: AccessibilityNodeInfo source = event.getSource(); if (source != null) { AccessibilityNodeInfoCompat copyNode = new AccessibilityNodeInfoCompat( AccessibilityNodeInfo.obtain(source)); Selection selection = new Selection(event.getFromIndex(), event.getToIndex()); mSelectionCache.put(copyNode, selection); } break; } }
From source file:com.android.talkback.eventprocessor.ProcessorScrollPosition.java
private CharSequence getDescriptionForScrollEvent(AccessibilityEvent event) { // If the from index or item count are invalid, don't announce anything. final int fromIndex = (event.getFromIndex() + 1); final int itemCount = event.getItemCount(); if ((fromIndex <= 0) || (itemCount <= 0)) { return null; }/*from w ww . j ava 2s.c om*/ // If the to and from indices are the same, or if the to index is // invalid, only announce the item at the from index. final int toIndex = event.getToIndex() + 1; if ((fromIndex == toIndex) || (toIndex <= 0) || (toIndex > itemCount)) { return mContext.getString(R.string.template_scroll_from_count, fromIndex, itemCount); } // Announce the range of visible items. return mContext.getString(R.string.template_scroll_from_to_count, fromIndex, toIndex, itemCount); }
From source file:com.android.screenspeak.eventprocessor.ProcessorScrollPosition.java
private CharSequence getDescriptionForScrollEvent(AccessibilityEvent event) { // If the event has text, use that by default. final CharSequence text = AccessibilityEventUtils.getEventTextOrDescription(event); if (!TextUtils.isEmpty(text)) { return text; }//from www . j a v a 2 s . co m // If the from index or item count are invalid, don't announce anything. final int fromIndex = (event.getFromIndex() + 1); final int itemCount = event.getItemCount(); if ((fromIndex <= 0) || (itemCount <= 0)) { return null; } // If the to and from indices are the same, or if the to index is // invalid, only announce the item at the from index. final int toIndex = event.getToIndex() + 1; if ((fromIndex == toIndex) || (toIndex <= 0) || (toIndex > itemCount)) { return mContext.getString(R.string.template_scroll_from_count, fromIndex, itemCount); } // Announce the range of visible items. return mContext.getString(R.string.template_scroll_from_to_count, fromIndex, toIndex, itemCount); }
From source file:com.android.screenspeak.eventprocessor.ProcessorFocusAndSingleTap.java
private int getScrollDirection(AccessibilityEvent event) { //check scroll of AdapterViews if (event.getFromIndex() > mLastScrollFromIndex || event.getToIndex() > mLastScrollToIndex) { return MOVING_FORWARDS; } else if (event.getFromIndex() < mLastScrollFromIndex || event.getToIndex() < mLastScrollToIndex) { return MOVING_BACKWARDS; }//from w w w .ja va2 s . c o m //check scroll of ScrollViews if (event.getScrollX() > mLastScrollX || event.getScrollY() > mLastScrollY) { return MOVING_FORWARDS; } else if (event.getScrollX() < mLastScrollX || event.getScrollY() < mLastScrollY) { return MOVING_BACKWARDS; } return MOVING_UNDEFINED_DIRECTION; }
From source file:com.android.talkback.eventprocessor.ProcessorFocusAndSingleTap.java
private @TraversalStrategy.SearchDirectionOrUnknown int getScrollDirection(AccessibilityEvent event) { //check scroll of AdapterViews if (event.getFromIndex() > mLastScrollFromIndex || event.getToIndex() > mLastScrollToIndex) { return TraversalStrategy.SEARCH_FOCUS_FORWARD; } else if (event.getFromIndex() < mLastScrollFromIndex || event.getToIndex() < mLastScrollToIndex) { return TraversalStrategy.SEARCH_FOCUS_BACKWARD; }/*from w w w .j a va2s . c o m*/ //check scroll of ScrollViews if (event.getScrollX() > mLastScrollX || event.getScrollY() > mLastScrollY) { return TraversalStrategy.SEARCH_FOCUS_FORWARD; } else if (event.getScrollX() < mLastScrollX || event.getScrollY() < mLastScrollY) { return TraversalStrategy.SEARCH_FOCUS_BACKWARD; } return TraversalStrategy.SEARCH_FOCUS_UNKNOWN; }
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;//from w w w . j a v a2s . c o m } // 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(); }