Commit 0d37c8f2 authored by mcarare's avatar mcarare Committed by Arturo Mejia
Browse files

For #16420: Make search bar first view focused by a11y services on open.

parent 88f3f356
......@@ -11,6 +11,7 @@ import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Typeface
import android.os.Build
import android.os.Bundle
import android.os.StrictMode
import android.speech.RecognizerIntent
......@@ -20,6 +21,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.ViewStub
import android.view.WindowManager
import android.view.accessibility.AccessibilityEvent
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.appcompat.content.res.AppCompatResources
......@@ -28,12 +30,14 @@ import androidx.constraintlayout.widget.ConstraintProperties.PARENT_ID
import androidx.constraintlayout.widget.ConstraintProperties.TOP
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import kotlinx.android.synthetic.main.fragment_search_dialog.*
import kotlinx.android.synthetic.main.fragment_search_dialog.view.*
import kotlinx.android.synthetic.main.search_suggestions_hint.view.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.concept.storage.HistoryStorage
import mozilla.components.feature.qr.QrFeature
......@@ -276,6 +280,9 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
}
view.search_suggestions_hint.setOnInflateListener((stubListener))
if (view.context.settings().accessibilityServicesEnabled) {
updateAccessibilityTraversalOrder()
}
consumeFrom(store) {
val shouldShowAwesomebar =
......@@ -294,6 +301,19 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
}
}
private fun updateAccessibilityTraversalOrder() {
val searchWrapperId = search_wrapper.id
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
qr_scan_button.accessibilityTraversalAfter = searchWrapperId
search_engines_shortcut_button.accessibilityTraversalAfter = searchWrapperId
fill_link_from_clipboard.accessibilityTraversalAfter = searchWrapperId
} else {
viewLifecycleOwner.lifecycleScope.launch {
search_wrapper.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
}
}
override fun onResume() {
super.onResume()
resetFocus()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment