Java Code Examples for android.view.accessibility.AccessibilityEvent#setClassName()

The following examples show how to use android.view.accessibility.AccessibilityEvent#setClassName() . 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: DirectionalViewpager.java    From BookReader with Apache License 2.0 6 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(DirectionalViewpager.class.getName());
    AccessibilityRecordCompat recordCompat = null;
    if (isHorizontal()) {
        recordCompat =
                AccessibilityEventCompat.asRecord(event);
    } else {
        recordCompat = AccessibilityRecordCompat.obtain();
    }
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example 2
Source File: ExploreByTouchHelper.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
/**
 * Constructs and returns an {@link AccessibilityEvent} populated with
 * information about the specified item.
 *
 * @param virtualViewId The virtual view id for the item for which to
 *            construct an event.
 * @param eventType The type of event to construct.
 * @return An {@link AccessibilityEvent} populated with information about
 *         the specified item.
 */
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    onPopulateEventForVirtualView(virtualViewId, event);

    // Make sure the developer is following the rules.
    if (event.getText().isEmpty() && (event.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateEventForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    event.setPackageName(mView.getContext().getPackageName());

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mView, virtualViewId);

    return event;
}
 
Example 3
Source File: ViewPagerEx.java    From UltimateAndroid 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(ViewPagerEx.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example 4
Source File: CustomViewPager.java    From AsteroidOSSync with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(CustomViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat =
            AccessibilityEventCompat.asRecord(event);
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example 5
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPopulateEventForVirtualView(int virtualViewId, AccessibilityEvent event) {
    if (mVirtualViews == null || mVirtualViews.size() <= virtualViewId) {
        // TODO(clholgat): Remove this work around when the Android bug is fixed.
        // crbug.com/420177
        event.setContentDescription(PLACE_HOLDER_STRING);
        return;
    }
    VirtualView view = mVirtualViews.get(virtualViewId);

    event.setContentDescription(view.getAccessibilityDescription());
    event.setClassName(CompositorViewHolder.class.getName());
}
 
Example 6
Source File: OrientedViewPager.java    From FlippableStackView 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(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example 7
Source File: ViewPagerCompat.java    From android-auto-scroll-viewpager 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(ViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example 8
Source File: NumberPicker.java    From zen4android with MIT License 5 votes vote down vote up
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
        String text) {
    if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.setClassName(Button.class.getName());
        event.setPackageName(getContext().getPackageName());
        event.getText().add(text);
        event.setEnabled(NumberPicker.this.isEnabled());
        event.setSource(NumberPicker.this, virtualViewId);
        requestSendAccessibilityEvent(NumberPicker.this, event);
    }
}
 
Example 9
Source File: JsWindow.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
private void trySendAccessibilityEvent() {
	AccessibilityManager accessibilityManager = AccessibilityManager
			.getInstance(mView.getContext());
	if (!accessibilityManager.isEnabled()) {
		return;
	}
	// treat toasts as notifications since they are used to
	// announce a transient piece of information to the user
	AccessibilityEvent event = AccessibilityEvent
			.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
	event.setClassName(getClass().getName());
	event.setPackageName(mView.getContext().getPackageName());
	mView.dispatchPopulateAccessibilityEvent(event);
	accessibilityManager.sendAccessibilityEvent(event);
}
 
Example 10
Source File: NumberPicker.java    From DateTimePicker with Apache License 2.0 5 votes vote down vote up
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
                                                    String text) {
    //if (AccessibilityManager.getInstance(mContext).isEnabled()) {
    if (accessibilityManager != null && accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.setClassName(Button.class.getName());
        event.setPackageName(getContext().getPackageName());
        event.getText().add(text);
        event.setEnabled(NumberPicker.this.isEnabled());
        AccessibilityRecordCompat.setSource(event, NumberPicker.this, virtualViewId);
        //event.setSource(NumberPicker.this, virtualViewId);
        requestSendAccessibilityEvent(NumberPicker.this, event);
    }
}
 
Example 11
Source File: NumberPicker.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(NumberPicker.class.getName());
    event.setScrollable(true);
    event.setScrollY((mMinValue + mValue) * mSelectorElementHeight);
    event.setMaxScrollY((mMaxValue - mMinValue) * mSelectorElementHeight);
}
 
Example 12
Source File: VelocityViewPager.java    From VelocityViewPager 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(VelocityViewPager.class.getName());
    final AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(mAdapter.getCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
Example 13
Source File: TextureRenderView.java    From ParsingPlayer with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(TextureRenderView.class.getName());
}
 
Example 14
Source File: MaterialButton.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent accessibilityEvent) {
  super.onInitializeAccessibilityEvent(accessibilityEvent);
  accessibilityEvent.setClassName(getA11yClassName());
  accessibilityEvent.setChecked(isChecked());
}
 
Example 15
Source File: SlidingDrawer.java    From flickr-uploader with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
	super.onInitializeAccessibilityEvent(event);
	event.setClassName(SlidingDrawer.class.getName());
}
 
Example 16
Source File: VideoControllerView.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(VideoControllerView.class.getName());
}
 
Example 17
Source File: SlidingPaneLayout.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);

    event.setClassName(SlidingPaneLayout.class.getName());
}
 
Example 18
Source File: AccessibleLinearLayout.java    From date_picker_converter with Apache License 2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(Button.class.getName());
}
 
Example 19
Source File: HorizontalViewPager.java    From DoubleViewPager with Apache License 2.0 4 votes vote down vote up
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
}