1
0
Fork 0

Closes #1127: Improves accessibility of quick action sheet

master
Sawyer Blatz 2019-03-21 11:50:24 -07:00 committed by Colin Lee
parent da35581c54
commit 0f1e65bdab
3 changed files with 18 additions and 8 deletions

View File

@ -40,6 +40,18 @@ class QuickActionSheet @JvmOverloads constructor(
val handle = findViewById<AppCompatImageButton>(R.id.quick_action_sheet_handle)
val linearLayout = findViewById<LinearLayout>(R.id.quick_action_sheet)
val quickActionSheetBehavior = BottomSheetBehavior.from(linearLayout.parent as View) as QuickActionSheetBehavior
val accessibilityManager = context
.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
if (accessibilityManager.isTouchExplorationEnabled) {
linearLayout.setOnClickListener {
quickActionSheetBehavior.state = when (quickActionSheetBehavior.state) {
BottomSheetBehavior.STATE_EXPANDED -> BottomSheetBehavior.STATE_COLLAPSED
else -> BottomSheetBehavior.STATE_EXPANDED
}
}
return
}
handle.increaseTapArea(grabHandleIncreasedTapArea)
handle.setOnClickListener {
@ -113,14 +125,6 @@ class QuickActionSheetBehavior(
}
private fun repositionQuickActionSheet(quickActionSheetContainer: NestedScrollView, toolbar: BrowserToolbar) {
val accessibilityManager = quickActionSheetContainer.context
.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
state = when (accessibilityManager.isTouchExplorationEnabled) {
true -> BottomSheetBehavior.STATE_EXPANDED
false -> BottomSheetBehavior.STATE_COLLAPSED
}
quickActionSheetContainer.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat()
}
}

View File

@ -9,6 +9,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/quick_action_sheet"
android:background="?attr/toolbarColor">
<androidx.appcompat.widget.AppCompatImageButton
@ -17,6 +18,7 @@
android:layout_width="24dp"
android:layout_height="2dp"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/quick_action_sheet_handle"
android:background="?attr/quickActionPullTabColor"
android:src="@drawable/ic_drawer_pull_tab"/>

View File

@ -159,6 +159,10 @@
<string name="quick_action_favorite">Favorite</string>
<!-- Option in Quick Action Sheet in the browser to put the the current page in reader mode -->
<string name="quick_action_read">Read</string>
<!-- Content description (not visible, for screen readers etc.): Quick action sheet-->
<string name="quick_action_sheet">Quick action sheet</string>
<!-- Content description (not visible, for screen readers etc.): Quick action sheet handle -->
<string name="quick_action_sheet_handle">Quick action sheet handle</string>
<!-- Library -->
<!-- Option in Library to open Sessions page -->