Search in sources :

Example 41 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ResurrectionRemix.

the class TextView method sendAccessibilityEventTypeViewTextChanged.

void sendAccessibilityEventTypeViewTextChanged(CharSequence beforeText, int fromIndex, int removedCount, int addedCount) {
    AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
    event.setFromIndex(fromIndex);
    event.setRemovedCount(removedCount);
    event.setAddedCount(addedCount);
    event.setBeforeText(beforeText);
    sendAccessibilityEventUnchecked(event);
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 42 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ResurrectionRemix.

the class View method clearAccessibilityFocusNoCallbacks.

/**
     * Clears accessibility focus without calling any callback methods
     * normally invoked in {@link #clearAccessibilityFocus()}. This method
     * is used separately from that one for clearing accessibility focus when
     * giving this focus to another view.
     *
     * @param action The action, if any, that led to focus being cleared. Set to
     * AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS to specify that focus is moving within
     * the window.
     */
void clearAccessibilityFocusNoCallbacks(int action) {
    if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) != 0) {
        mPrivateFlags2 &= ~PFLAG2_ACCESSIBILITY_FOCUSED;
        invalidate();
        if (AccessibilityManager.getInstance(mContext).isEnabled()) {
            AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
            event.setAction(action);
            if (mAccessibilityDelegate != null) {
                mAccessibilityDelegate.sendAccessibilityEventUnchecked(this, event);
            } else {
                sendAccessibilityEventUnchecked(event);
            }
        }
    }
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 43 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project android_frameworks_base by ResurrectionRemix.

the class View method announceForAccessibility.

/**
     * Convenience method for sending a {@link AccessibilityEvent#TYPE_ANNOUNCEMENT}
     * {@link AccessibilityEvent} to make an announcement which is related to some
     * sort of a context change for which none of the events representing UI transitions
     * is a good fit. For example, announcing a new page in a book. If accessibility
     * is not enabled this method does nothing.
     *
     * @param text The announcement text.
     */
public void announceForAccessibility(CharSequence text) {
    if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) {
        AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_ANNOUNCEMENT);
        onInitializeAccessibilityEvent(event);
        event.getText().add(text);
        event.setContentDescription(null);
        mParent.requestSendAccessibilityEvent(this, event);
    }
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 44 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ToggleFeaturePreferenceFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
    setPreferenceScreen(preferenceScreen);
    mSummaryPreference = new Preference(getPrefContext()) {

        @Override
        public void onBindViewHolder(PreferenceViewHolder view) {
            super.onBindViewHolder(view);
            view.setDividerAllowedAbove(false);
            view.setDividerAllowedBelow(false);
            final TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
            summaryView.setText(getSummary());
            sendAccessibilityEvent(summaryView);
        }

        private void sendAccessibilityEvent(View view) {
            // Since the view is still not attached we create, populate,
            // and send the event directly since we do not know when it
            // will be attached and posting commands is not as clean.
            AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getActivity());
            if (accessibilityManager.isEnabled()) {
                AccessibilityEvent event = AccessibilityEvent.obtain();
                event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);
                view.onInitializeAccessibilityEvent(event);
                view.dispatchPopulateAccessibilityEvent(event);
                accessibilityManager.sendAccessibilityEvent(event);
            }
        }
    };
    mSummaryPreference.setSelectable(false);
    mSummaryPreference.setPersistent(false);
    mSummaryPreference.setLayoutResource(R.layout.text_description_preference);
    preferenceScreen.addPreference(mSummaryPreference);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) AccessibilityManager(android.view.accessibility.AccessibilityManager) Preference(android.support.v7.preference.Preference) TextView(android.widget.TextView) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder) TextView(android.widget.TextView) View(android.view.View)

Example 45 with AccessibilityEvent

use of android.view.accessibility.AccessibilityEvent in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ExploreByTouchHelper method sendEventForVirtualView.

/**
     * Populates an event of the specified type with information about an item
     * and attempts to send it up through the view hierarchy.
     * <p>
     * You should call this method after performing a user action that normally
     * fires an accessibility event, such as clicking on an item.
     *
     * <pre>public void performItemClick(T item) {
     *   ...
     *   sendEventForVirtualViewId(item.id, AccessibilityEvent.TYPE_VIEW_CLICKED);
     * }
     * </pre>
     *
     * @param virtualViewId The virtual view id for which to send an event.
     * @param eventType The type of event to send.
     * @return true if the event was sent successfully.
     */
public boolean sendEventForVirtualView(int virtualViewId, int eventType) {
    if ((virtualViewId == INVALID_ID) || !mManager.isEnabled()) {
        return false;
    }
    final ViewParent parent = mView.getParent();
    if (parent == null) {
        return false;
    }
    final AccessibilityEvent event = createEvent(virtualViewId, eventType);
    return parent.requestSendAccessibilityEvent(mView, event);
}
Also used : ViewParent(android.view.ViewParent) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Aggregations

AccessibilityEvent (android.view.accessibility.AccessibilityEvent)234 AccessibilityManager (android.view.accessibility.AccessibilityManager)47 LargeTest (android.test.suitebuilder.annotation.LargeTest)40 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)20 ViewParent (android.view.ViewParent)13 TimeoutException (java.util.concurrent.TimeoutException)11 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)10 Notification (android.app.Notification)7 ITransientNotification (android.app.ITransientNotification)6 RemoteException (android.os.RemoteException)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 SuppressLint (android.annotation.SuppressLint)5 AccessibilityEventFilter (android.app.UiAutomation.AccessibilityEventFilter)5 OnAccessibilityEventListener (android.app.UiAutomation.OnAccessibilityEventListener)5 ViewGroup (android.view.ViewGroup)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5 SimpleDateFormat (java.text.SimpleDateFormat)5 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5