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.
nightly-build-test
Eitan Isaacson 5 years ago committed by Sawyer Blatz
parent f9ea856b34
commit 4f67b7a26c

@ -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

@ -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"

Loading…
Cancel
Save