Example usage for android.view View sendAccessibilityEvent

List of usage examples for android.view View sendAccessibilityEvent

Introduction

In this page you can find the example usage for android.view View sendAccessibilityEvent.

Prototype

public void sendAccessibilityEvent(int eventType) 

Source Link

Document

Sends an accessibility event of the given type.

Usage

From source file:Main.java

public static void sendAccessibilityEvent(View view, int eventType) {
    view.sendAccessibilityEvent(eventType);
}

From source file:at.linuxtage.companion.widgets.SlidingTabLayout.java

static void setSelectedCompat(View view, boolean selected) {
    final boolean becomeSelected = selected && !view.isSelected();
    view.setSelected(selected);//from  w  w w. j  a v a 2s. c  om
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN && becomeSelected) {
        // Pre-JB we need to manually send the TYPE_VIEW_SELECTED event
        view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
    }
}

From source file:com.android.talkback.eventprocessor.ProcessorFocusAndSingleTapTest.java

private void sendAccessibilityEvent(final View view, final int eventId) {
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override//  ww w  .ja v  a 2s  .c  o m
        public void run() {
            view.sendAccessibilityEvent(eventId);
        }
    });
    getInstrumentation().waitForIdleSync();
    waitForAccessibilityIdleSync();
}

From source file:com.silentcircle.contacts.activities.ScContactDetailActivity.java

/**
 * Setup the activity title and subtitle with contact name and company.
 */// www  . jav  a  2  s.  c om
private void setupTitle() {
    CharSequence displayName = ContactDetailDisplayUtils.getDisplayName(this, mContactData);
    String company = ContactDetailDisplayUtils.getCompany(this, mContactData);

    ActionBar actionBar = this.getSupportActionBar();
    actionBar.setTitle(displayName);
    actionBar.setSubtitle(company);

    if (!TextUtils.isEmpty(displayName)) {
        AccessibilityManager accessibilityManager = (AccessibilityManager) this
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isEnabled()) {
            View decorView = getWindow().getDecorView();
            decorView.setContentDescription(displayName);
            decorView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
    }
}

From source file:com.jakewharton.behavior.drawer.BehaviorDelegate.java

private void dispatchOnDrawerClosed(View drawerView) {
    if ((openState & FLAG_IS_OPENED) == FLAG_IS_OPENED) {
        openState = 0;//from   www  . ja  va 2 s.c o  m

        updateChildrenImportantForAccessibility(drawerView, false);

        // Only send WINDOW_STATE_CHANGE if the host has window focus. This
        // may change if support for multiple foreground windows (e.g. IME)
        // improves.
        if (parent.hasWindowFocus()) {
            final View rootView = parent.getRootView();
            if (rootView != null) {
                rootView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
            }
        }
    }
}

From source file:org.chromium.chrome.browser.autofill.CardUnmaskPrompt.java

private void setInitialFocus() {
    InputMethodManager imm = (InputMethodManager) mDialog.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    View view = mShouldRequestExpirationDate ? mMonthInput : mCardUnmaskInput;
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    if (sObserverForTest != null) {
        sObserverForTest.onCardUnmaskPromptReadyForInput(this);
    }/*from w  w  w  .ja  v  a 2s  . c  o m*/
}

From source file:com.dm.xz.views.PinnedSectionListView.java

private boolean performPinnedItemClick() {
    if (mPinnedSection == null)
        return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null && getAdapter().isEnabled(mPinnedSection.position)) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }/*ww w.  j av  a2  s.  c  o m*/
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}

From source file:com.yahala.ui.Views.PinnedSectionListView.java

private boolean performPinnedItemClick() {
    if (mPinnedSection == null)
        return false;

    OnItemClickListener listener = getOnItemClickListener();
    if (listener != null) {
        View view = mPinnedSection.view;
        playSoundEffect(SoundEffectConstants.CLICK);
        if (view != null) {
            view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
        }//from w  ww.j  a  v a  2 s  . c  o  m
        listener.onItemClick(this, view, mPinnedSection.position, mPinnedSection.id);
        return true;
    }
    return false;
}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/**
 * Setup the activity title and subtitle with contact name and company.
 *///ww w  . jav a2 s.c  o m
private void setupTitle() {
    CharSequence displayName = ContactDetailDisplayUtils.getDisplayName(this, mContactData);
    String company = ContactDetailDisplayUtils.getCompany(this, mContactData);

    ActionBar actionBar = getActionBar();
    actionBar.setTitle(displayName);
    actionBar.setSubtitle(company);

    final StringBuilder talkback = new StringBuilder();
    if (!TextUtils.isEmpty(displayName)) {
        talkback.append(displayName);
    }
    if (!TextUtils.isEmpty(company)) {
        if (talkback.length() != 0) {
            talkback.append(", ");
        }
        talkback.append(company);
    }

    if (talkback.length() != 0) {
        AccessibilityManager accessibilityManager = (AccessibilityManager) this
                .getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isEnabled()) {
            View decorView = getWindow().getDecorView();
            decorView.setContentDescription(talkback);
            decorView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
    }
}

From source file:com.android.talkback.eventprocessor.AccessibilityEventProcessorTest.java

private void sendEvent(final int event, final CharSequence className) {
    final View outerView = getViewForId(R.id.outer_view);
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override// w w w.j  av  a2  s  .  c  o  m
        public void run() {
            outerView.setAccessibilityDelegate(new AccessibilityDelegate() {
                @Override
                public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
                    super.onInitializeAccessibilityEvent(host, event);
                    event.setClassName(className);
                }
            });
            outerView.sendAccessibilityEvent(event);
        }
    });
    getInstrumentation().waitForIdleSync();
    waitForAccessibilityIdleSync();
}