简体   繁体   中英

TalkBack reads time wrong

When having a TextView containing foo bar 04:58 , TalkBack will say foo bar 4 hours 58 minutes - it should be foo bar 4 minutes 58 seconds . On the other hand, foo bar 04:24:05 works fine : foo bar 4 hours 24 minutes 5 seconds . My locale is french, by the way.

I thought of unelegant fixes for this :

  • Replace each mm:ss by 00:mm:ss
  • Replace each mm:ss by mm minutes ss seconds

Is there a better solution to this ?

This is one of the few times when I recommend overriding the text with a content description. You have to expand it out.

So let's say you have a TextView

textView.setText("2:45")

textView.setContentDescription("2 minutes 45 seconds")

Content descriptions on text views act as alternative text and will be read out instead. This actually creates other accessibility issues. Imagine an AT that read out both the Text and the Content Description, instead of using the content description as an override... UGH. But in the current Android Accessibility ecosystem, where TalkBack has an overwhelming market share this solution isn't completely evil. Ideally, the Text To Speech engine would NOT be stupid. But, since the TTS engine is stupid, we have to change the text TalkBack sees in order for the read out to be reasonable.

You can also leave it be, and note that TalkBack users have the ability to explore text by character if they'd like, so they could figure out the weird TTS auto formatting. You could also trying changing your view to look like this instead:

textView.setText("2m 45s");

Although, if I remember correctly the TTS Engine will expand this to "2 meters forty-fives"... awesome.

EDIT: I imagine this line of code will help with your other problem.

timeString.replaceAll("([0-9]{1,2}):([0-9]{1,2})", "$1 minutes $2 seconds");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM