Implementing text traversal in custom widgets?

43 views
Skip to first unread message

Nolan Darilek

unread,
Nov 29, 2012, 8:48:49 PM11/29/12
to Eyes-free Development
I'm trying to make the open source Cool Reader the most accessible ebook
reader on Android. It already has one of the better TTS-based readers
I've seen, but I'd really rather expose book text directly to the
accessibility API and push that as far as I can.

To that end, I have page text appearing in AccessibilityEvents and
AccessibilityNodeInfos. I've also registered that the nodes can support
traversal at character, word, line and paragraph levels (I'll support
pages eventually too, once I figure out how to map text traversal by
page to CR's page-scrolling mechanism.)

But even though I can set a desired traversal level, I can't traverse a
node by a given granularity. I thought that it'd be enough to set its
text, allowed granularities, and add the traversal actions. But
apparently something more is needed.

What do I need to do to support text traversal in a custom view?

David Engebretson Jr.

unread,
Nov 29, 2012, 8:56:19 PM11/29/12
to eyes-f...@googlegroups.com
Hey Nolan,

I'm just curious if you've seen replies to your last two inquiries today?

The replies aren't coming to the list, if so, and I'd really like to see the
technical answers from the Android Devs.

Best,
David

Nolan Darilek

unread,
Nov 29, 2012, 9:09:40 PM11/29/12
to eyes-f...@googlegroups.com
No, nada.

David Engebretson Jr.

unread,
Nov 29, 2012, 9:16:42 PM11/29/12
to eyes-f...@googlegroups.com
oh, bummer. I'll keep my ears out, then.

You know I'm at the far Northwest Canadian border, right? I'm in
Bellingham, just south of the border. Vancouver BC is a little shorter
distance to drive to than Seattle.

Where are you located?

thanks,
david

David Engebretson Jr.

unread,
Nov 30, 2012, 5:44:48 AM11/30/12
to eyes-f...@googlegroups.com
I'm curious, as an owner of several Android devices, how do we know which
devices will be uppgradable to what specific new versions of the OS?

For example, my newest devices are Droid 3 still running 2.3. Shouldn't
that be upgradable? I bought it less than a year ago (if i remember
correctly). I've not been given the option to upgrade yet on that phone. I
would appreciate ICS on that one, for sure.

I also have a Nexxus 7 running 4.2. I was given an option on the Nexxus to
upgrade to 4.2 from 4.0. I'm so appreciative of that opportunity.

If I don't know, however, what hardware is going to be upgradable to what
specific OS then it becomes a guessing game with my pocket book and my
innate desire to have the latest technology. My pocket book will become
empty long before my innate desire to develop applications and use the
latest and greatest operating system and hardware.

If I'm developing an app for Android 2.3 on a Motorola Droid 3 and it
becomes obsolete in 4 months then I will have wasted many hours of
development on said device.

What is the best device for a developer to own so the developer does not
spend too much time developing for an OS version that might become fodder
for the circular file cabinet as quickly as it appeared on the market?

Basically, How many upgrades will each of those hardware devices be allowed
to consume? Does each device have a max number of the Android OS it can be
upgraded to?

I'm very interested in getting the latest OS that has the latest and
greatest in accessibility for us blind folk.

Thank you for your thoughts, oh supreme Android development team.

Best,
David Engebretson Jr.
Bellingham, Wa.
"An Android at heart."
360.734.9979

Hittsjunk

unread,
Nov 30, 2012, 6:13:31 AM11/30/12
to eyes-f...@googlegroups.com, David Engebretson Jr.
Basically, you will have to check with the company who made the device and hope they keep thir word.
Nexus is the only exception. Nexus will get the most upgrades. I know for sure your DROID 3 won't get any more upgrades. It's almost 2 years old now.
The rule of thumb is upgrades can happen for the first 18 months after a device is released. It actually works out to just a year or less for most companies.

Send using k-9 mail from my D2G running Android 2.3 thanks to the spiel screen reader

Kirk Reiser

unread,
Nov 30, 2012, 11:28:23 AM11/30/12
to Eyes-free Development
Hi Nolan: What file formats does the cool reader support? I am asking
because I'm curious why you're not extending audioPager which does a
fine job on text files already. It is also written by an active blind
user.

Kirk
--
Well that's it then, colour me gone!

Nolan Darilek

unread,
Nov 30, 2012, 12:05:49 PM11/30/12
to eyes-f...@googlegroups.com
CR supports a whole host of formats. I use it mainly for its Epub
support, plus it integrates with the Smashwords Access app out of the
box, and Smashwords is where I get most of my content. It also supports
online Atom catalogs which many publishers use to syndicate their
libraries, and even though my goal is to make it as completely
accessible as possible, its TTS "read aloud" function is one of the best
I've seen, not losing its place and letting you set a TTS speed
independent of the normal rate.

I can't speak to AudioPager, but CR is a mainstream e-reader app with
good reviews. I'd rather add accessibility into a mainstream app than
use something developed heavily for accessibility (though that could be
an unfair assessment, I can't find AudioPager when searching for it.)

Besides, I wanted to see how hard it'd be to transition from an entirely
inaccessible widget to something that plays completely nicely with the
4.1 APIs.

Kirk Reiser

unread,
Nov 30, 2012, 9:42:46 PM11/30/12
to eyes-f...@googlegroups.com
Thanks for the quick reply Nolan. AudioPager doesn't handle any
formats other than text although I think it does a really nice job on
those. If you wish to check it out there is a git repository at
git://repo.or.cz/audiopager.git. I'll have to check out cool reader.
Almost all of my books are in text currently so it isn't immediately
necessary.

Kirk

Nolan Darilek

unread,
Dec 1, 2012, 11:14:06 AM12/1/12
to eyes-f...@googlegroups.com
On 11/29/2012 08:16 PM, David Engebretson Jr. wrote:
> oh, bummer. I'll keep my ears out, then.
> You know I'm at the far Northwest Canadian border, right? I'm in
> Bellingham, just south of the border. Vancouver BC is a little
> shorter distance to drive to than Seattle.
>
> Where are you located?
>
Austin, TX.

A.K.A. where "south of the border" and "Seattle" have no business being
in the same sentence, much less the same email. :P

Nolan Darilek

unread,
Dec 20, 2012, 12:32:17 PM12/20/12
to eyes-f...@googlegroups.com
*bump*

I would have expected the framework to have some standard about what is
a word, line, character, etc. and for it to be sufficient for me to set
the text on a node and have those traversals supported.

I looked through the 4.1 sources, and it seems like this might happen on
an event's contentDescription. Why not on its text?

So I added the page's text to the contentDescription. I do this both in
onInitializeAccessibilityNodeInfo() and onPopulateAccessibilityEvent().
I added all granularities, as well as the traversal actions. I can get
the entire page of text read. I can select a granularity. I cannot then
navigate by that granularity.

I also tried populating the contentDescription of the view via
setContentDescription() before generating the event. I can't populate
that on view creation because I'm not certain what the text of the page
being displayed is until the event is needed. That didn't seem to work
either.

I just tried setting the node's text, and calling super() last. Neither
worked. I feel less like I'm working with an API and more like I'm
playing a game of Myst. Surely it shouldn't be *this* complicated to
implement text traversal?

Help a fella out? How do I support text traversal on a custom view that
descends from SurfaceView and, as such, has no concept of text?

Here's my code. Perhaps I'm doing more than I need to, but this is a
corner of the framework that isn't well-defined or documented.

@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
// Set the view's contentDescription then populate the event,
// seems like the only way to support text review. Putting it
// directly in the event doesn't support traversal.
PositionProperties props = doc.getPositionProps(null);
setContentDescription(props.pageText);
super.onPopulateAccessibilityEvent(event);
}

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo
node) {
super.onInitializeAccessibilityNodeInfo(node);
PositionProperties props = doc.getPositionProps(null);
node.setContentDescription(props.pageText);
if(VERSION.SDK_INT >= 16) {
node.setMovementGranularities(
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER |
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD |
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE |
AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
);
node.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
node.addAction(AccessibilityNodeInfo.ACTION_FOCUS);
node.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
node.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
Reply all
Reply to author
Forward
0 new messages