Add accessibility labels for GIF categories and correct emoji labels.

This commit is contained in:
Sagar
2025-04-11 21:27:17 +05:30
committed by Cody Henthorne
parent 3ff7f89ef6
commit e3297ab593
5 changed files with 33 additions and 10 deletions

View File

@@ -14,6 +14,7 @@ interface KeyboardPageCategoryIconMappingModel<T : KeyboardPageCategoryIconMappi
val selected: Boolean
fun getIcon(context: Context): Drawable
fun getContentDescription(context: Context): String
}
class KeyboardPageCategoryIconViewHolder<T : KeyboardPageCategoryIconMappingModel<T>>(itemView: View, private val onPageSelected: Consumer<String>) : MappingViewHolder<T>(itemView) {
@@ -27,7 +28,7 @@ class KeyboardPageCategoryIconViewHolder<T : KeyboardPageCategoryIconMappingMode
}
iconView.setImageDrawable(model.getIcon(context))
iconView.contentDescription = model.key
iconView.contentDescription = model.getContentDescription(context)
iconView.isSelected = model.selected
iconSelected.isSelected = model.selected
}

View File

@@ -15,6 +15,10 @@ class RecentsMappingModel(override val selected: Boolean) : KeyboardPageCategory
return requireNotNull(ThemeUtil.getThemedDrawable(context, R.attr.emoji_category_recent))
}
override fun getContentDescription(context: Context): String {
return context.getString(R.string.ReactWithAnyEmojiBottomSheetDialogFragment__recents)
}
override fun areItemsTheSame(newItem: RecentsMappingModel): Boolean {
return newItem.key == key
}
@@ -31,6 +35,10 @@ class EmojiCategoryMappingModel(private val emojiCategory: EmojiCategory, overri
return requireNotNull(ThemeUtil.getThemedDrawable(context, emojiCategory.icon))
}
override fun getContentDescription(context: Context): String {
return context.getString(emojiCategory.getCategoryLabel())
}
override fun areItemsTheSame(newItem: EmojiCategoryMappingModel): Boolean {
return newItem.key == key
}

View File

@@ -19,6 +19,7 @@ class GifQuickSearchAdapter(clickListener: (GifQuickSearchOption) -> Unit) : Map
override fun bind(model: GifQuickSearch) {
image.setImageResource(model.gifQuickSearchOption.image)
image.isSelected = model.selected
image.contentDescription = itemView.context.getString(model.gifQuickSearchOption.categoryLabel)
imageSelected.isSelected = model.selected
itemView.setOnClickListener { listener(model.gifQuickSearchOption) }
}

View File

@@ -1,16 +1,17 @@
package org.thoughtcrime.securesms.keyboard.gif
import androidx.annotation.StringRes
import org.thoughtcrime.securesms.R
enum class GifQuickSearchOption(private val rank: Int, val image: Int, val query: String) {
TRENDING(0, R.drawable.ic_gif_trending_24, ""),
CELEBRATE(1, R.drawable.ic_gif_celebrate_24, "celebrate"),
LOVE(2, R.drawable.ic_gif_love_24, "love"),
THUMBS_UP(3, R.drawable.ic_gif_thumbsup_24, "thumbs up"),
SURPRISED(4, R.drawable.ic_gif_surprised_24, "surprised"),
EXCITED(5, R.drawable.ic_gif_excited_24, "excited"),
SAD(6, R.drawable.ic_gif_sad_24, "sad"),
ANGRY(7, R.drawable.ic_gif_angry_24, "angry");
enum class GifQuickSearchOption(private val rank: Int, val image: Int, val query: String, @StringRes val categoryLabel: Int) {
TRENDING(0, R.drawable.ic_gif_trending_24, "", R.string.GifQuickSearchOption__trending),
CELEBRATE(1, R.drawable.ic_gif_celebrate_24, "celebrate", R.string.GifQuickSearchOption__celebrate),
LOVE(2, R.drawable.ic_gif_love_24, "love", R.string.GifQuickSearchOption__love),
THUMBS_UP(3, R.drawable.ic_gif_thumbsup_24, "thumbs up", R.string.GifQuickSearchOption__thumbs_up),
SURPRISED(4, R.drawable.ic_gif_surprised_24, "surprised", R.string.GifQuickSearchOption__surprised),
EXCITED(5, R.drawable.ic_gif_excited_24, "excited", R.string.GifQuickSearchOption__excited),
SAD(6, R.drawable.ic_gif_sad_24, "sad", R.string.GifQuickSearchOption__sad),
ANGRY(7, R.drawable.ic_gif_angry_24, "angry", R.string.GifQuickSearchOption__angry);
companion object {
val ranked: List<GifQuickSearchOption> by lazy { entries.sortedBy { it.rank } }