3

I am trying to improve accessibility for a text view used for terms and privacy policy which looks something like this:

enter image description here

As mentioned on the Google Support page, the user will need to access the Local Context Menu via a TalkBack gesture (default gesture is Swipe up then right) to activate a TextView link.

But I want to use a swipe gesture to navigate between links something like: enter image description here

Currently, I am using clickable span to add the links, it is working fine with Local Context Menu but not with a swipe gesture. My code looks something like this:

    val clickableSpan: ClickableSpan = object : ClickableSpan() {
        override fun onClick(widget: View) {
            // handle link click.
        }
    }
    val spannableStringBuilder = SpannableStringBuilder(text).apply {
        setSpan(clickableSpan, 99, 109, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
    }
    tv_term_and_privacy_policy.apply {
        setText(spannableStringBuilder)
        movementMethod = LinkMovementMethod.getInstance()
    }

Please help me with this.

imvishi
  • 233
  • 4
  • 18
  • Sure, would be helpful if you provide us some code. – minchaej Jun 27 '21 at 18:58
  • code added for your reference. – imvishi Jun 28 '21 at 05:36
  • Users using Talkback will know about local context menus, it is expected behaviour which will be pretty consistent across many different apps. It also allows the user to swipe past TextView quicker without making additional gestures if they chose not to open the links. I would recommend leaving the default behaviour. – sigute Jul 09 '21 at 06:41
  • 1
    Thanks, @sigute for your comment, but the swipe gesture is the requirement of the project. – imvishi Jul 09 '21 at 07:01
  • You will most likely have to build a custom view to handle this type of interaction. One approach would be to have each element as a separate view in some sort of flow layout. Then links could be buttons and could have actions on them, but making the text flow correctly will be a big challenge. – sigute Jul 09 '21 at 07:40
  • I will definitely look into this. – imvishi Jul 09 '21 at 13:41
  • @imvishi Did you get any solution? – Saurabh Padwekar Jun 16 '22 at 11:49
  • @saurabh-padwekar - no, I didn't get the solution for this, so we decided to use the Local context menu for now. – imvishi Jun 21 '22 at 10:24
  • Thanks for replying. We are also going with the same solution. – Saurabh Padwekar Jun 22 '22 at 05:59

0 Answers0