Java Code Examples for android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SCROLLED

The following examples show how to use android.view.accessibility.AccessibilityEvent#TYPE_VIEW_SCROLLED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OversecAccessibilityService.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
public void setMonitorEventTypesAll() {
    Ln.d("SERVICE: setMonitorEventTypesAll");

    int mask = AccessibilityEvent.TYPE_WINDOWS_CHANGED
            | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
            | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED
            | AccessibilityEvent.TYPE_VIEW_SCROLLED;

    String packagename = mCore.getCurrentPackageName();

    if (packagename == null || mDb.isShowInfoOnTap(packagename)) {
        Ln.d("SERVICE: setMonitorEventTypesAll adding TYPE_VIEW_CLICKED");
        mask |= AccessibilityEvent.TYPE_VIEW_CLICKED;
    }
    if (packagename == null || mDb.isShowInfoOnLongTap(packagename) || mDb.isToggleEncryptButtonOnLongTap(packagename)) {
        Ln.d("SERVICE: setMonitorEventTypesAll adding TYPE_VIEW_LONG_CLICKED");
        mask |= AccessibilityEvent.TYPE_VIEW_LONG_CLICKED;
    }

    boolean includeNotImportantViews = packagename == null ? true : mDb.isIncludeNonImportantViews(packagename);

    setMonitorEventTypes(mask, includeNotImportantViews, true);


}
 
Example 2
Source File: YearPickerView.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 3
Source File: PagedView.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void sendAccessibilityEvent(int eventType) {
    // Don't let the view send real scroll events.
    if (eventType != AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        super.sendAccessibilityEvent(eventType);
    }
}
 
Example 4
Source File: YearPickerView.java    From cathode with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 5
Source File: YearPickerView.java    From date_picker_converter with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 6
Source File: SdkCenteredViewPager.java    From Android-SDK-Demo with MIT License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event)
{
    super.onInitializeAccessibilityEvent( host, event );
    event.setClassName( SdkCenteredViewPager.class.getName() );
    final AccessibilityRecord recordCompat = AccessibilityRecord.obtain();
    recordCompat.setScrollable( canScroll() );
    if ( event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED
            && mAdapter != null )
    {
        recordCompat.setItemCount( mAdapter.getCount() );
        recordCompat.setFromIndex( mCurItem );
        recordCompat.setToIndex( mCurItem );
    }
}
 
Example 7
Source File: SdkCenteredViewPager.java    From Android-SDK-Demo with MIT License 5 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
{
    // Dispatch scroll events from this ViewPager.
    if ( event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED )
    {
        return super.dispatchPopulateAccessibilityEvent( event );
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for ( int i = 0; i < childCount; i++ )
    {
        final View child = getChildAt( i );
        if ( child.getVisibility() == VISIBLE )
        {
            final ItemInfo ii = infoForChild( child );
            if ( ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent( event ) )
            {
                return true;
            }
        }
    }

    return false;
}
 
Example 8
Source File: YearPickerView.java    From AlarmOn with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 9
Source File: YearPickerView.java    From MaterialDateRangePicker with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 10
Source File: ProcessorCursorState.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onAccessibilityEvent(AccessibilityEvent event, EventId eventId) {
  switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
      // Keep track of the accessibility focused EditText.
      overlay.hide();
      saveFocusedNode(AccessibilityEventCompat.asRecord(event));
      break;
    case AccessibilityEvent.TYPE_VIEW_FOCUSED:
      // On pre Android O devices, double-tap on screen will interpreted as touch down and up
      // action at the center of the focused node, which might set cursor to the middle of text if
      // the text is long enough. TalkBack overrides the cursor position to be the end of the
      // field to avoid the confusion of cursor movement. See  for details.
      if (SHOULD_HANDLE_TOUCH_EVENT) {
        // Reset the EditText cursor because focusing will snap it to the middle.
        resetNodeCursor(AccessibilityEventCompat.asRecord(event), eventId);
      }
      break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
      // Hide the overlay so it doesn't interfere with scrolling.
      overlay.hide();
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
      if (SHOULD_HANDLE_TOUCH_EVENT) {
        // Show the overlay if the a11y-focused EditText is editing and we touch the screen.
        touchStart(event, eventId);
      }
      break;
    case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
      if (SHOULD_HANDLE_TOUCH_EVENT) {
        // Hide the overlay when we stop touching the screen.
        touchEnd(event, eventId);
      }
      break;
    default: // fall out
  }
}
 
Example 11
Source File: YearPickerView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
    super.onInitializeAccessibilityEventInternal(event);

    // There are a bunch of years, so don't bother.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 12
Source File: YearPickerView.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
Example 13
Source File: PagedView.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void sendAccessibilityEvent(int eventType) {
    // Don't let the view send real scroll events.
    if (eventType != AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        super.sendAccessibilityEvent(eventType);
    }
}
 
Example 14
Source File: YearPickerView.java    From AppCompat-Extension-Library with Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);

    // There are a bunch of years, so don't bother.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        AccessibilityEventCompat.asRecord(event).setFromIndex(0);
        AccessibilityEventCompat.asRecord(event).setToIndex(0);
    }
}
 
Example 15
Source File: NearbyAs.java    From WechatHook-Dusan with Apache License 2.0 5 votes vote down vote up
public synchronized void startNearby(AccessibilityEvent event, WechatService service, Context context) {
    if (this.context==null) {
        this.context = context;
    }
    int eventType = event.getEventType();
    String className = event.getClassName().toString();
    nodeInfo = CommonUtil.init().checkRootWindow(service);
    if (nodeInfo == null) return;
    ////判断什么时候向下滑动
    if (WechatUI.UI_NEARBY_FRIENDS.equals(className)
            ||WechatUI.CLASS_NAME_LIST_VIEW.equals(className)){
        if (handleMoveEvent()) return;
    }

    AccessibilityNodeInfo node_listview = AccessibilityHelper.findNodeInfosById(nodeInfo, WechatUI.ID_NEARBY_LIST_VIEW);
    if (node_listview!=null||AccessibilityEvent.TYPE_VIEW_SCROLLED==eventType) {
        handle_nearby_friends(service);
        getThumbHeight();
    }

    AccessibilityNodeInfo node_username = AccessibilityHelper.findNodeInfosById(nodeInfo, WechatUI.ID_USER_NAME);
    if (node_username!=null) {
        //if (isActionShort()) return;
        handle_contact_info(service);
    }

    AccessibilityNodeInfo node_editview = AccessibilityHelper.findNodeInfosById(nodeInfo, WechatUI.ID_SEND_HELLO_EDIT_VIEW);
    if (node_editview!=null||AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED==eventType) {
        handle_sayhi_edit(service);
    }
}
 
Example 16
Source File: PagedView.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
@Override
public void sendAccessibilityEvent(int eventType) {
    // Don't let the view send real scroll events.
    if (eventType != AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        super.sendAccessibilityEvent(eventType);
    }
}
 
Example 17
Source File: SliderPager.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(SliderPager.class.getName());
    event.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED && mAdapter != null) {
        event.setItemCount(mAdapter.getCount());
        event.setFromIndex(mCurItem);
        event.setToIndex(mCurItem);
    }
}
 
Example 18
Source File: AccessibilityEventUtils.java    From talkback with Apache License 2.0 5 votes vote down vote up
public static int[] getAllEventTypes() {
  return new int[] {
    AccessibilityEvent.TYPE_ANNOUNCEMENT,
    AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_END,
    AccessibilityEvent.TYPE_GESTURE_DETECTION_START,
    AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END,
    AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
    AccessibilityEvent.TYPE_TOUCH_INTERACTION_START,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED,
    AccessibilityEvent.TYPE_VIEW_CLICKED,
    AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED,
    AccessibilityEvent.TYPE_VIEW_FOCUSED,
    AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
    AccessibilityEvent.TYPE_VIEW_HOVER_EXIT,
    AccessibilityEvent.TYPE_VIEW_LONG_CLICKED,
    AccessibilityEvent.TYPE_VIEW_SCROLLED,
    AccessibilityEvent.TYPE_VIEW_SELECTED,
    AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED,
    AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY,
    AccessibilityEvent.TYPE_WINDOWS_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED,
    AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
  };
}
 
Example 19
Source File: CoolViewPager.java    From CoolViewPager with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(CoolViewPager.class.getName());
    event.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED && mAdapter != null) {
        event.setItemCount(mAdapter.getCount());
        event.setFromIndex(mCurItem);
        event.setToIndex(mCurItem);
    }
}
 
Example 20
Source File: EventRegister.java    From appium-uiautomator2-server with Apache License 2.0 4 votes vote down vote up
public static Boolean runAndRegisterScrollEvents(ReturningRunnable<Boolean> runnable, long timeout) {
    // turn off listening to notifications since it interferes with us listening for the scroll
    // event here
    NotificationListener listener = NotificationListener.getInstance();

    boolean notificationListenerActive = listener.isListening();
    if (notificationListenerActive) {
        listener.stop();
    }

    // here we set a callback for the accessibility event stream, keeping track of any scroll
    // events we come across
    AccessibilityEvent event = null;
    ArrayList<AccessibilityEvent> events = new ArrayList<>();
    UiAutomation.AccessibilityEventFilter filter = new EventCollectingPredicate(AccessibilityEvent.TYPE_VIEW_SCROLLED, events);
    UiAutomation automation = UiAutomatorBridge.getInstance().getUiAutomation();
    try {
        automation.executeAndWaitForEvent(runnable, filter, timeout);
    } catch (TimeoutException ign) {
        // ignore
    }

    // if we have caught any events in our net, snatch the last one
    if (events.size() > 0) {
        event = events.get(events.size() - 1);
    }

    Session session = AppiumUIA2Driver.getInstance().getSessionOrThrow();

    if (event == null) {
        Logger.debug("Did not retrieve accessibility event for scroll");
        session.setLastScrollData(null);
    } else {
        AccessibilityScrollData data = new AccessibilityScrollData(event);
        Logger.debug("Retrieved accessibility event for scroll: ", data);
        session.setLastScrollData(data);
    }

    // ensure we recycle all accessibility events once we no longer need them
    for (AccessibilityEvent eventToRecycle : events) {
        eventToRecycle.recycle();
    }

    // turn back on notification listener if it was active
    if (notificationListenerActive) {
        listener.start();
    }

    // finally, return whatever the runnable set as its result
    return runnable.getResult();
}