无障碍环境:对讲,和的WebView用户的区域 [英] Accesibility: Talkback, WebView and user's locale

查看:797
本文介绍了无障碍环境:对讲,和的WebView用户的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个应用程序,包括网页视图。我想使我的应用程序完全访问,因此对于web视图元素我想为话语提示读取HTML元素,如标题,旗,的EditText在一个完全访问的方式。

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.

我已经看到,在该网页视图TTS过程是通过经铬AccessibilityInjector.java类JS注射完成。这将给这个脚本到页面,其中只有英文的消息。其结果是,当设备是另一种语言中,TTS无论读取英语这些html元素。

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.

现在我不能调试或扩展铬WebClient的,所以我怎样才能使TTS根据用户所在的区域看我的网页?

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?

编辑:我使用jQuery Mobile的的方式

I am using jQuery Mobile by the way.

推荐答案

万一有人失足掉进这样的问题:我不得不申请一个丑陋的解决方法来克服这一点。每当我加载页面,话语提示已启用,重新注入我要读取包含文本的JavaScript变量,用自己的本地化同行。例如,对于西班牙语文本:

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)");

请注意,我注入变量之前插入一个超时 - 这是prevent的ChromeVox被注入的之后的我注入从而使该解决方案没用

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.

我知道这是一个丑陋的补丁,但没有进入铬的WebView类我找不到任何更好的解决方案。

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

这篇关于无障碍环境:对讲,和的WebView用户的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆