1
0
Fork 0

Fixes #1186: Make quick actions invisible to screen reader when collapsed.

The buttons in the quick actions sheet are not visible or interactive
when the sheet is collapsed. They should not be visible to AT users
either.
master
Eitan Isaacson 2019-03-27 11:15:41 -07:00 committed by Sawyer Blatz
parent f9ea856b34
commit 4f67b7a26c
2 changed files with 20 additions and 0 deletions

View File

@ -48,6 +48,17 @@ class QuickActionSheet @JvmOverloads constructor(
handle.setAccessibilityDelegate(HandleAccessibilityDelegate(quickActionSheetBehavior))
quickActionSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(v: View, state: Int) {
updateImportantForAccessibility(state)
}
override fun onSlide(p0: View, p1: Float) {
}
})
updateImportantForAccessibility(quickActionSheetBehavior.state)
val settings = Settings.getInstance(context)
if (settings.shouldAutoBounceQuickActionSheet) {
settings.incrementAutomaticBounceQuickActionSheetCount()
@ -55,6 +66,14 @@ class QuickActionSheet @JvmOverloads constructor(
}
}
private fun updateImportantForAccessibility(state: Int) {
findViewById<LinearLayout>(R.id.quick_action_sheet_buttonbar).importantForAccessibility =
if (state == BottomSheetBehavior.STATE_COLLAPSED || state == BottomSheetBehavior.STATE_HIDDEN)
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
else
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
}
private fun bounceSheet(
quickActionSheetBehavior: QuickActionSheetBehavior,
duration: Long = bounceAnimationLength

View File

@ -21,6 +21,7 @@
android:src="@drawable/ic_drawer_pull_tab"/>
<LinearLayout
android:id="@+id/quick_action_sheet_buttonbar"
android:orientation="horizontal"
android:layout_gravity="bottom"
android:layout_width="match_parent"