From 73670b8576b307ae869216f72260e00497906548 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Fri, 7 Dec 2018 17:05:02 +0100 Subject: [PATCH] Improve emoji picker accessibility (#944) * set emoji shortcode as content description on ImageView * hide bottom sheets on back press --- .../com/keylesspalace/tusky/ComposeActivity.java | 10 ++++++++++ .../keylesspalace/tusky/adapter/EmojiAdapter.kt | 14 ++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index fe921a82..6e561593 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -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(); diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt index 8d31ae6f..6afd71b5 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/EmojiAdapter.kt @@ -35,20 +35,22 @@ class EmojiAdapter(emojiList: List, 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) - + 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)