mirror of
https://github.com/element-hq/element-android
synced 2024-11-25 02:45:37 +03:00
Add contentDescription for the read receipts
Signed-off-by: Peter Vágner <pvdeejay@gmail.com>
This commit is contained in:
parent
73dd735ba6
commit
7ef471ad0d
3 changed files with 24 additions and 1 deletions
|
@ -28,6 +28,7 @@ import im.vector.riotx.features.home.room.detail.timeline.item.ReadReceiptData
|
|||
import kotlinx.android.synthetic.main.view_read_receipts.view.*
|
||||
|
||||
private const val MAX_RECEIPT_DISPLAYED = 5
|
||||
private const val MAX_RECEIPT_DESCRIBED = 4
|
||||
|
||||
class ReadReceiptsView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -51,6 +52,7 @@ class ReadReceiptsView @JvmOverloads constructor(
|
|||
setOnClickListener(clickListener)
|
||||
if (readReceipts.isNotEmpty()) {
|
||||
isVisible = true
|
||||
val displayNames = arrayListOf<String>()
|
||||
for (index in 0 until MAX_RECEIPT_DISPLAYED) {
|
||||
val receiptData = readReceipts.getOrNull(index)
|
||||
if (receiptData == null) {
|
||||
|
@ -58,6 +60,9 @@ class ReadReceiptsView @JvmOverloads constructor(
|
|||
} else {
|
||||
receiptAvatars[index].visibility = View.VISIBLE
|
||||
avatarRenderer.render(receiptData.avatarUrl, receiptData.userId, receiptData.displayName, receiptAvatars[index])
|
||||
if (null !=receiptData.displayName && displayNames.size <MAX_RECEIPT_DESCRIBED) {
|
||||
displayNames.add(receiptData.displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (readReceipts.size > MAX_RECEIPT_DISPLAYED) {
|
||||
|
@ -68,6 +73,13 @@ class ReadReceiptsView @JvmOverloads constructor(
|
|||
} else {
|
||||
receiptMore.visibility = View.GONE
|
||||
}
|
||||
when (displayNames.size) {
|
||||
0 -> setContentDescription(context.getResources().getQuantityString(R.plurals.fallback_users_read, readReceipts.size))
|
||||
1 -> setContentDescription(context.getString(R.string.one_user_read, displayNames.get(0)))
|
||||
2 -> setContentDescription(context.getString(R.string.two_users_read, displayNames.get(0), displayNames.get(1)))
|
||||
3 -> setContentDescription(context.getString(R.string.three_users_read, displayNames.get(0), displayNames.get(1), displayNames.get(2)))
|
||||
else -> setContentDescription(context.getString(R.string.two_and_some_others_read, displayNames.get(0), displayNames.get(1), (readReceipts.size -2)))
|
||||
}
|
||||
} else {
|
||||
isVisible = false
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
android:background="?vctr_pill_receipt"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:importantForAccessibility = "no"
|
||||
tools:text="999+" />
|
||||
|
||||
<ImageView
|
||||
|
|
|
@ -22,6 +22,16 @@
|
|||
<string name="a11y_create_room">Create a new room</string>
|
||||
<string name="a11y_close_keys_backup_banner">Close keys backup banner</string>
|
||||
|
||||
<!-- Read receipts list a11y -->
|
||||
<string name="two_and_some_others_read">%s, %s and %d others read</string>
|
||||
<string name="three_users_read">%s, %s and %s read</string>
|
||||
<string name="two_users_read">%s and %s read</string>
|
||||
<string name="one_user_read">%s read</string>
|
||||
<plurals name="fallback_users_read">
|
||||
<item quantity="one">1 user read</item>
|
||||
<item quantity="other">%d users read</item>
|
||||
</plurals>
|
||||
|
||||
<string name="error_file_too_big">"The file '%1$s' (%2$s) is too large to upload. The limit is %3$s."</string>
|
||||
|
||||
</resources>
|
Loading…
Reference in a new issue