How to stop Touch To Explore feature of TalkBack in my app

房东的猫 提交于 2019-12-20 06:27:01

问题


I'm working on a project for blind people, there're a lot of troubles I need to fix if the user activates TalkBalk on his phone.

I'm creating a soft keyboard for blind people, the blind will tap with single finger on the circles "Braille Cell Dots" to generate a Braille code, then he types the character/number/symbols he wants as they presented in Braille language.

My problem now is Touch To Explore feature of TalkBack, the user will not be able to make a single tap on the screen because this action now handled by TalkBack, the user must double tap on the dot and this is not good for my app!

How to generate a single tap even if Touch to Explore feature is enabled in TalkBack?


回答1:


You don't. It's a terrible idea. Come up with gestures and mechanisms that fit within what TalkBack allows. If you could annotate a specific feature or mechanism of your app that is not allowed to work with talkback, I could recommend an alternative. What gesture is it that's not working?




回答2:


Based on this answer which has solved my problem, as the single touch event converted to hover event if touch to explore is enabled, I've added onHoverEvent to call onTouchEvent and works fine:

@Override
public boolean onHoverEvent(MotionEvent event) {
    //Move AccessibilityManager object to the constructor 
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isTouchExplorationEnabled()) {
        return onTouchEvent(event);
    } else {
        return super.onHoverEvent(event);
    }
}

And handle hover action to onTouchEvent:

@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_HOVER_ENTER:
    //Your Code
    break;
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_HOVER_MOVE:
    //Your Code
    break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_HOVER_EXIT:
    //Your Code
    break;    

}

return true;
}

I'll edit my question to be more cleaner :)



来源:https://stackoverflow.com/questions/35165206/how-to-stop-touch-to-explore-feature-of-talkback-in-my-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!