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) {
|
override fun onBindViewHolder(holder: TabViewHolder, position: Int) {
|
||||||
super.onBindViewHolder(holder, position)
|
super.onBindViewHolder(holder, position)
|
||||||
val newIndex = tabCount - position - 1
|
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 ->
|
holder.tab?.let { tab ->
|
||||||
showCheckedIfSelected(tab, holder.itemView)
|
showCheckedIfSelected(tab, holder.itemView)
|
||||||
|
@ -9,6 +9,8 @@ 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 android.view.accessibility.AccessibilityEvent
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@ -186,7 +188,7 @@ class TabTrayView(
|
|||||||
concatAdapter.addAdapter(0, syncedTabsController.adapter)
|
concatAdapter.addAdapter(0, syncedTabsController.adapter)
|
||||||
|
|
||||||
if (hasAccessibilityEnabled) {
|
if (hasAccessibilityEnabled) {
|
||||||
tabsAdapter.notifyDataSetChanged()
|
tabsAdapter.notifyItemRangeChanged(0, tabs.size)
|
||||||
}
|
}
|
||||||
if (!hasLoaded) {
|
if (!hasLoaded) {
|
||||||
hasLoaded = true
|
hasLoaded = true
|
||||||
@ -491,6 +493,22 @@ class TabTrayView(
|
|||||||
} else {
|
} else {
|
||||||
view.context?.getString(R.string.open_tab_tray_plural, count.toString())
|
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 {
|
private fun updateTabCounter(count: Int): String {
|
||||||
|
@ -187,25 +187,22 @@ class TabTrayViewHolder(
|
|||||||
imageLoader.loadIntoView(thumbnailView, ImageLoadRequest(id, thumbnailSize))
|
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() {
|
item.accessibilityDelegate = object : View.AccessibilityDelegate() {
|
||||||
override fun onInitializeAccessibilityNodeInfo(
|
override fun onInitializeAccessibilityNodeInfo(
|
||||||
host: View?,
|
host: View?,
|
||||||
info: AccessibilityNodeInfo?
|
info: AccessibilityNodeInfo?
|
||||||
) {
|
) {
|
||||||
super.onInitializeAccessibilityNodeInfo(host, info)
|
super.onInitializeAccessibilityNodeInfo(host, info)
|
||||||
info?.let {
|
info?.collectionItemInfo =
|
||||||
info.collectionItemInfo = info.collectionItemInfo?.let { initialInfo ->
|
AccessibilityNodeInfo.CollectionItemInfo.obtain(
|
||||||
AccessibilityNodeInfo.CollectionItemInfo.obtain(
|
newIndex,
|
||||||
newIndex,
|
1,
|
||||||
initialInfo.rowSpan,
|
1,
|
||||||
initialInfo.columnIndex,
|
1,
|
||||||
initialInfo.columnSpan,
|
false,
|
||||||
false,
|
isSelected
|
||||||
initialInfo.isSelected
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user