Add accessibility id's

This commit is contained in:
charles 2022-12-22 12:07:45 +11:00
parent 7c6e4679fe
commit f600e4d343
7 changed files with 47 additions and 11 deletions

View File

@ -171,6 +171,7 @@ class ConversationActionBarView : LinearLayout {
fun bind(setting: ConversationSetting, itemCount: Int, listener: (ConversationSetting) -> Unit) {
binding.root.setOnClickListener { listener.invoke(setting) }
binding.root.contentDescription = setting.contentDescription
binding.iconImageView.setImageResource(setting.iconResId)
binding.iconImageView.isVisible = setting.iconResId > 0
binding.titleView.text = setting.title
@ -201,7 +202,8 @@ fun interface ConversationActionBarDelegate {
data class ConversationSetting(
val title: String,
val settingType: ConversationSettingType,
val iconResId: Int = 0
val iconResId: Int = 0,
val contentDescription: String = ""
)
enum class ConversationSettingType {

View File

@ -41,9 +41,13 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
private val viewModel: ExpirationSettingsViewModel by viewModels {
val afterReadOptions = resources.getIntArray(R.array.read_expiration_time_values).map(Int::toString)
.zip(resources.getStringArray(R.array.read_expiration_time_names)) { value, name -> RadioOption(value, name)}
.zip(resources.getStringArray(R.array.read_expiration_time_names)) { value, name ->
RadioOption(value, name, getString(R.string.AccessibilityId_time_option))
}
val afterSendOptions = resources.getIntArray(R.array.send_expiration_time_values).map(Int::toString)
.zip(resources.getStringArray(R.array.send_expiration_time_names)) { value, name -> RadioOption(value, name)}
.zip(resources.getStringArray(R.array.send_expiration_time_names)) { value, name ->
RadioOption(value, name, getString(R.string.AccessibilityId_time_option))
}
viewModelFactory.create(threadId, mayAddTestExpiryOption(afterReadOptions), mayAddTestExpiryOption(afterSendOptions))
}
@ -161,16 +165,22 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
if (viewModel.recipient.value?.isContactRecipient == true && viewModel.recipient.value?.isLocalNumber == false) {
deleteTypeOptions.addAll(
listOf(
RadioOption(value = "-1", title = getString(R.string.expiration_off)),
RadioOption(
value = "-1",
title = getString(R.string.expiration_off),
contentDescription = getString(R.string.AccessibilityId_disable_disappearing_messages)
),
RadioOption(
value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(),
title = getString(R.string.expiration_type_disappear_after_read),
subtitle = getString(R.string.expiration_type_disappear_after_read_description)
subtitle = getString(R.string.expiration_type_disappear_after_read_description),
contentDescription = getString(R.string.AccessibilityId_disappear_after_read_option)
),
RadioOption(
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
title = getString(R.string.expiration_type_disappear_after_send),
subtitle = getString(R.string.expiration_type_disappear_after_send_description)
subtitle = getString(R.string.expiration_type_disappear_after_send_description),
contentDescription = getString(R.string.AccessibilityId_disappear_after_send_option)
)
)
)
@ -179,7 +189,11 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
if (viewModel.recipient.value?.isContactRecipient == true && viewModel.recipient.value?.isLocalNumber == false) {
deleteTypeOptions.addAll(
listOf(
RadioOption(value = "-1", title = getString(R.string.expiration_off)),
RadioOption(
value = "-1",
title = getString(R.string.expiration_off),
contentDescription = getString(R.string.AccessibilityId_disable_disappearing_messages)
),
RadioOption(
value = "0",
title = getString(R.string.expiration_type_disappear_legacy),
@ -189,13 +203,15 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(),
title = getString(R.string.expiration_type_disappear_after_read),
subtitle = getString(R.string.expiration_type_disappear_after_read_description),
enabled = false
enabled = false,
contentDescription = getString(R.string.AccessibilityId_disappear_after_read_option)
),
RadioOption(
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
title = getString(R.string.expiration_type_disappear_after_send),
subtitle = getString(R.string.expiration_type_disappear_after_send_description),
enabled = false
enabled = false,
contentDescription = getString(R.string.AccessibilityId_disappear_after_send_option)
)
)
)
@ -212,7 +228,8 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
value = ExpirationType.DELETE_AFTER_SEND_VALUE.toString(),
title = getString(R.string.expiration_type_disappear_after_send),
subtitle = getString(R.string.expiration_type_disappear_after_send_description),
enabled = false
enabled = false,
contentDescription = getString(R.string.AccessibilityId_disappear_after_send_option)
)
)
)

View File

@ -49,6 +49,7 @@ class RadioOptionAdapter(
fun bind(option: RadioOption, isSelected: Boolean, toggleSelection: (RadioOption) -> Unit) {
val alpha = if (option.enabled) 1f else 0.5f
binding.root.isEnabled = option.enabled
binding.root.contentDescription = option.contentDescription
binding.titleTextView.alpha = alpha
binding.subtitleTextView.alpha = alpha
binding.selectButton.alpha = alpha
@ -69,5 +70,6 @@ data class RadioOption(
val value: String,
val title: String,
val subtitle: String? = null,
val enabled: Boolean = true
val enabled: Boolean = true,
val contentDescription: String = ""
)

View File

@ -73,6 +73,7 @@
android:id="@+id/layout_timer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/AccessibilityId_disappearing_messages_timer"
android:layout_marginHorizontal="@dimen/small_spacing"
android:background="@drawable/preference_single"
android:paddingHorizontal="@dimen/large_spacing"
@ -108,6 +109,7 @@
style="@style/Widget.Session.Button.Common.ProminentOutline"
android:layout_width="196dp"
android:layout_height="@dimen/medium_button_height"
android:contentDescription="@string/AccessibilityId_set_button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/medium_spacing"

View File

@ -33,6 +33,7 @@
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/AccessibilityId_configuration_message"
android:gravity="center"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/very_small_font_size"

View File

@ -22,6 +22,7 @@
android:id="@+id/conversationTitleView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/AccessibilityId_conversation_header_name"
tools:text="@tools:sample/full_names"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"

View File

@ -9,6 +9,17 @@
<string name="save">Save</string>
<string name="note_to_self">Note to Self</string>
<string name="version_s">Version %s</string>
<!-- Disappearing messages -->
<string name="AccessibilityId_disappear_after_read_option">Disappear after read option</string>
<string name="AccessibilityId_disappear_after_send_option">Disappear after send option</string>
<string name="AccessibilityId_disappearing_messages_timer">Disappearing messages timer</string>
<string name="AccessibilityId_set_button">Set button</string>
<string name="AccessibilityId_time_option">Time option</string>
<string name="AccessibilityId_disable_disappearing_messages">Disable disappearing messages (Off option)</string>
<string name="AccessibilityId_configuration_message">Configuration message</string>
<string name="AccessibilityId_disappearing_messages_type_and_time">Disappearing messages type and time</string>
<string name="AccessibilityId_conversation_header_name">Conversation header name</string>
<!-- AbstractNotificationBuilder -->
<string name="AbstractNotificationBuilder_new_message">New message</string>
<!-- AlbumThumbnailView -->