Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthew Finkel
fenix
Commits
e2322a18
Commit
e2322a18
authored
Nov 12, 2020
by
mcarare
Committed by
Mihai Adrian Carare
Nov 13, 2020
Browse files
For #16477: Migrate updateAccessibilityCollectionItemInfo to extension.
parent
b52f0695
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/ext/View.kt
View file @
e2322a18
...
...
@@ -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.
*
...
...
app/src/main/java/org/mozilla/fenix/tabtray/FenixTabsAdapter.kt
View file @
e2322a18
...
...
@@ -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
)
...
...
app/src/main/java/org/mozilla/fenix/tabtray/TabTrayViewHolder.kt
View file @
e2322a18
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment