Fix contentDescriptions

This commit is contained in:
Andrew 2024-01-23 14:24:10 +10:00
parent 43745ce995
commit 97d6c9928f
5 changed files with 19 additions and 21 deletions

View File

@ -58,7 +58,10 @@ class DisappearingMessages @Inject constructor(
)
)
}
destructiveButton(if (message.expiresIn == 0L) R.string.dialog_disappearing_messages_follow_setting_confirm else R.string.dialog_disappearing_messages_follow_setting_set) {
destructiveButton(
text = if (message.expiresIn == 0L) R.string.dialog_disappearing_messages_follow_setting_confirm else R.string.dialog_disappearing_messages_follow_setting_set,
contentDescription = if (message.expiresIn == 0L) R.string.AccessibilityId_confirm else R.string.AccessibilityId_set_button
) {
set(message.threadId, message.recipient.address, message.expiryMode)
}
cancelButton()

View File

@ -257,13 +257,14 @@ class VisibleMessageView : LinearLayout {
binding.expirationTimerView.isGone = true
if (message.isOutgoing || disappearing) {
val (iconID, iconColor, textId, contentDescription) = getMessageStatusImage(message)
val (iconID, iconColor, textId) = getMessageStatusImage(message)
textId?.let(binding.messageStatusTextView::setText)
iconColor?.let(binding.messageStatusTextView::setTextColor)
iconID?.let { ContextCompat.getDrawable(context, it) }
?.run { iconColor?.let { mutate().apply { setTint(it) } } ?: this }
?.let(binding.messageStatusImageView::setImageDrawable)
binding.messageStatusImageView.contentDescription = contentDescription
binding.messageStatusTextView.contentDescription = context.getString(R.string.AccessibilityId_message_sent_status)
binding.messageStatusImageView.contentDescription = context.getString(R.string.AccessibilityId_message_sent_status)
val lastMessageID = mmsSmsDb.getLastMessageID(message.threadId)
val isLastMessage = message.id == lastMessageID
@ -305,48 +306,41 @@ class VisibleMessageView : LinearLayout {
data class MessageStatusInfo(@DrawableRes val iconId: Int?,
@ColorInt val iconTint: Int?,
@StringRes val messageText: Int?,
val contentDescription: String?)
@StringRes val messageText: Int?)
private fun getMessageStatusImage(message: MessageRecord): MessageStatusInfo = when {
message.isFailed ->
MessageStatusInfo(
R.drawable.ic_delivery_status_failed,
resources.getColor(R.color.destructive, context.theme),
R.string.delivery_status_failed,
null
R.string.delivery_status_failed
)
message.isSyncFailed ->
MessageStatusInfo(
R.drawable.ic_delivery_status_failed,
context.getColor(R.color.accent_orange),
R.string.delivery_status_sync_failed,
null
R.string.delivery_status_sync_failed
)
message.isPending ->
MessageStatusInfo(
R.drawable.ic_delivery_status_sending,
context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_sending,
context.getString(R.string.AccessibilityId_message_sent_status_pending)
context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_sending
)
message.isResyncing ->
MessageStatusInfo(
R.drawable.ic_delivery_status_sending,
context.getColor(R.color.accent_orange), R.string.delivery_status_syncing,
context.getString(R.string.AccessibilityId_message_sent_status_syncing)
context.getColor(R.color.accent_orange), R.string.delivery_status_syncing
)
message.isRead || !message.isOutgoing ->
MessageStatusInfo(
R.drawable.ic_delivery_status_read,
context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_read,
null
context.getColorFromAttr(R.attr.message_status_color), R.string.delivery_status_read
)
else ->
MessageStatusInfo(
R.drawable.ic_delivery_status_sent,
context.getColorFromAttr(R.attr.message_status_color),
R.string.delivery_status_sent,
context.getString(R.string.AccessibilityId_message_sent_status_tick)
R.string.delivery_status_sent
)
}

View File

@ -56,7 +56,8 @@
android:layout_marginTop="4dp"
android:textColor="@color/accent_green"
android:textSize="@dimen/very_small_font_size"
android:text="Follow Setting"
android:text="@string/MessageRecord_follow_setting"
android:contentDescription="@string/"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

View File

@ -82,6 +82,7 @@
<!-- Conversation icons -->
<string name="AccessibilityId_call_button">Call button</string>
<string name="AccessibilityId_settings">Settings</string>
<string name="AccessibilityId_confirm">Confirm</string>
<string name="AccessibilityId_disappearing_messages_time_picker">Time selector</string>
<string name="AccessibilityId_accept_message_request_button">Accept message request</string>
<string name="AccessibilityId_decline_message_request_button">Decline message request</string>
@ -113,9 +114,7 @@
<string name="AccessibilityId_download_media">Download media</string>
<string name="AccessibilityId_dont_download_media">Don\'t download media</string>
<!-- Conversation View-->
<string name="AccessibilityId_message_sent_status_tick">Message sent status: Sent</string>
<string name="AccessibilityId_message_sent_status_pending">Message sent status pending</string>
<string name="AccessibilityId_message_sent_status_syncing">Message sent status syncing</string>
<string name="AccessibilityId_message_sent_status">Message sent status</string>
<string name="AccessibilityId_message_request_config_message">Message request has been accepted</string>
<string name="AccessibilityId_message_body">Message body</string>
<string name="AccessibilityId_voice_message">Voice message</string>

View File

@ -15,6 +15,7 @@
<string name="MessageRecord_s_called_you">%s called you</string>
<string name="MessageRecord_called_s">Called %s</string>
<string name="MessageRecord_missed_call_from">Missed call from %s</string>
<string name="MessageRecord_follow_setting">Follow Setting</string>
<string name="MessageRecord_you_disabled_disappearing_messages">You disabled disappearing messages.</string>
<string name="MessageRecord_you_turned_off_disappearing_messages">You have turned off disappearing messages.</string>
<string name="MessageRecord_you_turned_off_disappearing_messages_1_on_1">You turned off disappearing messages. Messages you send will no longer disappear.</string>