0

I was exploring the API Demos provided in android sdk, android version > 4.1 . API Demos -> Accessibility -> Accessibility Node Provider

The AccessibilityNodeProvider contains some custom views with Red, Green, Blue colors. As mentioned in the activity , i enabled the talkback and i tried to hover on the views. Talkback couldn't read the colors. Talkback is reading the text available in the activity but not the colors. I was wondering does Talkback reads the colors (custom views) in the activity ?

Thanks in advance

Jitendar M
  • 633
  • 1
  • 10
  • 26

2 Answers2

2

In the package com.example.android.apis.accessibility in the AccessibilityNodeProviderActivity class, find the sendAccessibilityEventForVirtualView() method. You need to set the eventType on the AccessibilityEvent to AccessibilityEvent.TYPE_ANNOUNCEMENT like so:

event.getText().add(virtualView.mText);
event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event);

That should make it announce the text. But it still doesn't highlight the view -- don't know if the expected behaviour is that the node should be highlighted.

spear
  • 21
  • 2
0

I've found this Google Code example to be a better example of speaking text in a node provider setup.

(Old answer below.)

In the AccessibilityNodeProviderActivity class, look at the method sendAccessibilityEventForVirtualView(). You’ll see that the text set into the event is the text defined in accessibility_node_provider.xml. You would replace that text with a wording of the different color values to get what you asked for.

jbm
  • 1,482
  • 11
  • 26
  • thanks for the reply. In the accessibility_node_provider.xml, i don't see any 'text' defined for the custom view. When i enable talkback and touch the colors, by default i was expecting 'Virtual view 1' / 'Virtual view 2' / 'Virtual view 3' as set in the createVirtualChildren() method, which is not detected/read by talkback. In sendAccessibilityEventForVirtualView() method i have changed event.getText().add(virtualView.mText); to event.getText().add("RED"); but still talkback doesn't detect/read the text. With your changes to the code, does talkback detect/read color on your device. – Jitendar M Sep 25 '13 at 10:48
  • No, it doesn't. I've been experimenting with this demo, and not finding it very helpful for actually speaking the text. I've altered my original answer with pointer. Hope that helps, it's helped me! – jbm Sep 30 '13 at 17:45