mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/14540: Fix updating list and item info for a11y services.
This commit is contained in:
parent
12707f2b74
commit
fd8dbfe8dc
@ -67,7 +67,11 @@ class FenixTabsAdapter(
|
||||
override fun onBindViewHolder(holder: TabViewHolder, position: Int) {
|
||||
super.onBindViewHolder(holder, position)
|
||||
val newIndex = tabCount - position - 1
|
||||
(holder as TabTrayViewHolder).updateAccessibilityRowIndex(holder.itemView, newIndex)
|
||||
(holder as TabTrayViewHolder).updateAccessibilityRowInfo(
|
||||
holder.itemView,
|
||||
newIndex,
|
||||
selectedItems.contains(holder.tab)
|
||||
)
|
||||
|
||||
holder.tab?.let { tab ->
|
||||
showCheckedIfSelected(tab, holder.itemView)
|
||||
|
@ -9,6 +9,8 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.accessibility.AccessibilityEvent
|
||||
import android.view.accessibility.AccessibilityNodeInfo
|
||||
import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
@ -186,7 +188,7 @@ class TabTrayView(
|
||||
concatAdapter.addAdapter(0, syncedTabsController.adapter)
|
||||
|
||||
if (hasAccessibilityEnabled) {
|
||||
tabsAdapter.notifyDataSetChanged()
|
||||
tabsAdapter.notifyItemRangeChanged(0, tabs.size)
|
||||
}
|
||||
if (!hasLoaded) {
|
||||
hasLoaded = true
|
||||
@ -491,6 +493,22 @@ class TabTrayView(
|
||||
} else {
|
||||
view.context?.getString(R.string.open_tab_tray_plural, count.toString())
|
||||
}
|
||||
|
||||
view.tabsTray.accessibilityDelegate = object : View.AccessibilityDelegate() {
|
||||
override fun onInitializeAccessibilityNodeInfo(
|
||||
host: View?,
|
||||
info: AccessibilityNodeInfo?
|
||||
) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info)
|
||||
info?.let {
|
||||
info.collectionInfo = CollectionInfo.obtain(
|
||||
tabsAdapter.tabCount,
|
||||
1,
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTabCounter(count: Int): String {
|
||||
|
@ -187,28 +187,25 @@ class TabTrayViewHolder(
|
||||
imageLoader.loadIntoView(thumbnailView, ImageLoadRequest(id, thumbnailSize))
|
||||
}
|
||||
|
||||
internal fun updateAccessibilityRowIndex(item: View, newIndex: Int) {
|
||||
internal fun updateAccessibilityRowInfo(item: View, newIndex: Int, isSelected: Boolean) {
|
||||
item.accessibilityDelegate = object : View.AccessibilityDelegate() {
|
||||
override fun onInitializeAccessibilityNodeInfo(
|
||||
host: View?,
|
||||
info: AccessibilityNodeInfo?
|
||||
) {
|
||||
super.onInitializeAccessibilityNodeInfo(host, info)
|
||||
info?.let {
|
||||
info.collectionItemInfo = info.collectionItemInfo?.let { initialInfo ->
|
||||
info?.collectionItemInfo =
|
||||
AccessibilityNodeInfo.CollectionItemInfo.obtain(
|
||||
newIndex,
|
||||
initialInfo.rowSpan,
|
||||
initialInfo.columnIndex,
|
||||
initialInfo.columnSpan,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
false,
|
||||
initialInfo.isSelected
|
||||
isSelected
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PLAY_PAUSE_BUTTON_EXTRA_DPS = 24
|
||||
|
Loading…
Reference in New Issue
Block a user