简体   繁体   中英

Accessibility: Talkback, WebView and user's locale

I have developed an app that includes a Webview. I would like to make my app fully accessible, so for the webview element I would like for TalkBack to read html elements such as "Heading", "Banner", "EditText" in a fully accessible way.

I have seen that the TTS process in WebView is done through JS injection via Chromium AccessibilityInjector.java class. This injects this script into the page, which only has the messages in English. The result is that when a device is in another language, the TTS reads these html element in English regardless.

Now I cannot debug or extend the chromium webclient, so how can I make TTS to read my page according to the user's locale?

EDIT: I am using jQuery Mobile by the way.

Just in case someone stumbles into this problem: I had to apply an ugly workaround to get over this. Whenever I load a page and TalkBack is enabled, I reinject the javascript variables containing the text to be read, with their localized counterparts. For instance, for Spanish text:

view.loadUrl("javascript:window.setTimeout(function(){" +
                "window.console.log(\"Injecting messages.\");" +
                "cvox.TestMessages[\"chromevox_input_type_text\"] = {message: \"cuadro de edición\"};" +
                "cvox.TestMessages[\"chromevox_input_type_radio\"] = {message: \"botón de opción\"};" +
                "cvox.TestMessages[\"chromevox_selected\"] = {message: \"seleccionado\"};" +
                "cvox.TestMessages[\"chromevox_unselected\"] = {message: \"no seleccionado\"};" +
                "cvox.TestMessages[\"chromevox_radio_selected_state\"] = {message: \"seleccionado\"};" +
                "cvox.TestMessages[\"chromevox_radio_unselected_state\"] = {message: \"no seleccionado\"};" +
                "cvox.TestMessages[\"chromevox_input_type_submit\"] = {message: \"botón\"};" +
                "cvox.TestMessages[\"chromevox_input_type_button\"] = {message: \"botón\"};" +
                "cvox.TestMessages[\"chromevox_tag_button\"] = {message: \"botón\"};" +
                "}, 2000)");

Note that I insert a timeout before injecting the variables -- this is to prevent chromevox from being injected after my injection thus making the solution useless.

I know this is an ugly patch, but I could not find any better solutions without access to the chromium webview classes.

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