1
0
Fork 0

For #1072: Adds accessibility support

master
Sawyer Blatz 2019-03-20 09:28:36 -07:00 committed by Colin Lee
parent 486bfc2d68
commit 6dcc026e04
4 changed files with 39 additions and 8 deletions

View File

@ -15,6 +15,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import mozilla.components.browser.toolbar.BrowserToolbar
import org.mozilla.fenix.R
import android.animation.ValueAnimator
import android.view.accessibility.AccessibilityManager
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.utils.Settings
@ -27,7 +28,7 @@ class QuickActionSheet @JvmOverloads constructor(
) : LinearLayout(context, attrs, defStyle, defStyleRes) {
init {
inflate(getContext(), R.layout.component_quickactionsheet, this)
inflate(getContext(), R.layout.layout_quick_action_sheet, this)
}
fun afterInflate() {
@ -38,6 +39,7 @@ 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
handle.increaseTapArea(grabHandleIncreasedTapArea)
handle.setOnClickListener {
bounceSheet(quickActionSheetBehavior)
@ -109,7 +111,14 @@ class QuickActionSheetBehavior(
}
private fun repositionQuickActionSheet(quickActionSheetContainer: NestedScrollView, toolbar: BrowserToolbar) {
state = BottomSheetBehavior.STATE_COLLAPSED
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

@ -16,6 +16,8 @@ import org.mozilla.fenix.ext.getPreferenceKey
class Settings private constructor(context: Context) {
companion object {
const val autoBounceMaximumCount = 2
var instance: Settings? = null
@JvmStatic
@ -40,7 +42,7 @@ class Settings private constructor(context: Context) {
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_telemetry), true)
val shouldAutoBounceQuickActionSheet: Boolean
get() = autoBounceQuickActionSheetCount < 2
get() = autoBounceQuickActionSheetCount < autoBounceMaximumCount
private val autoBounceQuickActionSheetCount: Int
get() = (preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_bounce_quick_action), 0))

View File

@ -35,6 +35,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/quick_action_share"
android:src="@drawable/quick_action_icon_share"
android:background="@color/off_white"/>
@ -45,6 +46,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/quick_action_screenshot"
android:src="@drawable/library_icon_screenshots_circle_background"
android:background="@color/off_white"/>
@ -55,6 +57,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/quick_action_download"
android:src="@drawable/library_icon_downloads_circle_background"
android:background="@color/off_white"/>
@ -65,6 +68,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/quick_action_favorite"
android:src="@drawable/library_icon_favorites_circle_background"
android:background="@color/off_white"/>
@ -75,6 +79,7 @@
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/quick_action_read"
android:src="@drawable/quick_action_icon_read"
android:background="@color/off_white"/>
</LinearLayout>
@ -92,7 +97,7 @@
android:layout_width="0dp"
android:textAlignment="center"
android:textSize="12sp"
android:text="Share"/>
android:text="@string/quick_action_share"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_height="wrap_content"
@ -100,7 +105,7 @@
android:layout_width="0dp"
android:textAlignment="center"
android:textSize="12sp"
android:text="Screenshot"/>
android:text="@string/quick_action_screenshot"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_height="wrap_content"
@ -108,7 +113,7 @@
android:layout_width="0dp"
android:textAlignment="center"
android:textSize="12sp"
android:text="Download"/>
android:text="@string/quick_action_download"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_height="wrap_content"
@ -116,13 +121,16 @@
android:layout_width="0dp"
android:textAlignment="center"
android:textSize="12sp"
android:text="Favorite"/>
android:text="@string/quick_action_favorite"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:textAlignment="center"
android:textSize="12sp"
android:text="Read"/>
android:text="@string/quick_action_read"/>
</LinearLayout>
</LinearLayout>

View File

@ -150,6 +150,18 @@
<!-- Preference switch for app health report. -->
<string name="preferences_fenix_health_report">Fenix health report</string>
<!-- Quick Action Sheet -->
<!-- Option in Quick Action Sheet in the browser to share the current page -->
<string name="quick_action_share">Share</string>
<!-- Option in Quick Action Sheet in the browser to screenshot the current page -->
<string name="quick_action_screenshot">Screenshot</string>
<!-- Option in Quick Action Sheet in the browser to download the current page -->
<string name="quick_action_download">Download</string>
<!-- Option in Quick Action Sheet in the browser to favorite the current page -->
<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>
<!-- Library -->
<!-- Option in Library to open Sessions page -->
<string name="library_sessions">Sessions</string>