我正在尝试制作一款针对视力障碍用户的基础TalkBack版本。我已经制作了一个简单的无障碍服务,它可以读取用户点击的按钮的contentDescription,并将其大声朗读出来。
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
// get the source node of the event
AccessibilityNodeInfo source = event.getSource();
if (source == null) {
return;
}
// Check if a button is clicked and speak out the content
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_CLICKED
&& BUTTON_CLASS_NAME.equals(source.getClassName()) {
Log.d("Button clicked", source.getViewIdResourceName().toString());
convertTextToSpeech(source.getContentDescription().toString());
}
if (source != null)
source.recycle();
return;
}
问题:但是这样用户在执行单击按钮时无法先听到按钮的描述。当用户听完描述时,按钮已经被点击并且动作已经被执行。
问题: 我如何中断动作(例如:单击按钮后打开一个新的活动)以便用户可以安全地探索屏幕上当前的视图,并提供反馈,而不会启动新的活动或触发其他动作?
有点像Talkback中所发生的:用户单击来听取描述,双击来执行操作。Talkback如何防止动作发生,除非用户双击?我已经研究了TouchExplorationMode,但我想它主要用于手势而不是点击。