Example usage for android.view View ACCESSIBILITY_LIVE_REGION_ASSERTIVE

List of usage examples for android.view View ACCESSIBILITY_LIVE_REGION_ASSERTIVE

Introduction

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

Prototype

int ACCESSIBILITY_LIVE_REGION_ASSERTIVE

To view the source code for android.view View ACCESSIBILITY_LIVE_REGION_ASSERTIVE.

Click Source Link

Document

Live region mode specifying that accessibility services should interrupt ongoing speech to immediately announce changes to this view.

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  w  w.  ja v a2 s .c o m*/

    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;
    }/* www .  j av  a 2 s  . c  o  m*/

    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:com.android.screenspeak.formatter.LiveViewFormatter.java

@Override
public boolean format(AccessibilityEvent event, ScreenSpeakService context, Utterance utterance) {
    AccessibilityNodeInfoCompat node = new AccessibilityNodeInfoCompat(event.getSource());
    if (node.getInfo() == null) {
        return false;
    }// w w w.  java2  s.  c o  m

    int liveRegion = node.getLiveRegion();
    switch (liveRegion) {
    case View.ACCESSIBILITY_LIVE_REGION_POLITE:
        break;
    case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
        utterance.getMetadata().putInt(Utterance.KEY_METADATA_QUEUING, SpeechController.QUEUE_MODE_INTERRUPT);
        break;
    case View.ACCESSIBILITY_LIVE_REGION_NONE:
        return false;
    default:
        return false;
    }

    CharSequence text = NodeSpeechRuleProcessor.getInstance().getDescriptionForNode(node, event);

    if (TextUtils.isEmpty(text)) {
        return false;
    }

    utterance.addSpoken(text);
    utterance.addSpokenFlag(FeedbackItem.FLAG_SKIP_DUPLICATE);
    return true;
}

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

@Override
public boolean format(AccessibilityEvent event, TalkBackService context, Utterance utterance) {
    AccessibilityNodeInfoCompat node = new AccessibilityNodeInfoCompat(event.getSource());
    if (node.getInfo() == null) {
        return false;
    }//  w  w  w.j ava  2 s  .  co m

    int liveRegion = node.getLiveRegion();
    switch (liveRegion) {
    case View.ACCESSIBILITY_LIVE_REGION_POLITE:
        break;
    case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
        utterance.getMetadata().putInt(Utterance.KEY_METADATA_QUEUING, SpeechController.QUEUE_MODE_INTERRUPT);
        break;
    case View.ACCESSIBILITY_LIVE_REGION_NONE:
        return false;
    default:
        return false;
    }

    CharSequence text = NodeSpeechRuleProcessor.getInstance().getDescriptionForTree(node, event, node);

    if (TextUtils.isEmpty(text)) {
        return false;
    }

    utterance.addSpoken(text);
    utterance.addSpokenFlag(FeedbackItem.FLAG_SKIP_DUPLICATE);
    return true;
}

From source file:com.facebook.react.uimanager.BaseViewManager.java

@ReactProp(name = PROP_ACCESSIBILITY_LIVE_REGION)
public void setAccessibilityLiveRegion(T view, String liveRegion) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (liveRegion == null || liveRegion.equals("none")) {
            view.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE);
        } else if (liveRegion.equals("polite")) {
            view.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
        } else if (liveRegion.equals("assertive")) {
            view.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE);
        }//from  ww w.  ja  v a 2  s  .co m
    }
}