Example usage for android.view.accessibility AccessibilityEvent TYPE_WINDOW_CONTENT_CHANGED

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

Introduction

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

Prototype

int TYPE_WINDOW_CONTENT_CHANGED

To view the source code for android.view.accessibility AccessibilityEvent TYPE_WINDOW_CONTENT_CHANGED.

Click Source Link

Document

Represents the event of changing the content of a window and more specifically the sub-tree rooted at the event's source.

Usage

From source file:com.android.screenspeak.formatter.LiveViewFormatter.java

@Override
public boolean accept(AccessibilityEvent event, ScreenSpeakService context) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED)
        return false;

    AccessibilityNodeInfoCompat node = new AccessibilityNodeInfoCompat(event.getSource());
    if (node.getInfo() == null) {
        return false;
    }/*from w  ww.j a  v a2 s .  c om*/

    int liveRegion = node.getLiveRegion();
    switch (liveRegion) {
    case View.ACCESSIBILITY_LIVE_REGION_POLITE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_NONE:
        return false;
    default:
        return false;
    }
}

From source file:com.android.talkback.formatter.LiveViewFormatter.java

@Override
public boolean accept(AccessibilityEvent event, TalkBackService context) {
    if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED)
        return false;

    AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    AccessibilityNodeInfoCompat node = record.getSource();
    if (node == null) {
        return false;
    }/*from  w  w w. j  a va2s  . c  om*/

    int liveRegion = node.getLiveRegion();
    node.recycle();

    switch (liveRegion) {
    case View.ACCESSIBILITY_LIVE_REGION_POLITE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
        return true;
    case View.ACCESSIBILITY_LIVE_REGION_NONE:
        return false;
    default:
        return false;
    }
}

From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    if (!(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED == event.getEventType())) {
        return;/*from w  w  w .ja v  a 2  s .co m*/
    }
    Log.d(Constants.TAG, "TYPE_WINDOW_CONTENT_CHANGED");

    // This AccessibilityNodeInfo represents the view that fired the
    // AccessibilityEvent. The following code will use it to traverse the
    // view hierarchy, using this node as a starting point.
    //
    // NOTE: Every method that returns an AccessibilityNodeInfo may return null,
    // because the explored window is in another process and the
    // corresponding View might be gone by the time your request reaches the
    // view hierarchy.
    //        AccessibilityNodeInfo source = event.getSource();

    // TODO: start with "com.google.android.gm:id/conversation" ?
    AccessibilityNodeInfo source = getRootInActiveWindow();
    if (source == null) {
        return;
    }
    closeOverlay();

    ArrayList<AccessibilityNodeInfo> pgpNodes = new ArrayList<>();
    findPgpNodeInfo(source, pgpNodes);
    for (final AccessibilityNodeInfo node : pgpNodes) {
        Log.d(Constants.TAG, "node=" + node);

        drawOverlay(node, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                decryptWithOpenKeychain(node);
            }
        });
    }
}

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

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 };
}

From source file:com.android.yijiang.kzx.widget.betterpickers.TouchExplorationHelper.java

/**
 * Invalidates cached information about the parent view. <p> You <b>must</b> call this method after adding or
 * removing items from the parent view. </p>
 *///from ww  w . j  a va 2s.  c om
public void invalidateParent() {
    mParentView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}

From source file:com.android.screenspeak.eventprocessor.ProcessorScrollPosition.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (shouldIgnoreEvent(event)) {
        return;/*from w w  w.j  a  va 2 s.c  o  m*/
    }

    switch (event.getEventType()) {
    case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
        // Window state changes clear the cache.
        mCachedFromValues.clear();
        mCachedItemCounts.clear();
        mHandler.cancelScrollFeedback();
        break;
    case AccessibilityEvent.TYPE_VIEW_SCROLLED:
    case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
        mHandler.postScrollFeedback(event);
        break;
    }
}

From source file:com.android.yijiang.kzx.widget.betterpickers.TouchExplorationHelper.java

/**
 * Invalidates cached information for a particular item. <p> You <b>must</b> call this method when any of the
 * properties set in {@link #populateNodeForItem(Object, AccessibilityNodeInfoCompat)} have changed. </p>
 *///from ww  w . jav a  2  s  .co  m
public void invalidateItem(T item) {
    sendEventForItem(item, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}

From source file:com.example.accessibility.OverlayManager.java

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {

    // TODO Auto-generated method stub
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
        if (mFCV != null) {
            destroyFeedbackClickView(mContext);
        }//from   w w w .j  ava  2 s. c o m
        showScrollButtons();

    }
}

From source file:com.android.screenspeak.formatter.CheckableClickedFormatter.java

@Override
public boolean accept(AccessibilityEvent event, ScreenSpeakService context) {
    int type = event.getEventType();

    if (type == AccessibilityEvent.TYPE_VIEW_CLICKED) {
        mClickedNode = null;/*from  w  ww .j  av a2s.  co m*/
        mClickedTime = -1;

        if (event.isChecked()) {
            return true;
        }

        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        AccessibilityNodeInfoCompat source = record.getSource();
        if (source != null) {
            if (source.isCheckable()) {
                return true;
            }

            // it is bug in settings application that does not include clicked state on node
            // so we need to restore it later from TYPE_WINDOW_CONTENT_CHANGED event
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mClickedNode = source;
                mClickedTime = System.currentTimeMillis();
            }
        }

        return false;
    }

    if (type == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
            return false;
        if (mClickedTime == -1 || mClickedNode == null)
            return false;

        long now = System.currentTimeMillis();
        if ((mClickedTime + 1000) < now) {
            mClickedTime = -1;
            if (mClickedNode != null) {
                mClickedNode.recycle();
                mClickedNode = null;
            }
            return false;
        }

        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        AccessibilityNodeInfoCompat source = record.getSource();
        return findClickedCheckableNode(source);
    }

    return false;
}

From source file:com.android.talkback.formatter.CheckableClickedFormatter.java

@Override
public boolean accept(AccessibilityEvent event, TalkBackService context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        return false;

    int type = event.getEventType();

    if (type == AccessibilityEvent.TYPE_VIEW_CLICKED) {
        mClickedNode = null;/*  w ww.jav  a  2 s.  c om*/
        mClickedTime = -1;

        if (event.isChecked()) {
            return true;
        }

        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        AccessibilityNodeInfoCompat source = record.getSource();
        if (source != null) {
            if (source.isCheckable()) {
                return true;
            }

            // it is bug in settings application that does not include clicked state on node
            // so we need to restore it later from TYPE_WINDOW_CONTENT_CHANGED event
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mClickedNode = source;
                mClickedTime = System.currentTimeMillis();
            }
        }

        return false;
    }

    if (type == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
            return false;
        if (mClickedTime == -1 || mClickedNode == null)
            return false;

        long now = System.currentTimeMillis();
        if ((mClickedTime + 1000) < now) {
            mClickedTime = -1;
            if (mClickedNode != null) {
                mClickedNode.recycle();
                mClickedNode = null;
            }
            return false;
        }

        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        AccessibilityNodeInfoCompat source = record.getSource();
        return findClickedCheckableNode(source);
    }

    return false;
}