Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@khsbory khsbory commented Aug 15, 2020

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

This comment has been minimized.

Copy link
Owner Author

@ataulm ataulm commented Aug 15, 2020

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

@khsbory

This comment has been minimized.

Copy link

@khsbory khsbory commented Aug 24, 2020

@ataulm

This comment has been minimized.

Copy link
Owner Author

@ataulm ataulm commented Aug 24, 2020

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