Message composer: add content descriptions to image buttons

Signed-off-by: Peter Vágner <pvdeejay@gmail.com>
This commit is contained in:
Peter Vágner 2019-06-29 22:05:36 +02:00 committed by Peter Vágner
parent 588e5d6e63
commit 2edfd4e830
2 changed files with 12 additions and 4 deletions

View File

@ -260,9 +260,9 @@ class RoomDetailFragment :
roomDetailViewModel.selectSubscribe(RoomDetailViewState::sendMode) { mode -> roomDetailViewModel.selectSubscribe(RoomDetailViewState::sendMode) { mode ->
when (mode) { when (mode) {
is SendMode.REGULAR -> renderRegularMode(mode.text) is SendMode.REGULAR -> renderRegularMode(mode.text)
is SendMode.EDIT -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, mode.text) is SendMode.EDIT -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, R.string.edit, mode.text)
is SendMode.QUOTE -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, mode.text) is SendMode.QUOTE -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, R.string.quote, mode.text)
is SendMode.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, mode.text) is SendMode.REPLY -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text)
} }
} }
@ -357,10 +357,12 @@ class RoomDetailFragment :
composerLayout.collapse() composerLayout.collapse()
updateComposerText(text) updateComposerText(text)
composerLayout.sendButton.setContentDescription(getString(R.string.send))
} }
private fun renderSpecialMode(event: TimelineEvent, private fun renderSpecialMode(event: TimelineEvent,
@DrawableRes iconRes: Int, @DrawableRes iconRes: Int,
descriptionRes: Int,
defaultContent: String) { defaultContent: String) {
commandAutocompletePolicy.enabled = false commandAutocompletePolicy.enabled = false
//switch to expanded bar //switch to expanded bar
@ -384,6 +386,8 @@ class RoomDetailFragment :
updateComposerText(defaultContent) updateComposerText(defaultContent)
composerLayout.composerRelatedMessageActionIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), iconRes)) composerLayout.composerRelatedMessageActionIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), iconRes))
composerLayout.sendButton.setContentDescription(getString(descriptionRes))
avatarRenderer.render(event.senderAvatar, event.root.senderId avatarRenderer.render(event.senderAvatar, event.root.senderId
?: "", event.senderName, composerLayout.composerRelatedMessageAvatar) ?: "", event.senderName, composerLayout.composerRelatedMessageAvatar)
@ -592,6 +596,7 @@ class RoomDetailFragment :
Timber.w("Send button is locked") Timber.w("Send button is locked")
return@setOnClickListener return@setOnClickListener
} }
composerLayout.sendButton.setContentDescription(getString(R.string.send))
val textMessage = composerLayout.composerEditText.text.toString() val textMessage = composerLayout.composerEditText.text.toString()
if (textMessage.isNotBlank()) { if (textMessage.isNotBlank()) {
lockSendButton = true lockSendButton = true

View File

@ -73,6 +73,7 @@
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_close" android:contentDescription="@string/action_close"
android:src="@drawable/ic_close_round" android:src="@drawable/ic_close_round"
android:contentDescription="@string/action_close"
android:tint="@color/riotx_notice" android:tint="@color/riotx_notice"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
@ -91,6 +92,7 @@
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/send_attachment" android:contentDescription="@string/send_attachment"
android:src="@drawable/ic_attachment" android:src="@drawable/ic_attachment"
android:contentDescription="@string/option_send_files"
android:tint="?attr/colorAccent" android:tint="?attr/colorAccent"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
@ -111,6 +113,7 @@
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/send" android:contentDescription="@string/send"
android:src="@drawable/ic_send" android:src="@drawable/ic_send"
android:contentDescription="@string/send"
android:tint="?attr/colorAccent" android:tint="?attr/colorAccent"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
@ -128,4 +131,4 @@
tools:hint="@string/room_message_placeholder_not_encrypted" tools:hint="@string/room_message_placeholder_not_encrypted"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
</merge> </merge>