mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/16477: Migrate updateAccessibilityCollectionItemInfo to extension.
This commit is contained in:
parent
33e8a2b22b
commit
2302a589da
@ -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.
|
* 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.components
|
||||||
import org.mozilla.fenix.ext.metrics
|
import org.mozilla.fenix.ext.metrics
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
import org.mozilla.fenix.ext.updateAccessibilityCollectionItemInfo
|
||||||
|
|
||||||
class FenixTabsAdapter(
|
class FenixTabsAdapter(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
@ -88,8 +89,7 @@ class FenixTabsAdapter(
|
|||||||
columnIndex = itemIndex % columnsCount
|
columnIndex = itemIndex % columnsCount
|
||||||
}
|
}
|
||||||
|
|
||||||
(holder as TabTrayViewHolder).updateAccessibilityCollectionItemInfo(
|
holder.itemView.updateAccessibilityCollectionItemInfo(
|
||||||
holder.itemView,
|
|
||||||
rowIndex,
|
rowIndex,
|
||||||
columnIndex,
|
columnIndex,
|
||||||
selectedItems.contains(holder.tab)
|
selectedItems.contains(holder.tab)
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
package org.mozilla.fenix.tabtray
|
package org.mozilla.fenix.tabtray
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.accessibility.AccessibilityNodeInfo
|
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
@ -219,31 +218,6 @@ class TabTrayViewHolder(
|
|||||||
imageLoader.loadIntoView(thumbnailView, ImageLoadRequest(id, thumbnailSize))
|
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 {
|
companion object {
|
||||||
private const val PLAY_PAUSE_BUTTON_EXTRA_DPS = 24
|
private const val PLAY_PAUSE_BUTTON_EXTRA_DPS = 24
|
||||||
private const val GRID_ITEM_CLOSE_BUTTON_EXTRA_DPS = 24
|
private const val GRID_ITEM_CLOSE_BUTTON_EXTRA_DPS = 24
|
||||||
|
Loading…
Reference in New Issue
Block a user