Improve emoji picker accessibility (#944)

* set emoji shortcode as content description on ImageView

* hide bottom sheets on back press
This commit is contained in:
Konrad Pozniak 2018-12-07 17:05:02 +01:00 committed by GitHub
parent 59257c7af4
commit 73670b8576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 6 deletions

View file

@ -1479,6 +1479,16 @@ public final class ComposeActivity
}
private void handleCloseButton() {
if(composeOptionsBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED ||
addMediaBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED ||
emojiBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED ) {
composeOptionsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
addMediaBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
emojiBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
return;
}
CharSequence contentText = textEditor.getText();
CharSequence contentWarning = contentWarningEditor.getText();

View file

@ -35,20 +35,22 @@ class EmojiAdapter(emojiList: List<Emoji>, private val onEmojiSelectedListener:
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EmojiAdapter.EmojiHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_emoji_button, parent, false) as ImageView
return EmojiHolder(view)
}
override fun onBindViewHolder(viewHolder: EmojiAdapter.EmojiHolder, position: Int) {
val emoji = emojiList[position]
Picasso.with(viewHolder.emojiImageView.context)
.load(emojiList[position].url)
.load(emoji.url)
.into(viewHolder.emojiImageView)
viewHolder.emojiImageView.setOnClickListener {
onEmojiSelectedListener.onEmojiSelected(emojiList[position].shortcode)
onEmojiSelectedListener.onEmojiSelected(emoji.shortcode)
}
viewHolder.emojiImageView.contentDescription = emoji.shortcode
}
class EmojiHolder(val emojiImageView: ImageView) : RecyclerView.ViewHolder(emojiImageView)