From d0b7a2cb31373eb39dea33a917c77aa75d2da9a2 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Wed, 27 Mar 2019 11:15:41 -0700 Subject: [PATCH] [fenix] Fixes https://github.com/mozilla-mobile/fenix/issues/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. --- .../quickactionsheet/QuickActionSheet.kt | 19 +++++++++++++++++++ .../res/layout/layout_quick_action_sheet.xml | 1 + 2 files changed, 20 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt index 5af750e697..3cb5c03250 100644 --- a/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt +++ b/app/src/main/java/org/mozilla/fenix/quickactionsheet/QuickActionSheet.kt @@ -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(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 diff --git a/app/src/main/res/layout/layout_quick_action_sheet.xml b/app/src/main/res/layout/layout_quick_action_sheet.xml index 92543c9550..b4fb5b94d5 100644 --- a/app/src/main/res/layout/layout_quick_action_sheet.xml +++ b/app/src/main/res/layout/layout_quick_action_sheet.xml @@ -21,6 +21,7 @@ android:src="@drawable/ic_drawer_pull_tab"/>