Commit e2322a18 authored by mcarare's avatar mcarare Committed by Mihai Adrian Carare
Browse files

For #16477: Migrate updateAccessibilityCollectionItemInfo to extension.

parent b52f0695
......@@ -66,6 +66,35 @@ fun View.addChildToAccessibilityNodeInfo(child: View) {
}
}
/**
* Updates the a11y collection item info for an item in a list.
*/
fun View.updateAccessibilityCollectionItemInfo(
rowIndex: Int,
columnIndex: Int,
isSelected: Boolean,
rowSpan: Int = 1,
columnSpan: Int = 1
) {
this.accessibilityDelegate = object : View.AccessibilityDelegate() {
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfo?
) {
super.onInitializeAccessibilityNodeInfo(host, info)
info?.collectionItemInfo =
AccessibilityNodeInfo.CollectionItemInfo.obtain(
rowIndex,
rowSpan,
columnIndex,
columnSpan,
false,
isSelected
)
}
}
}
/**
* Fills a [Rect] with data about a view's location in the screen.
*
......
......@@ -22,6 +22,7 @@ import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.updateAccessibilityCollectionItemInfo
class FenixTabsAdapter(
private val context: Context,
......@@ -88,8 +89,7 @@ class FenixTabsAdapter(
columnIndex = itemIndex % columnsCount
}
(holder as TabTrayViewHolder).updateAccessibilityCollectionItemInfo(
holder.itemView,
holder.itemView.updateAccessibilityCollectionItemInfo(
rowIndex,
columnIndex,
selectedItems.contains(holder.tab)
......
......@@ -5,7 +5,6 @@
package org.mozilla.fenix.tabtray
import android.view.View
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
......@@ -219,31 +218,6 @@ class TabTrayViewHolder(
imageLoader.loadIntoView(thumbnailView, ImageLoadRequest(id, thumbnailSize))
}
internal fun updateAccessibilityCollectionItemInfo(
item: View,
rowIndex: Int,
columnIndex: Int,
isSelected: Boolean
) {
item.accessibilityDelegate = object : View.AccessibilityDelegate() {
override fun onInitializeAccessibilityNodeInfo(
host: View?,
info: AccessibilityNodeInfo?
) {
super.onInitializeAccessibilityNodeInfo(host, info)
info?.collectionItemInfo =
AccessibilityNodeInfo.CollectionItemInfo.obtain(
rowIndex,
1,
columnIndex,
1,
false,
isSelected
)
}
}
}
companion object {
private const val PLAY_PAUSE_BUTTON_EXTRA_DPS = 24
private const val GRID_ITEM_CLOSE_BUTTON_EXTRA_DPS = 24
......
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