0

For accessibility demo purpose, I’m creating android example app. By the way, during creating bad example accessibility, I have a question about toast issue. By default, every time toast is showing, TalkBack read the toast and it is very good.

But sometimes I want to hide toast from TalkBack so that TalkBack won’t read the toast message. Of course TalkBack must read all toast messages in order to give same information with none screen reader users. But sometimes in some apps, too many toast messages are appeared on screen and even the same message is stayed on screen.

So in that case TalkBack says too much and even TalkBack won’t read the toast, blind users can read the message that toasted through swiping. Also the toast message is not alert text. So in some cases, I think hiding toast from TalkBack is needed.

But I don’t know how to do this. I set one view in java and added toast message. And then I set importantForAccessibility to NO, but it doesn’t work.

My code is below. Lastly, I referred as the stack that customizing TalkBack toast. Thank you.

imgClick2 = (ImageView)findViewById(R.id.imageView2);
imgClick2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
    Toast toast = new Toast(MainActivity.this);
    TextView messageView = new TextView(MainActivity.this);
        messageView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
    messageView.setText("visible text");

    toast.setView(messageView);
    toast.show();
    }
});
halfer
  • 19,824
  • 17
  • 99
  • 186
  • can you try this "messageView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)" – GvSharma May 18 '19 at 07:34
  • Thank you for your message. I tried this, but doesn't work. If you tell me other ways, I will try. Actually I think that it is need to block accessibility event. Because, toast class has system accessibility event, so I think block event code is needed. but I don't know what code can I use. – Hyongsop Kim May 19 '19 at 09:31
  • I searched some code, and I got some tips. But I don't know how to put this to my code. The code I found is below.    @Override    public void sendAccessibilityEvent(int eventType) {       if (accessibilitymanager.isTouchExplorationEnabled()             && eventType != AccessibilityEvent.TYPE_VIEW_CLICKED             && eventType != AccessibilityEvent.TYPE_VIEW_FOCUSED             && eventType != AccessibilityEvent.TYPE_VIEW_SELECTED) {          super.sendAccessibilityEvent(eventType);  // Let screenreader have it       }    }  // Don't send any other events } Please help me. – Hyongsop Kim May 20 '19 at 01:47
  • I would suggest that you don't hide the Toast messages from Talkback. If you have too many Toasts, then that is UI problem that should be addressed for all users, not just Talkback users. If some messages are unimportant enough that they can be hidden from Talkback users, then perhaps you should consider removing them altogether? – Shailen Tuli May 20 '19 at 14:14
  • Thank you for your suggestion and I really agree with you. But based on the situation, I need to know how to block accessibility event produced by system like Toast class. Again, I surely advise to developers that offer same information to sighted users and TalkBack users and Toast message is the same case. But in some rare case, not just Toast accessibility event, I need to learn blocking some accessibility event by system. For example, there are some cases that I should block accessibility event, such as voice input. – Hyongsop Kim May 22 '19 at 08:39
  • Generally, if I press voice input button, new activity will be appeared, but TalkBack says nothing in order to prevent include TalkBack voice to voice input text field. Of course I know that it is good communicated with audio manager API with TalkBack. However, in some cases, if developer doesn’t use general audio API, TalkBack says something during voice input and it is very big problem. Like this example, I need to know how to block accessibility event. Toast is just my example. Please help me. – Hyongsop Kim May 22 '19 at 08:39

0 Answers0