Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 972
natinusala Avatar asked May 04 '26 06:05

natinusala


1 Answers

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");
like image 90
ChrisCM Avatar answered May 06 '26 00:05

ChrisCM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!