Skip to content

Instantly share code, notes, and snippets.

@ataulm
Created August 14, 2020 10:56
Show Gist options
  • Select an option

  • Save ataulm/ccf2dc796992faaf70674e3f9254b8be to your computer and use it in GitHub Desktop.

Select an option

Save ataulm/ccf2dc796992faaf70674e3f9254b8be to your computer and use it in GitHub Desktop.
private val intervalBounds = Rect()
@Suppress("DEPRECATION") // setBoundsInParent is required by [ExploreByTouchHelper]
override fun onPopulateNodeForVirtualView(virtualViewId: Int, node: AccessibilityNodeInfoCompat) {
node.className = RatingsHistogramView::class.simpleName
node.contentDescription = "content desc $virtualViewId"
updateBoundsForInterval(virtualViewId)
node.setBoundsInParent(intervalBounds)
}
private fun updateBoundsForInterval(index: Int) {
val histogram = this@RatingsHistogramView.ratingsHistogram ?: return
val intervalWidth = width.toFloat() / histogram.intervals.size
val left = index * intervalWidth
intervalBounds.left = (left + 2).roundToInt()
intervalBounds.top = (height - (histogram.intervals[index].weight * height)).roundToInt()
intervalBounds.right = (left + intervalWidth - 2).roundToInt()
intervalBounds.bottom = height
}
@khsbory

khsbory commented Aug 15, 2020

Copy link
Copy Markdown

Hi, my name is Hyongsop Kim from Korea and accessibility consultant.
I read your blod post that android custom view accessible article.
I learned a lot from your posting that even a Cambus view can be implemented so that TalkBack can read the view.
Could you share the entire sample app project for my study?
I'd like to build your project on my phone and experience it in person, see each of the source codes, and learn more deeply.
My email address is hyongsop.kim@nvisions.co.kr.
Thank you.

@ataulm

ataulm commented Aug 15, 2020

Copy link
Copy Markdown
Author

Hi Hyongsop Kim, you can find the full project here https://github.com/ataulm/android-skeleton/compare/virtual-views-a11y?expand=1

@khsbory

khsbory commented Aug 24, 2020 via email

Copy link
Copy Markdown

@ataulm

ataulm commented Aug 24, 2020 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment