For 9640 - Focus on last selected tab in tab tray with a11y turned on (#11487)
parent
8b24cdec42
commit
149efc1683
|
@ -110,7 +110,8 @@ class TabTrayDialogFragment : AppCompatDialogFragment(), TabTrayInteractor {
|
||||||
view.tabLayout,
|
view.tabLayout,
|
||||||
this,
|
this,
|
||||||
isPrivate,
|
isPrivate,
|
||||||
requireContext().resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
requireContext().resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE,
|
||||||
|
viewLifecycleOwner.lifecycleScope
|
||||||
) { tabsFeature.get()?.filterTabs(it) }
|
) { tabsFeature.get()?.filterTabs(it) }
|
||||||
|
|
||||||
tabsFeature.set(
|
tabsFeature.set(
|
||||||
|
|
|
@ -8,14 +8,19 @@ import android.content.Context
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.accessibility.AccessibilityEvent
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.main.component_tabstray.view.*
|
import kotlinx.android.synthetic.main.component_tabstray.view.*
|
||||||
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
|
import kotlinx.android.synthetic.main.component_tabstray_fab.view.*
|
||||||
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import mozilla.components.browser.menu.BrowserMenuBuilder
|
import mozilla.components.browser.menu.BrowserMenuBuilder
|
||||||
import mozilla.components.browser.menu.item.SimpleBrowserMenuItem
|
import mozilla.components.browser.menu.item.SimpleBrowserMenuItem
|
||||||
import mozilla.components.browser.state.selector.normalTabs
|
import mozilla.components.browser.state.selector.normalTabs
|
||||||
|
@ -37,11 +42,13 @@ interface TabTrayInteractor {
|
||||||
/**
|
/**
|
||||||
* View that contains and configures the BrowserAwesomeBar
|
* View that contains and configures the BrowserAwesomeBar
|
||||||
*/
|
*/
|
||||||
|
@Suppress("LongParameterList")
|
||||||
class TabTrayView(
|
class TabTrayView(
|
||||||
private val container: ViewGroup,
|
private val container: ViewGroup,
|
||||||
private val interactor: TabTrayInteractor,
|
private val interactor: TabTrayInteractor,
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
startingInLandscape: Boolean,
|
startingInLandscape: Boolean,
|
||||||
|
lifecycleScope: LifecycleCoroutineScope,
|
||||||
private val filterTabs: ((TabSessionState) -> Boolean) -> Unit
|
private val filterTabs: ((TabSessionState) -> Boolean) -> Unit
|
||||||
) : LayoutContainer, TabLayout.OnTabSelectedListener {
|
) : LayoutContainer, TabLayout.OnTabSelectedListener {
|
||||||
val fabView = LayoutInflater.from(container.context)
|
val fabView = LayoutInflater.from(container.context)
|
||||||
|
@ -118,6 +125,19 @@ class TabTrayView(
|
||||||
if (!hasLoaded) {
|
if (!hasLoaded) {
|
||||||
hasLoaded = true
|
hasLoaded = true
|
||||||
tray.layoutManager?.scrollToPosition(selectedBrowserTabIndex)
|
tray.layoutManager?.scrollToPosition(selectedBrowserTabIndex)
|
||||||
|
if (view.context.settings().accessibilityServicesEnabled) {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
delay(SELECTION_DELAY.toLong())
|
||||||
|
lifecycleScope.launch(Main) {
|
||||||
|
tray.layoutManager?.findViewByPosition(selectedBrowserTabIndex)
|
||||||
|
?.requestFocus()
|
||||||
|
tray.layoutManager?.findViewByPosition(selectedBrowserTabIndex)
|
||||||
|
?.sendAccessibilityEvent(
|
||||||
|
AccessibilityEvent.TYPE_VIEW_FOCUSED
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,6 +249,7 @@ class TabTrayView(
|
||||||
private const val PRIVATE_TAB_ID = 1
|
private const val PRIVATE_TAB_ID = 1
|
||||||
private const val EXPAND_AT_SIZE = 3
|
private const val EXPAND_AT_SIZE = 3
|
||||||
private const val SLIDE_OFFSET = 0
|
private const val SLIDE_OFFSET = 0
|
||||||
|
private const val SELECTION_DELAY = 500
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/tab_item"
|
android:id="@+id/tab_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="88dp">
|
android:layout_height="88dp"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/play_pause_button"
|
android:id="@+id/play_pause_button"
|
||||||
|
|
Loading…
Reference in New Issue