Example usage for android.view.accessibility AccessibilityEvent setClassName

List of usage examples for android.view.accessibility AccessibilityEvent setClassName

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent setClassName.

Prototype

public void setClassName(CharSequence className) 

Source Link

Document

Sets the class name of the source.

Usage

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

@Override
protected final void populateEventForVirtualViewId(int virtualViewId, AccessibilityEvent event) {
    final T item = getItemForVirtualViewId(virtualViewId);
    if (item == null) {
        return;/*  w  w  w. jav a 2s .com*/
    }

    populateEventForItem(item, event);
    event.setClassName(item.getClass().getName());
}

From source file:com.example.android.supportv4.media.MediaController.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(MediaController.class.getName());
}

From source file:com.onyx.latinime.accessibility.AccessibilityEntityProvider.java

/**
 * Creates and populates an {@link AccessibilityEvent} for the specified key
 * and event type.//w w w . j a  v  a  2  s .co m
 *
 * @param key A key on the host keyboard view.
 * @param eventType The event type to create.
 * @return A populated {@link AccessibilityEvent} for the key.
 * @see AccessibilityEvent
 */
public AccessibilityEvent createAccessibilityEvent(final Key key, final int eventType) {
    final int virtualViewId = generateVirtualViewIdForKey(key);
    final String keyDescription = getKeyDescription(key);
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setPackageName(mKeyboardView.getContext().getPackageName());
    event.setClassName(key.getClass().getName());
    event.setContentDescription(keyDescription);
    event.setEnabled(true);
    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    record.setSource(mKeyboardView, virtualViewId);
    return event;
}

From source file:com.android.inputmethod.accessibility.KeyboardAccessibilityNodeProvider.java

/**
 * Creates and populates an {@link AccessibilityEvent} for the specified key
 * and event type./*  w w  w.j  a v  a  2  s  .c  o  m*/
 *
 * @param key A key on the host keyboard view.
 * @param eventType The event type to create.
 * @return A populated {@link AccessibilityEvent} for the key.
 * @see AccessibilityEvent
 */
public AccessibilityEvent createAccessibilityEvent(final Key key, final int eventType) {
    final int virtualViewId = getVirtualViewIdOf(key);
    final String keyDescription = getKeyDescription(key);
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setPackageName(mKeyboardView.getContext().getPackageName());
    event.setClassName(key.getClass().getName());
    event.setContentDescription(keyDescription);
    event.setEnabled(true);
    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mKeyboardView, virtualViewId);
    return event;
}

From source file:com.android.hareime.accessibility.AccessibilityEntityProvider.java

/**
 * Creates and populates an {@link AccessibilityEvent} for the specified key
 * and event type.// ww  w  .j  a v  a 2 s .  c o m
 *
 * @param key A key on the host keyboard view.
 * @param eventType The event type to create.
 * @return A populated {@link AccessibilityEvent} for the key.
 * @see AccessibilityEvent
 */
public AccessibilityEvent createAccessibilityEvent(Key key, int eventType) {
    final int virtualViewId = generateVirtualViewIdForKey(key);
    final String keyDescription = getKeyDescription(key);

    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setPackageName(mKeyboardView.getContext().getPackageName());
    event.setClassName(key.getClass().getName());
    event.setContentDescription(keyDescription);
    event.setEnabled(true);

    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    record.setSource(mKeyboardView, virtualViewId);

    return event;
}

From source file:com.albedinsky.android.support.ui.widget.FrameLayoutWidget.java

/**
 *//* www. ja v a2 s .  c  o  m*/
@Override
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(FrameLayoutWidget.class.getName());
}

From source file:com.albedinsky.android.support.ui.widget.LinearLayoutWidget.java

/**
 *//*w w  w  .j av a  2s  .c o  m*/
@Override
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(LinearLayoutWidget.class.getName());
}

From source file:com.albedinsky.android.support.ui.widget.RelativeLayoutWidget.java

/**
 *///from w  ww .j  a  v  a  2  s  .c om
@Override
public void onInitializeAccessibilityEvent(@NonNull AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(RelativeLayoutWidget.class.getName());
}

From source file:org.connectbot.views.CheckableMenuItem.java

public CheckableMenuItem(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mRootView = inflate(context, R.layout.view_checkablemenuitem, this);

    mTitle = (TextView) mRootView.findViewById(R.id.title);
    mSummary = (TextView) mRootView.findViewById(R.id.summary);
    mSwitch = (SwitchCompat) findViewById(R.id.checkbox_switch);

    setFocusable(true);/*w  ww  .j  av  a2s . co m*/

    mAccessHelper = new ExploreByTouchHelper(this) {
        private final Rect mTmpRect = new Rect();

        @Override
        protected int getVirtualViewAt(float x, float y) {
            return HOST_ID;
        }

        @Override
        protected void getVisibleVirtualViews(List<Integer> virtualViewIds) {
        }

        @Override
        protected void onPopulateEventForVirtualView(int virtualViewId, AccessibilityEvent event) {
            if (virtualViewId != HOST_ID) {
                // TODO(kroot): remove this when the bug is fixed.
                event.setContentDescription(PLACEHOLDER_STRING);
                return;
            }

            event.setContentDescription(mTitle.getText() + " " + mSummary.getText());
            event.setClassName(ACCESSIBILITY_EVENT_CLASS_NAME);
            event.setChecked(isChecked());
        }

        @Override
        protected void onPopulateNodeForVirtualView(int virtualViewId, AccessibilityNodeInfoCompat node) {
            if (virtualViewId != HOST_ID) {
                // TODO(kroot): remove this when the bug is fixed.
                node.setBoundsInParent(mPlaceHolderRect);
                node.setContentDescription(PLACEHOLDER_STRING);
                return;
            }

            mTmpRect.set(0, 0, CheckableMenuItem.this.getWidth(), CheckableMenuItem.this.getHeight());
            node.setBoundsInParent(mTmpRect);

            node.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK);
            node.setClassName(ACCESSIBILITY_EVENT_CLASS_NAME);
            node.setCheckable(true);
            node.setChecked(isChecked());

            node.addChild(mTitle);
            node.addChild(mSummary);
        }

        @Override
        protected boolean onPerformActionForVirtualView(int virtualViewId, int action, Bundle arguments) {
            if (virtualViewId != HOST_ID) {
                return false;
            }

            if (action == AccessibilityNodeInfoCompat.ACTION_CLICK) {
                mSwitch.toggle();
                sendAccessibilityEvent(mRootView, AccessibilityEventCompat.CONTENT_CHANGE_TYPE_UNDEFINED);
                return true;
            }

            return false;
        }
    };
    ViewCompat.setAccessibilityDelegate(mRootView, mAccessHelper);

    setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSwitch.toggle();
        }
    });

    if (attrs != null) {
        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.CheckableMenuItem, 0, 0);

        @DrawableRes
        int iconRes = typedArray.getResourceId(R.styleable.CheckableMenuItem_android_icon, 0);
        @StringRes
        int titleRes = typedArray.getResourceId(R.styleable.CheckableMenuItem_android_title, 0);
        @StringRes
        int summaryRes = typedArray.getResourceId(R.styleable.CheckableMenuItem_summary, 0);

        typedArray.recycle();

        ImageView icon = (ImageView) mRootView.findViewById(R.id.icon);
        mTitle.setText(titleRes);
        if (iconRes != 0) {
            Resources resources = context.getResources();
            Resources.Theme theme = context.getTheme();
            Drawable iconDrawable = VectorDrawableCompat.create(resources, iconRes, theme);

            icon.setImageDrawable(iconDrawable);
        }
        if (summaryRes != 0) {
            mSummary.setText(summaryRes);
        }
    }
}

From source file:com.bangtoven.cookievideoview.CookieVideoView.java

@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(CookieVideoView.class.getName());
}